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

@ -34,6 +34,8 @@ uniform sampler2D causticsTex0;
uniform sampler2D causticsTex1;
uniform vec2 targetSize;
out vec4 OUT_col;
float distanceToPlane(vec4 plane, vec3 pos)
{
return (plane.x * pos.x + plane.y * pos.y + plane.z * pos.z) + plane.w;
@ -48,7 +50,7 @@ void main()
float depth = prePass.w;
if(depth > 0.9999)
{
OUT_FragColor0 = vec4(0,0,0,0);
OUT_col = vec4(0,0,0,0);
return;
}
@ -59,7 +61,7 @@ void main()
float waterDepth = -distanceToPlane(waterFogPlane, pos);
if(waterDepth < 0)
{
OUT_FragColor0 = vec4(0,0,0,0);
OUT_col = vec4(0,0,0,0);
return;
}
waterDepth = saturate(waterDepth);
@ -81,5 +83,5 @@ void main()
//float waterDepth = 1 - saturate(pos.z + waterFogPlane.w + 1);
caustics *= saturate(prePass.z) * pow(1-depth, 64) * waterDepth;
OUT_FragColor0 = caustics;
OUT_col = caustics;
}

View file

@ -27,6 +27,8 @@
uniform sampler2D shrunkSampler; // Output of DofDownsample()
uniform sampler2D blurredSampler; // Blurred version of the shrunk sampler
out vec4 OUT_col;
// This is the pixel shader function that calculates the actual
// value used for the near circle of confusion.
// "texCoords" are 0 at the bottom left pixel and 1 at the top right.
@ -46,8 +48,8 @@ void main()
coc = 2 * max( blurred.a, shrunk.a ) - shrunk.a;
//OUT_FragColor0 = vec4( coc.rrr, 1.0 );
//OUT_FragColor0 = vec4( color, 1.0 );
OUT_FragColor0 = vec4( color, coc );
//OUT_FragColor0 = vec4( 1.0, 0.0, 1.0, 1.0 );
//OUT_col = vec4( coc.rrr, 1.0 );
//OUT_col = vec4( color, 1.0 );
OUT_col = vec4( color, coc );
//OUT_col = vec4( 1.0, 0.0, 1.0, 1.0 );
}

View file

@ -47,6 +47,8 @@ in vec2 tcDepth2;
in vec2 tcDepth3;
#define IN_tcDepth3 tcDepth3
out vec4 OUT_col;
void main()
{
//return vec4( 1.0, 0.0, 1.0, 1.0 );
@ -131,8 +133,8 @@ void main()
maxCoc = max( max( coc[0], coc[1] ), max( coc[2], coc[3] ) );
//OUT_FragColor0 = half4( 1.0, 0.0, 1.0, 1.0 );
OUT_FragColor0 = half4( color, maxCoc );
//OUT_FragColor0 = half4( color, 1.0f );
//OUT_FragColor0 = half4( maxCoc.rrr, 1.0 );
//OUT_col = half4( 1.0, 0.0, 1.0, 1.0 );
OUT_col = half4( color, maxCoc );
//OUT_col = half4( color, 1.0f );
//OUT_col = half4( maxCoc.rrr, 1.0 );
}

View file

@ -41,6 +41,8 @@ uniform float maxFarCoC;
//static vec4 dofLerpBias = vec4( 1.0, (1.0 - d2) / d1, 1.0 / d2, (d2 - 1.0) / d2 );
//static vec3 dofEqFar = vec3( 2.0, 0.0, 1.0 );
out vec4 OUT_col;
vec4 tex2Doffset( sampler2D s, vec2 tc, vec2 offset )
{
return texture( s, tc + offset * oneOverTargetSize );
@ -141,5 +143,5 @@ void main()
//return half4(nearCoc.rrr,1);
//return half4( 1,0,1,0 );
OUT_FragColor0 = InterpolateDof( small, med.rgb, large, coc );
OUT_col = InterpolateDof( small, med.rgb, large, coc );
}

View file

