Clean GLSL fragment shader out.

This commit is contained in:
LuisAntonRebollo 2014-11-30 22:56:30 +01:00
parent 87f34e3c4f
commit ed0febea39
135 changed files with 451 additions and 239 deletions

View file

@ -30,8 +30,10 @@ in vec2 texCoord;
uniform sampler2D diffuseMap ;
out vec4 OUT_col;
void main()
{
vec4 col = texture( diffuseMap, IN_texCoord );
OUT_FragColor0 = hdrEncode( col );
OUT_col = hdrEncode( col );
}

View file

@ -28,10 +28,12 @@ uniform sampler2D diffuseMap;
in vec2 texc0, texc1, texc2, texc3;
out vec4 OUT_col;
void main()
{
OUT_FragColor0 = texture(diffuseMap, texc0) * kernel.x;
OUT_FragColor0 += texture(diffuseMap, texc1) * kernel.y;
OUT_FragColor0 += texture(diffuseMap, texc2) * kernel.z;
OUT_FragColor0 += texture(diffuseMap, texc3) * kernel.w;
OUT_col = texture(diffuseMap, texc0) * kernel.x;
OUT_col += texture(diffuseMap, texc1) * kernel.y;
OUT_col += texture(diffuseMap, texc2) * kernel.z;
OUT_col += texture(diffuseMap, texc3) * kernel.w;
}

View file

@ -47,6 +47,8 @@ uniform float cloudCoverage;
uniform vec3 cloudBaseColor;
uniform float cloudExposure;
out vec4 OUT_col;
//-----------------------------------------------------------------------------
// Globals
//-----------------------------------------------------------------------------
@ -141,5 +143,5 @@ void main()
cResultColor.a = mix( cResultColor.a, 0.0, 1.0 - pow(IN_worldDist,2.0) );
OUT_FragColor0 = cResultColor;
OUT_col = cResultColor;
}

View file

@ -29,12 +29,14 @@ uniform vec4 groundAlpha;
in vec4 color, groundAlphaCoeff;
in vec2 outTexCoord, alphaLookup;
out vec4 OUT_col;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
void main()
{
vec4 alpha = texture(alphaMap, alphaLookup);
OUT_FragColor0 = color * texture(diffuseMap, outTexCoord);
OUT_FragColor0.a = OUT_FragColor0.a * min(alpha, groundAlpha + groundAlphaCoeff.x).x;
OUT_col = color * texture(diffuseMap, outTexCoord);
OUT_col.a = OUT_col.a * min(alpha, groundAlpha + groundAlphaCoeff.x).x;
}

View file

