diff options
author | sarbes <sarbes@kodi.tv> | 2024-04-24 21:53:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 21:53:42 +0200 |
commit | 8dc175623ae53f79fce0f949536353e8dcc444ac (patch) | |
tree | a75651deaf034d39521cd30c9863c9930f4aa6a8 /system/shaders/GLES/2.0/gles_shader_clip.vert | |
parent | 7f8591145c25bca49936abd945770d0f02dbd620 (diff) | |
parent | 5b73d31eadd3f38b24d045e2a10b47b0052b3620 (diff) | |
download | xbmc-8dc175623ae53f79fce0f949536353e8dcc444ac.tar.xz |
Merge pull request #25033 from sarbes/font-shader-clipping-gles
GLES: Add font shader clipping
Diffstat (limited to 'system/shaders/GLES/2.0/gles_shader_clip.vert')
-rw-r--r-- | system/shaders/GLES/2.0/gles_shader_clip.vert | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/system/shaders/GLES/2.0/gles_shader_clip.vert b/system/shaders/GLES/2.0/gles_shader_clip.vert new file mode 100644 index 0000000000..513a24456c --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_clip.vert @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#version 100 + +attribute vec4 m_attrpos; +attribute vec4 m_attrcol; +attribute vec4 m_attrcord0; +attribute vec4 m_attrcord1; +varying vec4 m_cord0; +varying vec4 m_cord1; +varying vec4 m_colour; +uniform mat4 m_matrix; +uniform vec4 m_shaderClip; +uniform vec4 m_cordStep; + +// this shader can be used in cases where clipping via glScissor() is not +// possible (e.g. when rotating). it can't discard triangles, but it may +// degenerate them. + +void main() +{ + // limit the vertices to the clipping area + vec4 position = m_attrpos; + position.xy = clamp(position.xy, m_shaderClip.xy, m_shaderClip.zw); + gl_Position = m_matrix * position; + + // correct texture coordinates for clipped vertices + vec2 clipDist = m_attrpos.xy - position.xy; + m_cord0.xy = m_attrcord0.xy - clipDist * m_cordStep.xy; + m_cord1.xy = m_attrcord1.xy - clipDist * m_cordStep.zw; + + m_colour = m_attrcol; +} |