@ -42,7 +42,7 @@ in vec2 uv6;
in vec2 uv7;
#define IN_uv7 uv7
#define OUT OUT_FragColor0
out vec4 OUT_col;
uniform sampler2D diffuseMap;
@ -50,19 +50,19 @@ void main()
{
vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * 0.5 / 1.3; //25f;
OUT = vec4(0);
OUT += texture( diffuseMap, IN_uv0 ) * kernel.x;
OUT += texture( diffuseMap, IN_uv1 ) * kernel.y;
OUT += texture( diffuseMap, IN_uv2 ) * kernel.z;
OUT += texture( diffuseMap, IN_uv3 ) * kernel.w;
OUT_col = vec4(0);
OUT_col += texture( diffuseMap, IN_uv0 ) * kernel.x;
OUT_col += texture( diffuseMap, IN_uv1 ) * kernel.y;
OUT_col += texture( diffuseMap, IN_uv2 ) * kernel.z;
OUT_col += texture( diffuseMap, IN_uv3 ) * kernel.w;
OUT += texture( diffuseMap, IN_uv4 ) * kernel.x;
OUT += texture( diffuseMap, IN_uv5 ) * kernel.y;
OUT += texture( diffuseMap, IN_uv6 ) * kernel.z;
OUT += texture( diffuseMap, IN_uv7 ) * kernel.w;
OUT_col += texture( diffuseMap, IN_uv4 ) * kernel.x;
OUT_col += texture( diffuseMap, IN_uv5 ) * kernel.y;
OUT_col += texture( diffuseMap, IN_uv6 ) * kernel.z;
OUT_col += texture( diffuseMap, IN_uv7 ) * kernel.w;
// Calculate a lumenance value in the alpha so we
// can use alpha test to save fillrate.
//vec3 rgb2lum = vec3( 0.30, 0.59, 0.11 );
//OUT.a = dot( OUT.rgb, rgb2lum );
//OUT_col.a = dot( OUT_col.rgb, rgb2lum );
}

View file

@ -32,6 +32,8 @@ uniform sampler2D colorSampler; // Output of DofNearCoc()
in vec4 texCoords;
#define IN_texCoords texCoords
out vec4 OUT_col;
void main()
{
vec4 color;
@ -40,5 +42,5 @@ void main()
color += texture( colorSampler, IN_texCoords.yz );
color += texture( colorSampler, IN_texCoords.xw );
color += texture( colorSampler, IN_texCoords.yw );
OUT_FragColor0 = color / 4.0;
OUT_col = color / 4.0;
}

View file

@ -28,7 +28,9 @@ in vec2 uv0;
uniform sampler2D edgeBuffer;
out vec4 OUT_col;
void main()
{
OUT_FragColor0 = vec4( texture( edgeBuffer, IN_uv0 ).rrr, 1.0 );
OUT_col = vec4( texture( edgeBuffer, IN_uv0 ).rrr, 1.0 );
}

View file

@ -28,6 +28,8 @@ uniform sampler2D edgeBuffer;
uniform sampler2D backBuffer;
uniform vec2 targetSize;
out vec4 OUT_col;
void main()
{
vec2 pixelSize = 1.0 / targetSize;
@ -64,5 +66,5 @@ void main()
}
accumColor /= 9.0;
OUT_FragColor0 = accumColor;
OUT_col = accumColor;
}

View file

@ -88,7 +88,9 @@ in vec2 uv0;
uniform sampler2D prepassBuffer;
uniform vec2 targetSize;
out vec4 OUT_col;
void main()
{
OUT_FragColor0 = vec4( GetEdgeWeight(IN_uv0, prepassBuffer, targetSize ) );//rtWidthHeightInvWidthNegHeight.zw);
OUT_col = vec4( GetEdgeWeight(IN_uv0, prepassBuffer, targetSize ) );//rtWidthHeightInvWidthNegHeight.zw);
}

View file