@ -100,7 +100,4 @@ mat4 mat4FromRow( float r0c0, float r0c1, float r0c2, float r0c3,
#ifdef TORQUE_PIXEL_SHADER
void clip(float a) { if(a < 0) discard;}
out vec4 OUT_col;
#define OUT_FragColor0 OUT_col
#endif

View file

@ -38,6 +38,7 @@ uniform sampler2D edgeSource;
uniform vec4 edgeTargetParams;
#endif
out vec4 OUT_col;
void main()
{
@ -57,5 +58,5 @@ void main()
#endif
// Sample offscreen target and return
OUT_FragColor0 = texture( colorSource, uvScene.xy );
OUT_col = texture( colorSource, uvScene.xy );
}

View file

@ -78,6 +78,8 @@ vec4 lmSample( vec3 nrm )
uniform float alphaFactor;
uniform float alphaScale;
out vec4 OUT_col;
void main()
{
float softBlend = 1;
@ -100,12 +102,12 @@ void main()
vec4 diffuse = texture( diffuseMap, IN_uv0 );
//OUT_FragColor0 = vec4( lmSample(vec3(0, 0, -1)).rgb, IN_color.a * diffuse.a * softBlend * alphaScale);
//OUT_col = vec4( lmSample(vec3(0, 0, -1)).rgb, IN_color.a * diffuse.a * softBlend * alphaScale);
// Scale output color by the alpha factor (turn LerpAlpha into pre-multiplied alpha)
vec3 colorScale = ( alphaFactor < 0.0 ? IN_color.rgb * diffuse.rgb : vec3( alphaFactor > 0.0 ? IN_color.a * diffuse.a * alphaFactor * softBlend : softBlend ) );
OUT_FragColor0 = hdrEncode( vec4( IN_color.rgb * diffuse.rgb * colorScale,
OUT_col = hdrEncode( vec4( IN_color.rgb * diffuse.rgb * colorScale,
IN_color.a * diffuse.a * softBlend * alphaScale ) );
}

View file

@ -29,6 +29,8 @@ uniform vec4 shadeColor;
in vec2 TEX0;
in vec4 TEX1;
out vec4 OUT_col;
//-----------------------------------------------------------------------------
// Fade edges of axis for texcoord passed in
//-----------------------------------------------------------------------------
@ -64,5 +66,5 @@ void main()
vec4 diffuseColor = texture( diffuseMap, TEX0 );
vec4 reflectColor = textureProj( refractMap, texIndex );
OUT_FragColor0 = diffuseColor + reflectColor * diffuseColor.a;
OUT_col = diffuseColor + reflectColor * diffuseColor.a;
}

View file

@ -29,6 +29,8 @@ uniform vec4 shadeColor;
in vec2 TEX0;
in vec4 TEX1;
out vec4 OUT_col;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
@ -37,5 +39,5 @@ void main()
vec4 diffuseColor = texture( diffuseMap, TEX0 );
vec4 reflectColor = textureProj( refractMap, TEX1 );
OUT_FragColor0 = diffuseColor + reflectColor * diffuseColor.a;
OUT_col = diffuseColor + reflectColor * diffuseColor.a;
}

View file

@ -28,10 +28,12 @@ uniform sampler2D diffuseMap;
in vec4 color;
in vec2 texCoord;
out vec4 OUT_col;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
void main()
{
OUT_FragColor0 = texture(diffuseMap, texCoord) * color;
OUT_col = texture(diffuseMap, texCoord) * color;
}

View file

@ -24,7 +24,7 @@ in vec2 texCoord;
in vec4 color;
in float fade;
out vec4 OUT_FragColor0;
out vec4 OUT_col;
uniform sampler2D inputTex;
uniform vec4 ambient;
@ -33,5 +33,5 @@ uniform vec4 ambient;
void main()
{
float shadow = texture( inputTex, texCoord ).a * color.a;
OUT_FragColor0 = ( ambient * shadow ) + ( 1 - shadow );
OUT_col = ( ambient * shadow ) + ( 1 - shadow );
}

View file

@ -43,6 +43,8 @@ uniform float useCubemap;
uniform vec3 lightDir;
uniform vec3 sunDir;
out vec4 OUT_col;
void main()
{
@ -62,7 +64,7 @@ void main()
float fac = dot( normalize( pos ), sunDir );
fac = max( nightInterpAndExposure.y, pow( clamp( fac, 0.0, 1.0 ), 2 ) );
OUT_FragColor0 = mix( color, nightSkyColor, nightInterpAndExposure.y );
OUT_col = mix( color, nightSkyColor, nightInterpAndExposure.y );
// Clip based on the camera-relative
// z position of the vertex, passed through
@ -70,6 +72,6 @@ void main()
if(zPosition < 0.0)
discard;
OUT_FragColor0.a = 1;
OUT_FragColor0 = hdrEncode( OUT_FragColor0 );
OUT_col.a = 1;
OUT_col = hdrEncode( OUT_col );
}

View file

@ -267,6 +267,6 @@ void fizzle(vec2 vpos, float visibility)
/// @param condition This should be a bvec[2-4]. If any items is false, condition is considered to fail.
/// @param color The color that should be outputted if the condition fails.
/// @note This macro will only work in the void main() method of a pixel shader.
#define assert(condition, color) { if(!any(condition)) { OUT_FragColor0 = color; return; } }
#define assert(condition, color) { if(!any(condition)) { OUT_col = color; return; } }
#endif // _TORQUE_GLSL_

View file

@ -33,6 +33,8 @@ in vec4 outLightVec;
in vec3 outPos;
in vec3 outEyePos;
out vec4 OUT_col;
void main()
{
vec2 texOffset;
@ -45,11 +47,11 @@ void main()
vec4 bumpNorm = texture(bumpMap, texOffset) * 2.0 - 1.0;
vec4 diffuse = texture(diffMap, texOffset);
OUT_FragColor0 = diffuse * (clamp(dot(outLightVec.xyz, bumpNorm.xyz), 0.0, 1.0) + ambient);
OUT_col = diffuse * (clamp(dot(outLightVec.xyz, bumpNorm.xyz), 0.0, 1.0) + ambient);
vec3 eyeVec = normalize(outEyePos - outPos);
vec3 halfAng = normalize(eyeVec + outLightVec.xyz);
float specular = clamp(dot(bumpNorm.xyz, halfAng), 0.0, 1.0) * outLightVec.w;
specular = pow(specular, specularPower);
OUT_FragColor0 += specularColor * specular;
OUT_col += specularColor * specular;
}