Skip to content

Commit

Permalink
GLSL compatibility layer improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Dec 29, 2013
1 parent b6fcb29 commit de09651
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 138 deletions.
34 changes: 17 additions & 17 deletions glsl/defaultCelshade.glsl
Expand Up @@ -10,11 +10,11 @@
#include "include/greyscale.glsl"
#endif

varying vec2 v_TexCoord;
varying vec3 v_TexCoordCube;
qf_varying vec2 v_TexCoord;
qf_varying vec3 v_TexCoordCube;

#if defined(APPLY_FOG) && !defined(APPLY_FOG_COLOR)
varying vec2 v_FogCoord;
qf_varying vec2 v_FogCoord;
#endif

#ifdef VERTEX_SHADER
Expand Down Expand Up @@ -44,7 +44,7 @@ void main(void)
#endif
#endif

gl_FrontColor = vec4(outColor);
qf_FrontColor = vec4(outColor);

v_TexCoord = TextureMatrix2x3Mul(u_TextureMatrix, TexCoord);
v_TexCoordCube = vec3(u_ReflectionTexMatrix * vec4(reflect(normalize(Position.xyz - u_EntityDist), Normal.xyz), 0.0));
Expand Down Expand Up @@ -78,51 +78,51 @@ uniform samplerCube u_CelLightTexture;

void main(void)
{
myhalf4 inColor = myhalf4(gl_Color);
myhalf4 inColor = myhalf4(qf_FrontColor);

myhalf4 tempColor;

myhalf4 outColor;
outColor = myhalf4(texture2D(u_BaseTexture, v_TexCoord));
outColor = myhalf4(qf_texture(u_BaseTexture, v_TexCoord));

#ifdef APPLY_ENTITY_DECAL
#ifdef APPLY_ENTITY_DECAL_ADD
outColor.rgb += myhalf3(u_EntityColor.rgb) * myhalf3(texture2D(u_EntityDecalTexture, v_TexCoord));
outColor.rgb += myhalf3(u_EntityColor.rgb) * myhalf3(qf_texture(u_EntityDecalTexture, v_TexCoord));
#else
tempColor = myhalf4(u_EntityColor.rgb, 1.0) * myhalf4(texture2D(u_EntityDecalTexture, v_TexCoord));
tempColor = myhalf4(u_EntityColor.rgb, 1.0) * myhalf4(qf_texture(u_EntityDecalTexture, v_TexCoord));
outColor.rgb = mix(outColor.rgb, tempColor.rgb, tempColor.a);
#endif
#endif // APPLY_ENTITY_DECAL

#ifdef APPLY_DIFFUSE
outColor.rgb *= myhalf3(texture2D(u_DiffuseTexture, v_TexCoord));
outColor.rgb *= myhalf3(qf_texture(u_DiffuseTexture, v_TexCoord));
#endif

outColor.rgb *= myhalf3(textureCube(u_CelShadeTexture, v_TexCoordCube));
outColor.rgb *= myhalf3(qf_textureCube(u_CelShadeTexture, v_TexCoordCube));

#ifdef APPLY_STRIPES
#ifdef APPLY_STRIPES_ADD
outColor.rgb += myhalf3(u_EntityColor.rgb) * myhalf3(texture2D(u_StripesTexture, v_TexCoord));
outColor.rgb += myhalf3(u_EntityColor.rgb) * myhalf3(qf_texture(u_StripesTexture, v_TexCoord));
#else
tempColor = myhalf4(u_EntityColor.rgb, 1.0) * myhalf4(texture2D(u_StripesTexture, v_TexCoord));
tempColor = myhalf4(u_EntityColor.rgb, 1.0) * myhalf4(qf_texture(u_StripesTexture, v_TexCoord));
outColor.rgb = mix(outColor.rgb, tempColor.rgb, tempColor.a);
#endif
#endif // APPLY_STRIPES_ADD

#ifdef APPLY_CEL_LIGHT
#ifdef APPLY_CEL_LIGHT_ADD
outColor.rgb += myhalf3(textureCube(u_CelLightTexture, v_TexCoordCube));
outColor.rgb += myhalf3(qf_textureCube(u_CelLightTexture, v_TexCoordCube));
#else
tempColor = myhalf4(textureCube(u_EntityDecalTexture, v_TexCoordCube));
tempColor = myhalf4(qf_textureCube(u_EntityDecalTexture, v_TexCoordCube));
outColor.rgb = mix(outColor.rgb, tempColor.rgb, tempColor.a);
#endif
#endif // APPLY_CEL_LIGHT

#ifdef APPLY_DECAL
#ifdef APPLY_DECAL_ADD
outColor.rgb += myhalf3(texture2D(u_DecalTexture, v_TexCoord));
outColor.rgb += myhalf3(qf_texture(u_DecalTexture, v_TexCoord));
#else
tempColor = myhalf4(texture2D(u_DecalTexture, v_TexCoord));
tempColor = myhalf4(qf_texture(u_DecalTexture, v_TexCoord));
outColor.rgb = mix(outColor.rgb, tempColor.rgb, tempColor.a);
#endif
#endif // APPLY_DECAL
Expand All @@ -138,7 +138,7 @@ void main(void)
outColor.rgb = mix(outColor.rgb, u_Fog.Color, fogDensity);
#endif

gl_FragColor = vec4(outColor);
qf_FragColor = vec4(outColor);
}