@ -34,9 +34,11 @@ uniform vec2 oneOverTargetSize;
in vec4 hpos;
in vec2 uv0;
out vec4 OUT_col;
void main()
{
OUT_FragColor0 = FxaaPixelShader(
OUT_col = FxaaPixelShader(
uv0, // vertex position

View file

@ -32,6 +32,8 @@ uniform float distCoeff;
uniform float cubeDistort;
uniform vec3 colorDistort;
out vec4 OUT_col;
void main()
{
vec2 tex = IN_uv0;
@ -56,5 +58,5 @@ void main()
outColor[i] = tex2Dlod( backBuffer, vec4(x,y,0,0) )[i];
}
OUT_FragColor0 = vec4( outColor.rgb, 1 );
OUT_col = vec4( outColor.rgb, 1 );
}

View file

@ -28,10 +28,12 @@ uniform float damageFlash;
uniform float whiteOut;
uniform sampler2D backBuffer;
out vec4 OUT_col;
void main()
{
vec4 color1 = texture(backBuffer, IN_uv0);
vec4 color2 = color1 * MUL_COLOR;
vec4 damage = mix(color1,color2,damageFlash);
OUT_FragColor0 = mix(damage,WHITE_COLOR,whiteOut);
OUT_col = mix(damage,WHITE_COLOR,whiteOut);
}

View file

@ -34,6 +34,8 @@ uniform vec4 rtParams0;
in vec2 uv0;
in vec3 wsEyeRay;
out vec4 OUT_col;
void main()
{
//vec2 prepassCoord = ( uv0.xy * rtParams0.zw ) + rtParams0.xy;
@ -46,5 +48,5 @@ void main()
fogData.y,
fogData.z );
OUT_FragColor0 = hdrEncode( vec4( fogColor.rgb, 1.0 - saturate( factor ) ) );
OUT_col = hdrEncode( vec4( fogColor.rgb, 1.0 - saturate( factor ) ) );
}

View file

@ -31,6 +31,8 @@ uniform float OneOverGamma;
in vec2 uv0;
out vec4 OUT_col;
void main()
{
vec4 color = texture(backBuffer, uv0.xy);
@ -43,5 +45,5 @@ void main()
// Apply gamma correction
color.rgb = pow( abs(color.rgb), vec3(OneOverGamma) );
OUT_FragColor0 = color;
OUT_col = color;
}

View file

@ -34,25 +34,26 @@ in vec2 uv5; //TEXCOORD5;
in vec2 uv6; //TEXCOORD6;
in vec2 uv7; //TEXCOORD7;
out vec4 OUT_col;
void main()
{
vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * 0.5f;
vec4 OUT = vec4(0);
OUT += texture( diffuseMap, uv0 ) * kernel.x;
OUT += texture( diffuseMap, uv1 ) * kernel.y;
OUT += texture( diffuseMap, uv2 ) * kernel.z;
OUT += texture( diffuseMap, uv3 ) * kernel.w;
vec4 OUT_col = vec4(0);
OUT_col += texture( diffuseMap, uv0 ) * kernel.x;
OUT_col += texture( diffuseMap, uv1 ) * kernel.y;
OUT_col += texture( diffuseMap, uv2 ) * kernel.z;
OUT_col += texture( diffuseMap, uv3 ) * kernel.w;
OUT += texture( diffuseMap, uv4 ) * kernel.x;
OUT += texture( diffuseMap, uv5 ) * kernel.y;
OUT += texture( diffuseMap, uv6 ) * kernel.z;
OUT += texture( diffuseMap, uv7 ) * kernel.w;
OUT_col += texture( diffuseMap, uv4 ) * kernel.x;
OUT_col += texture( diffuseMap, uv5 ) * kernel.y;
OUT_col += texture( diffuseMap, uv6 ) * kernel.z;
OUT_col += texture( diffuseMap, uv7 ) * kernel.w;
// Calculate a lumenance value in the alpha so we
// can use alpha test to save fillrate.
vec3 rgb2lum = vec3( 0.30, 0.59, 0.11 );
OUT.a = dot( OUT.rgb, rgb2lum );
OUT_col.a = dot( OUT_col.rgb, rgb2lum );
OUT_FragColor0 = OUT;
}

View file

@ -37,6 +37,8 @@ uniform float velocityMultiplier;
uniform sampler2D backBuffer;
uniform sampler2D prepassTex;
out vec4 OUT_col;
void main()
{
vec2 IN_uv0 = _IN_uv0;
@ -72,5 +74,5 @@ void main()
color += currentColor;
}
OUT_FragColor0 = color / samples;
OUT_col = color / samples;
}

View file

@ -25,7 +25,9 @@
in vec2 uv0;
uniform sampler2D inputTex ;
out vec4 OUT_col;
void main()
{
OUT_FragColor0 = texture( inputTex, uv0 );
OUT_col = texture( inputTex, uv0 );
}

View file

@ -34,6 +34,8 @@ in vec2 uv0;
#define IN_uv0 uv0
out vec4 OUT_col;
void main()
{
float speed = 2.0;
@ -46,5 +48,5 @@ void main()
y = clamp(y, targetViewport.y, targetViewport.w);
x = clamp(x, targetViewport.x, targetViewport.z);
OUT_FragColor0 = texture (inputTex, vec2(x, y));
OUT_col = texture (inputTex, vec2(x, y));
}

View file

