Skip to content

Commit

Permalink
ref_gl: introduce gl2_shim based on vgl_shim for future limited core/…
Browse files Browse the repository at this point in the history
…gles context support (SLOW, still needs ffp for matrix operations)
  • Loading branch information
Dmitry Toroshchin committed Oct 4, 2023
1 parent 2fdd080 commit 83b284f
Show file tree
Hide file tree
Showing 10 changed files with 852 additions and 0 deletions.
53 changes: 53 additions & 0 deletions ref/gl/gl2_shim/fragment.glsl.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
R"(
precision mediump float;
#if ATTR_TEXCOORD0
uniform sampler2D uTex0;
#endif
#if ATTR_TEXCOORD1
uniform sampler2D uTex1;
#endif
#if FEAT_ALPHA_TEST
uniform float uAlphaTest;
#endif
#if FEAT_FOG
uniform vec4 uFog;
#endif
uniform vec4 uColor;
#if ATTR_COLOR
in vec4 vColor;
#endif
#if ATTR_TEXCOORD0
in vec2 vTexCoord0;
#endif
#if ATTR_TEXCOORD1
in vec2 vTexCoord1;
#endif
#if ATTR_NORMAL
in vec2 vNormal;
#endif
out vec4 oFragColor;
void main()
{
#if ATTR_COLOR
vec4 c = vColor;
#else
vec4 c = uColor;
#endif
#if ATTR_TEXCOORD0
c = c * texture(uTex0, vTexCoord0);
#endif
#if ATTR_TEXCOORD1
c = c * texture(uTex1, vTexCoord1);
#endif
#if FEAT_ALPHA_TEST
if(c.a <= uAlphaTest)
discard;
#endif
#if FEAT_FOG
float fogDist = gl_FragCoord.z / gl_FragCoord.w;
float fogRate = clamp(exp(-uFog.w * fogDist), 0.f, 1.f);
c.rgb = mix(uFog.rgb, c.rgb, fogRate);
#endif
oFragColor = c;
}
)"
Loading

0 comments on commit 83b284f

Please sign in to comment.