#endif // FRAGMENT_SHADER
32 changes: 16 additions & 16 deletions glsl/defaultDistortion.glsl
Expand Up @@ -5,10 +5,10 @@

#include "include/greyscale.glsl"

varying vec4 v_TexCoord;
varying vec4 v_ProjVector;
qf_varying vec4 v_TexCoord;
qf_varying vec4 v_ProjVector;
#ifdef APPLY_EYEDOT
varying vec3 v_EyeVector;
qf_varying vec3 v_EyeVector;
#endif

#ifdef VERTEX_SHADER
Expand All @@ -33,7 +33,7 @@ void main(void)

TransformVerts(Position, Normal, TexCoord);

gl_FrontColor = vec4(VertexRGBGen(Position, Normal, inColor));
qf_FrontColor = vec4(VertexRGBGen(Position, Normal, inColor));

v_TexCoord.st = TextureMatrix2x3Mul(u_TextureMatrix, TexCoord);

Expand Down Expand Up @@ -77,10 +77,10 @@ void main(void)
myhalf3 color;

#ifdef APPLY_DUDV
vec3 displacement = vec3(texture2D(u_DuDvMapTexture, vec2(v_TexCoord.pq) * vec2(0.25)));
vec3 displacement = vec3(qf_texture(u_DuDvMapTexture, vec2(v_TexCoord.pq) * vec2(0.25)));
vec2 coord = vec2(v_TexCoord.st) + vec2(displacement) * vec2 (0.2);

vec3 fdist = vec3 (normalize(vec3(texture2D(u_DuDvMapTexture, coord)) - vec3 (0.5))) * vec3(0.005);
vec3 fdist = vec3 (normalize(vec3(qf_texture(u_DuDvMapTexture, coord)) - vec3 (0.5))) * vec3(0.005);
#else
vec3 fdist = vec3(0.0);
#endif
Expand All @@ -98,8 +98,8 @@ void main(void)

#ifdef APPLY_EYEDOT
// calculate dot product between the surface normal and eye vector
// great for simulating varying water translucency based on the view angle
myhalf3 surfaceNormal = normalize(myhalf3(texture2D(u_NormalmapTexture, coord)) - myhalf3 (0.5));
// great for simulating qf_varying water translucency based on the view angle
myhalf3 surfaceNormal = normalize(myhalf3(qf_texture(u_NormalmapTexture, coord)) - myhalf3 (0.5));
vec3 eyeNormal = normalize(myhalf3(v_EyeVector));