@ -51,6 +51,8 @@ uniform vec2 nearFar;
uniform vec4 rtParams0;
uniform float waterDepthGradMax;
out vec4 OUT_col;
void main()
{
//vec2 prepassCoord = IN_uv0;
@ -134,5 +136,5 @@ void main()
vec3 outColor = mix( inColor, fogColor.rgb, fogAmt );
OUT_FragColor0 = vec4( hdrEncode( outColor ), 1 );
OUT_col = vec4( hdrEncode( outColor ), 1 );
}

View file

@ -30,6 +30,8 @@ uniform float gaussMultiplier;
uniform float gaussMean;
uniform float gaussStdDev;
out vec4 OUT_col;
#define PI 3.141592654
float computeGaussianValue( float x, float mean, float std_deviation )
@ -66,5 +68,5 @@ void main()
color += (texture( inputTex, IN_uv0 + vec2( offset, 0.0f ) ) * weight );
}
OUT_FragColor0 = vec4( color.rgb, 1.0f );
OUT_col = vec4( color.rgb, 1.0f );
}

View file

@ -30,6 +30,8 @@ uniform float gaussMultiplier;
uniform float gaussMean;
uniform float gaussStdDev;
out vec4 OUT_col;
#define D3DX_PI 3.141592654
float computeGaussianValue( float x, float mean, float std_deviation )
@ -65,5 +67,5 @@ void main()
color += (texture( inputTex, IN_uv0 + vec2( 0.0f, offset ) ) * weight );
}
OUT_FragColor0 = vec4( color.rgb, 1.0f );
OUT_col = vec4( color.rgb, 1.0f );
}

View file

@ -33,6 +33,8 @@ uniform float g_fMiddleGray;
const vec3 LUMINANCE_VECTOR = vec3(0.3125f, 0.6154f, 0.0721f);
out vec4 OUT_col;
const vec2 gTapOffsets[4] = vec2[]
(
@ -59,5 +61,5 @@ void main()
average = vec4( 0.0f, 0.0f, 0.0f, 1.0f );
// Write the colour to the bright-pass render target
OUT_FragColor0 = hdrEncode( average );
OUT_col = hdrEncode( average );
}

View file

@ -30,6 +30,8 @@ uniform sampler2D lastAdaptedLum;
uniform float adaptRate;
uniform float deltaTime;
out vec4 OUT_col;
void main()
{
float fAdaptedLum = texture( lastAdaptedLum, vec2(0.5f, 0.5f) ).r;
@ -42,5 +44,5 @@ void main()
float diff = fCurrentLum - fAdaptedLum;
float fNewAdaptation = fAdaptedLum + ( diff * ( 1.0 - exp( -deltaTime * adaptRate ) ) );
OUT_FragColor0 = vec4( fNewAdaptation, 0.0, 0.0, 1.0f );
OUT_col = vec4( fNewAdaptation, 0.0, 0.0, 1.0f );
}

View file

@ -30,6 +30,8 @@ in vec4 texCoords[8];
uniform sampler2D inputTex;
out vec4 OUT_col;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
@ -44,5 +46,5 @@ void main()
_sample += texture( inputTex, IN_texCoords[i].zw );
}
OUT_FragColor0 = _sample / 16;
OUT_col = _sample / 16;
}

View file

@ -43,6 +43,8 @@ uniform float g_fBloomScale;
uniform float g_fOneOverGamma;
out vec4 OUT_col;
void main()
{
@ -92,5 +94,5 @@ void main()
// Apply gamma correction
_sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) );
OUT_FragColor0 = _sample;
OUT_col = _sample;
}

View file

@ -28,6 +28,8 @@
uniform sampler2D inputTex;
uniform float brightPassThreshold;
out vec4 OUT_col;
void main()
{
vec4 _sample = hdrDecode( texture( inputTex, IN_uv0 ) );
@ -36,5 +38,5 @@ void main()
float lum = hdrLuminance( _sample.rgb );
// Write the colour to the bright-pass render target
OUT_FragColor0 = ( vec4( lum.rrr, 1 ) );
OUT_col = ( vec4( lum.rrr, 1 ) );
}

View file

@ -29,6 +29,8 @@ uniform vec2 texSize0;
uniform float g_fMinLuminace;
out vec4 OUT_col;
const vec2 gTapOffsets[9] = vec2[]
(
vec2( -1.0, -1.0 ), vec2( 0.0, -1.0 ), vec2( 1.0, -1.0 ),
@ -56,5 +58,5 @@ void main()
average = exp( average / 9.0 );
OUT_FragColor0 = vec4( average, 0.0, 0.0, 1.0 );
OUT_col = vec4( average, 0.0, 0.0, 1.0 );
}

View file

@ -26,6 +26,7 @@
uniform sampler2D inputTex;
uniform vec2 oneOverTargetSize;
out vec4 OUT_col;
const vec2 gTapOffsets[16] = vec2[]
(
@ -47,5 +48,5 @@ void main()
average += lum;
}
OUT_FragColor0 = vec4( average / 16.0, 0.0, 0.0, 1.0 );
OUT_col = vec4( average / 16.0, 0.0, 0.0, 1.0 );
}

View file

@ -31,6 +31,7 @@ uniform float brightScalar;
const vec3 LUMINANCE_VECTOR = vec3(0.3125f, 0.6154f, 0.0721f);
out vec4 OUT_col;
void main()
{
@ -50,5 +51,5 @@ void main()
col *= brightScalar;
}
OUT_FragColor0 = col;
OUT_col = col;
}

View file

@ -36,6 +36,8 @@ uniform float weight;
uniform float decay;
uniform float exposure;
out vec4 OUT_col;
void main()
{
vec4 texCoord = vec4( IN_uv0.xy, 0, 0 );
@ -55,7 +57,7 @@ void main()
if ( samples <= 0 )
{
OUT_FragColor0 = bbCol;
OUT_col = bbCol;
return;
}
@ -88,5 +90,5 @@ void main()
//return bbCol * decay;
// Output final color with a further scale control factor.
OUT_FragColor0 = saturate( amount ) * vec4( color * exposure, 1 ) + bbCol;
OUT_col = saturate( amount ) * vec4( color * exposure, 1 ) + bbCol;
}

View file

@ -34,6 +34,8 @@ uniform sampler2D edgesMap;
uniform sampler2D edgesMapL;
uniform sampler2D areaMap;
out vec4 OUT_col;
#include "./functions.glsl"
@ -77,5 +79,5 @@ void main()
areas.ba = Area(abs(d), e1, e2);
}
OUT_FragColor0 = areas;
OUT_col = areas;
}

View file

@ -39,6 +39,8 @@ uniform float depthThreshold;
in vec2 texcoord;
in vec4 offset[2];
out vec4 OUT_col;
void main()
{
// Luma calculation requires gamma-corrected colors (texture 'colorMapG').
@ -70,5 +72,5 @@ void main()
if (dot(edges, vec4(1.0)) == 0.0)
discard;
OUT_FragColor0 = edges;
OUT_col = edges;
}

View file

@ -40,6 +40,7 @@ uniform sampler2D areaMap;
uniform sampler2D edgesMapL;
#include "./functions.glsl"
out vec4 OUT_col;
void main()
{
@ -83,5 +84,5 @@ void main()
#endif
// Normalize the resulting color and we are finished!
OUT_FragColor0 = color / sum;
OUT_col = color / sum;
}

View file

@ -46,6 +46,7 @@ uniform sampler2D prepassMap ;
uniform float blurDepthTol;
uniform float blurNormalTol;
out vec4 OUT_col;
void _sample( vec2 uv, float weight, vec4 centerTap, inout int usedCount, inout float occlusion, inout float total )
{
@ -96,7 +97,7 @@ void main()
//occlusion /= (float)usedCount / 8.0;
occlusion /= total;
OUT_FragColor0 = vec4( vec3(occlusion), 1 );
OUT_col = vec4( vec3(occlusion), 1 );
//return vec4( 0,0,0,occlusion );

View file

@ -57,6 +57,8 @@ uniform float lDepthPow;
uniform float lNormalTol;
uniform float lNormalPow;
out vec4 OUT_col;
#ifndef QUALITY
#define QUALITY 2
@ -152,7 +154,7 @@ void main()
// Early out if too far away.
if ( depth > 0.99999999 )
{
OUT_FragColor0 = vec4( 0,0,0,0 );
OUT_col = vec4( 0,0,0,0 );
return;
}
@ -270,7 +272,7 @@ void main()
// seems backwards, but it makes it simple to deal with the SSAO
// being disabled in the lighting shaders.
OUT_FragColor0 = vec4(occlusion, vec3(0.0));
OUT_col = vec4(occlusion, vec3(0.0));
}

View file

@ -25,8 +25,10 @@
in vec2 uv0;
#define IN_uv0 uv0
out vec4 OUT_col;
void main()
{
float power = pow( max( IN_uv0.x, 0 ), 0.1 );
OUT_FragColor0 = vec4( power, 0, 0, 1 );
OUT_col = vec4( power, 0, 0, 1 );
}