float refrdot = float(dot(surfaceNormal, eyeNormal));
Expand All @@ -108,34 +108,34 @@ void main(void)
// get refraction and reflection

#ifdef APPLY_REFRACTION
refr = (myhalf3(texture2D(u_RefractionTexture, projCoord))) * refrdot;
refr = (myhalf3(qf_texture(u_RefractionTexture, projCoord))) * refrdot;
#endif
#ifdef APPLY_REFLECTION
refl = (myhalf3(texture2D(u_ReflectionTexture, projCoord))) * refldot;
refl = (myhalf3(qf_texture(u_ReflectionTexture, projCoord))) * refldot;
#endif

#else

#ifdef APPLY_REFRACTION
refr = (myhalf3(texture2D(u_RefractionTexture, projCoord)));
refr = (myhalf3(qf_texture(u_RefractionTexture, projCoord)));
#endif
#ifdef APPLY_REFLECTION
refl = (myhalf3(texture2D(u_ReflectionTexture, projCoord)));
refl = (myhalf3(qf_texture(u_ReflectionTexture, projCoord)));
#endif

#endif // APPLY_EYEDOT

// add reflection and refraction
#ifdef APPLY_DISTORTION_ALPHA
color = myhalf3(gl_Color.rgb) + myhalf3(mix (refr, refl, myhalf(gl_Color.a)));
color = myhalf3(qf_FrontColor.rgb) + myhalf3(mix (refr, refl, myhalf(qf_FrontColor.a)));
#else
color = myhalf3(gl_Color.rgb) + refr + refl;
color = myhalf3(qf_FrontColor.rgb) + refr + refl;
#endif

#ifdef APPLY_GREYSCALE
gl_FragColor = vec4(vec3(Greyscale(color)),1.0);
qf_FragColor = vec4(vec3(Greyscale(color)),1.0);
#else
gl_FragColor = vec4(vec3(color),1.0);
qf_FragColor = vec4(vec3(color),1.0);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions glsl/defaultFXAA.glsl
Expand Up @@ -4,7 +4,7 @@
#include "include/common.glsl"
#include "include/uniforms.glsl"

varying vec2 v_TexCoord;
qf_varying vec2 v_TexCoord;

#ifdef VERTEX_SHADER

Expand Down Expand Up @@ -68,7 +68,7 @@ void main(void)
float ConsoleEdgeThresholdMin = 0.05;
vec4 Console360ConstDir = vec4(1.0, -1.0, 0.25, -0.25);

gl_FragColor = FxaaPixelShader(v_TexCoord, ConsolePosPos, u_BaseTexture, u_BaseTexture, u_BaseTexture,
qf_FragColor = FxaaPixelShader(v_TexCoord, ConsolePosPos, u_BaseTexture, u_BaseTexture, u_BaseTexture,
u_TextureParams.zw, ConsoleRcpFrameOpt, ConsoleRcpFrameOpt2, Console360RcpFrameOpt2,
QualitySubpix, QualityEdgeThreshold, QualityEdgeThresholdMin, ConsoleEdgeSharpness,
ConsoleEdgeThreshold, ConsoleEdgeThresholdMin, Console360ConstDir);
Expand Down
4 changes: 2 additions & 2 deletions glsl/defaultFog.glsl
Expand Up @@ -4,7 +4,7 @@
#include "include/uniforms.glsl"
#include "include/fog.glsl"

varying vec2 v_FogCoord;
qf_varying vec2 v_FogCoord;

#ifdef VERTEX_SHADER

Expand Down Expand Up @@ -32,7 +32,7 @@ void main(void)
void main(void)
{
float fogDensity = FogDensity(v_FogCoord);
gl_FragColor = vec4(u_Fog.Color, fogDensity);
qf_FragColor = vec4(u_Fog.Color, fogDensity);
}

#endif // FRAGMENT_SHADER
Expand Down

0 comments on commit de09651

Please sign in to comment.