void main(void) { vec4 origColor = texture2D(otex, gl_TexCoord[0].st); vec4 raysColor = texture2D(rtex, gl_TexCoord[0].st); if (lightDirDOTviewDir>0.0){ float exposure = 0.1/float(NUM_SAMPLES); float decay = 1.0 ; float density = 0.5; float weight = 6.0; float illuminationDecay = 1.0; vec2 deltaTextCoord = vec2( gl_TexCoord[0].st - lightPositionOnScreen); vec2 textCoo = gl_TexCoord[0].st; deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density; for(int i=0; i < NUM_SAMPLES ; i++) { textCoo -= deltaTextCoord; vec4 tsample = texture2D(rtex, textCoo ); tsample *= illuminationDecay * weight; raysColor += tsample; illuminationDecay *= decay; } raysColor *= exposure * lightDirDOTviewDir; float p = 0.3 *raysColor.g + 0.59*raysColor.r + 0.11*raysColor.b; gl_FragColor = origColor + p; } else { gl_FragColor = origColor; } }
void main() { vec4 heightRT = texture2D( u_Texture0, v_TexCoords ); vec4 normRT = texture2D( u_Texture1, v_TexCoords ); vec3 baseNorm = (normRT.rgb-0.5)*2.0; baseNorm.z = 0.0; baseNorm = normalize(baseNorm); vec3 faceNorm = vec3(0.0,0.0,1.0); float curDis = heightRT.b; float maxDis = 128.0/255.0; float startZ = 0.0; float endZ = 1.0; float lerpPow = 2.0; float lerpAmount = max(maxDis-curDis,0.0)/maxDis; /* // sharp bevel lerpAmount = 0.5; if (curDis >= 80.0/255.0) { lerpAmount = 0.0; }*/ if (curDis <= 16.0/255.0) { lerpAmount = 1.0; } vec3 finalNorm = mix(faceNorm, baseNorm, lerpAmount ); finalNorm = normalize(finalNorm); float alphaVal = heightRT.g; if (alphaVal == 0.0) { discard; } vec4 gIdRGBA; float groupId = v_Data0.z; gIdRGBA.rg = pack16(groupId); //gIdRGBA.r = floor(groupId/256.0)/255.0; //gIdRGBA.g = mod(groupId,256.0)/255.0; float matId = v_Data0.w; gIdRGBA.ba = pack16(matId); //gIdRGBA.b = floor(matId/256.0)/255.0; //gIdRGBA.a = mod(matId,256.0)/255.0; gl_FragColor = gIdRGBA; }
void main() { // pages vec4 tex0 = texture2D(Texture0, TexCoord0 ); vec4 tex1 = texture2D(Texture1, TexCoord0 ); // geom vec4 tex2 = texture2D(Texture2, TexCoord0 ); vec4 tex3 = texture2D(Texture3, TexCoord0 ); float bh1 = unpack16(tex0.rg); float bh2 = unpack16(tex2.rg); vec4 res0 = vec4(0.0); vec4 res1 = vec4(0.0); if (bh2 > bh1) { res0 = tex2; res1 = tex3; } else { res0 = tex0; res1 = tex1; } gl_FragData[0] = res0; gl_FragData[1] = res1; }
void main()\n\ {\n\ vec4 diffuse = texture2D(texture1, st);\n\ vec4 position = texture2D(texture2, st);\n\ vec4 normal = texture2D(texture3, st);\n\ vec3 light = vec3(50,100,50);\n\ vec3 lightDir = light - position.xyz ;\n\ \n\ float blurSize_x = 1.0/100.0;\n\ float blurSize_y = 1.0/80.0;\n\ \n\ vec4 sum = vec4(0);\n\ vec2 size = vec2(800,600);\n\ int samples = 20; \n\ float quality =4.0; \n\ int diff = (samples - 1) / 2;\n\ vec2 sizeFactor = vec2(1) / size * quality;\n\ \n\ for (int x = -diff; x <= diff; x++)\n\ {\n\ for (int y = -diff; y <= diff; y++)\n\ {\n\ vec2 coordinate = st + vec2(x, y) * sizeFactor;\n\ coordinate.x = clamp(coordinate.x, 0.0, 1.0);\n\ coordinate.y = clamp(coordinate.y, 0.0, 1.0);\n\ sum += texture2D(texture4, coordinate);\n\ }\n\ }\n\ sum = sum / (samples*samples);\n\ \n\ diffuse = diffuse*(1.0 - sum.a);\n\ finalColor = diffuse+sum;\n\ }";
void main () { vec4 texel = texture2D(sampler, gl_FragCoord.xy / resolution); vec2 coords = vec2(gl_FragCoord.x, (resolution.y - gl_FragCoord.y)) / resolution; if( (coords.x >= clip.s && coords.y >= clip.t) && (coords.x <= clip.p && coords.y <= clip.q) ) { vec4 clap = clip; clap.tq -= offset.y / count.t; vec2 coords = (coords - clap.st) / (clap.pq - clap.st); vec4 glyph = texture2D(text, vec2( coords.x, (coords.y * ( count.t / count.p)) )); texel = texture2D(glyphs, vec2( ( glyph.p - glyph.s ) * fract( (coords.x + offset.x) * count.s ) + glyph.s, ( glyph.q - glyph.t ) * fract( coords.y * count.t ) + glyph.t )); gl_FragColor = vec4(1., 1., 1., texel.a); } else gl_FragColor = texture2D(texture, gl_FragCoord.xy / resolution); }
const char *fragmentShader() const { return QT_STRINGIFY( const int numberOfLights = 5; varying mediump vec2 qt_TexCoord0; varying mediump vec3 lightVecTangent[numberOfLights]; uniform mediump float qt_Opacity; uniform mediump float lightIntensities[numberOfLights]; uniform sampler2D sourceImage; uniform sampler2D normalsImage; void main(void) { mediump vec2 pixPos = qt_TexCoord0; mediump vec4 pix = texture2D(sourceImage, pixPos.st); mediump vec4 pix2 = texture2D(normalsImage, pixPos.st); mediump vec3 normal = vec3(pix2.rg * 2.0 - 1.0, pix2.b); mediump float diffuse = 0.66; // Unroll the loop, my HD3000 doesn't like non-const array lookups. mediump vec3 relVec; relVec = normalize(lightVecTangent[0]); diffuse += lightIntensities[0] * 0.4 * dot(normal, relVec); relVec = normalize(lightVecTangent[1]); diffuse += lightIntensities[1] * 0.4 * dot(normal, relVec); relVec = normalize(lightVecTangent[2]); diffuse += lightIntensities[2] * 0.4 * dot(normal, relVec); relVec = normalize(lightVecTangent[3]); diffuse += lightIntensities[3] * 0.4 * dot(normal, relVec); relVec = normalize(lightVecTangent[4]); diffuse += lightIntensities[4] * 0.4 * dot(normal, relVec); diffuse = clamp(diffuse, 0.0, 1.0); mediump vec4 color = vec4(diffuse * pix.rgb, pix.a); gl_FragColor = color * qt_Opacity; }
string GaussianBlurFilter::_getFragSrc() { return GLSL_STRING(120, uniform sampler2D texture0; uniform float blurSize; uniform float bloom; uniform float texelWidthOffset; uniform float texelHeightOffset; void main() { float v; float pi = 3.141592653589793; float radius = blurSize; if ( radius < 0 ) radius = 0; int steps = int(min(radius * 0.7, sqrt(radius) * pi)); float r = radius / steps; float t = bloom / (steps * 2 + 1); float x = gl_TexCoord[0].x; float y = gl_TexCoord[0].y; vec4 sum = texture2D(texture0, vec2(x, y)) * t; int i; for(i = 1; i <= steps; i++){ v = (cos(i / (steps + 1) / pi) + 1) * 0.5; sum += texture2D(texture0, vec2(x + i * texelWidthOffset * r, y + i * texelHeightOffset * r)) * v * t; sum += texture2D(texture0, vec2(x - i * texelWidthOffset * r, y - i * texelHeightOffset * r)) * v * t; } gl_FragColor = sum; }
void main(void){ float dxtex = 1.0 / textureSizeX; float dytex = 1.0 / textureSizeY; vec2 st = gl_TexCoord[0].st; // access center pixel and 4 surrounded pixel vec3 center = getNormal(st).rgb; vec3 left = getNormal(st + vec2(dxtex, 0.0)).rgb; vec3 right = getNormal(st + vec2(-dxtex, 0.0)).rgb; vec3 up = getNormal(st + vec2(0.0, -dytex)).rgb; vec3 down = getNormal(st + vec2(0.0, dytex)).rgb; // discrete Laplace operator vec3 laplace = abs(-4.0*center + left + right + up + down); // if one rgb-component of convolution result is over threshold => edge vec4 line = texture2D(normalImage, st); if(laplace.r > normalEdgeThreshold || laplace.g > normalEdgeThreshold || laplace.b > normalEdgeThreshold){ line = vec4(0.0, 0.0, 0.0, 1.0); // => color the pixel green } else { line = vec4(1.0, 1.0, 1.0, 1.0); // black } //end Line; //start Phong //vec3 lightPosition = vec3(100.0, 100.0, 50.0); vec3 lightPosition = gl_LightSource[0].position.xyz; vec3 L = normalize(lightPosition - v); vec3 E = normalize(-v); vec3 R = normalize(-reflect(L,N)); // ambient term vec4 Iamb = ambient; // diffuse term vec4 Idiff = texture2D( normalImage, gl_TexCoord[0].st) * diffuse; //vec4 Idiff = vec4(1.0, 1.0, 1.0, 1.0) * diffuse; Idiff *= max(dot(N,L), 0.0); Idiff = clamp(Idiff, 0.0, 1.0); // specular term vec4 Ispec = specular; Ispec *= pow(max(dot(R,E),0.0), shinyness); Ispec = clamp(Ispec, 0.0, 1.0); vec4 color = Iamb + Idiff; if ( bSpecular == 1 ) color += Ispec; // store previous alpha value float alpha = color.a; // quantize process: multiply by factor, round and divde by factor color = floor(0.5 + (qLevel * color)) / qLevel; // set fragment/pixel color color.a = alpha; gl_FragColor = color * line; }
void main(void)\ {\ vec4 shared=texture2D(TexUnit2, vec2(gl_TexCoord[2]));\ vec4 pantalla=texture2D(TexUnit0, vec2(gl_TexCoord[0]));\ vec4 blur=texture2D(TexUnit1, vec2(gl_TexCoord[1]))*producto*shared.rrrr;\ gl_FragColor = pantalla*blur*addormultiply + ((pantalla+blur)*(1.0-addormultiply));\ }";
void main (void) { vec4 texcolor=gl_Color; vec4 finalcolor; float fShadowFactor=1.0; float specfactor=1.0; #ifdef ENABLE_TEXTURES #ifdef ENABLE_WATER ApplyWaterEffect(Texture0,gl_TexCoord[0].xy,texcolor.xyz); #else texcolor*= texture2D(Texture0, gl_TexCoord[0].xy); #endif #if TEXTURE_UNITS > 1 #ifdef ENABLE_WATER vec3 temptexunit1; ApplyWaterEffect(Texture1,gl_TexCoord[1].xy,temptexunit1); texcolor.rgb*=temptexunit1; #else texcolor*= texture2D(Texture1, gl_TexCoord[1].xy); #endif #endif #endif #ifdef ENABLE_SHADOWS fShadowFactor=shadow2DProj(ShadowMap, gl_TexCoord[SHADOW_TEXTURE_LEVEL]).r; #ifdef ENABLE_SOFT_SHADOWS float offset=3.0; fShadowFactor+=shadow2DProj(ShadowMap,gl_TexCoord[SHADOW_TEXTURE_LEVEL]+vec4(-offset,-offset,0,0)).g; fShadowFactor+=shadow2DProj(ShadowMap,gl_TexCoord[SHADOW_TEXTURE_LEVEL]+vec4(offset,-offset,0,0)).g; fShadowFactor+=shadow2DProj(ShadowMap,gl_TexCoord[SHADOW_TEXTURE_LEVEL]+vec4(-offset,offset,0,0)).g; fShadowFactor+=shadow2DProj(ShadowMap,gl_TexCoord[SHADOW_TEXTURE_LEVEL]+vec4(offset,offset,0,0)).g; fShadowFactor/=5.0; #endif #endif #ifdef ENABLE_LIGHTING vec4 sunambdiffspec=g_sunambdiffspec; #ifdef ENABLE_SKY_SHADOW sunambdiffspec*=1.0-(texture2D(SkyShadowMap, gl_TexCoord[SKY_TEXTURE_LEVEL].xy)*SkyData.a); #endif finalcolor.rgb=clamp(g_ambdiffspec.rgb+sunambdiffspec.rgb*fShadowFactor,0.0,LIGHTING_SATURATION); finalcolor.rgb*=texcolor.rgb; finalcolor.a=texcolor.a; #else #ifdef ENABLE_SKY_SHADOW fShadowFactor*=1.0-(texture2D(SkyShadowMap, gl_TexCoord[SKY_TEXTURE_LEVEL].xy)*SkyData.a).r; #endif finalcolor=texcolor*fShadowFactor; #endif #ifdef ENABLE_FOG finalcolor= vec4(clamp(finalcolor.rgb, 0.0, 1.0),finalcolor.a); finalcolor.rgb=mix(finalcolor.rgb,gl_Fog.color.rgb,g_fFogFactor); #endif gl_FragColor=finalcolor; }
// Derivative maps - bump mapping unparametrized surfaces by Morten Mikkelsen // http://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html // Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2) vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float hll = bumpScale * texture2D( tDisplacement, vUv ).x; float dBx = bumpScale * texture2D( tDisplacement, vUv + dSTdx ).x - hll; float dBy = bumpScale * texture2D( tDisplacement, vUv + dSTdy ).x - hll; return vec2( dBx, dBy ); }
void main() { vec4 redColor = texture2D(texture, fragmentTextureCoordinate.xy - redOffset + vec2(0.5,0.5)); vec4 greenColor = texture2D(texture, fragmentTextureCoordinate.xy - greenOffset + vec2(0.5,0.5)); vec4 blueColor = texture2D(texture, fragmentTextureCoordinate.xy - blueOffset + vec2(0.5,0.5)); gl_FragColor = vec4(redColor.r, greenColor.g, blueColor.b, (redColor.a + greenColor.a + blueColor.a)/3.); }
void main(void) { float toneFactor = 1.0;///2.0; vec4 mapC = texture2D(uMapKd, vTexCoordinate); vec4 shad = texture2D(uMapShadow, vTexCoordinate)*toneFactor; gl_FragColor = mapC * shad + shad * (shad.w - 1.0)*mapC.w; }
void main(void) { vec4 color = texture2D(texture, fragmentTextureCoordinate.xy); vec4 maskColor = texture2D(mask, fragmentTextureCoordinate.xy); float maskAmount = maskColor.a * rgbToHsl(maskColor.rgb).z; color.rgb *= maskAmount; color.a = maskAmount; gl_FragColor = color; }
void main(void) { vec4 tv4Position = texture2D(uMapPosition, vTexCoordinate); vec4 shadowProj = uShadowMatrix * vec4(tv4Position.xyz, 1.0); shadowProj /= shadowProj.w; if ( abs(shadowProj.x) < 1.0 && abs(shadowProj.y) < 1.0 && abs(shadowProj.z) < 1.0 ) { vec2 shadowSample = vec2( (shadowProj.x+1.0)/2.0, (shadowProj.y+1.0)/2.0 ); float shadowVal = 0.0; float count = 0.0; //float x, y; for (float y = -1.5; y <= 1.5; y += 1.0) { for (float x = -1.5; x <= 1.5; x += 1.0) { vec4 t4Shadow = texture2D(uMapShadow, vec2( shadowSample.x + x/1024.0, shadowSample.y + y/1024.0) ); // assuming a 1024 by 1024 shadow map if ( t4Shadow.x - shadowProj.z > -0.0000 ) { shadowVal += 1.0; } else { float variance = t4Shadow.y - (t4Shadow.x*t4Shadow.x); variance = max(variance,0.0000002); float d = shadowProj.z - t4Shadow.x; float p_max = variance / (variance + d*d); shadowVal += p_max; } count += 1.0; } } shadowVal = shadowVal/count; gl_FragColor = vec4(shadowVal); } else { vec4 pingColor = texture2D( uMapPing, vTexCoordinate); gl_FragColor = pingColor; } }
void main() { vec2 newTC = mod(v_TexCoords*4.0,2.0)/2.0; vec2 newTC2 = v_TexCoords; newTC2.y = 1.0-newTC2.y; vec4 baseval = texture2D( u_Texture0, newTC ); vec4 basevalo = texture2D( u_Texture0, v_TexCoords ); float res; vec4 res2; if (u_Section == 0.0) { if (newTC2.x < 0.5 && newTC2.y < 0.5 ) { res = baseval.r; res2 = vec4(1.0,0.0,0.0,1.0); } if (newTC2.x >= 0.5 && newTC2.y < 0.5 ) { res = baseval.g; res2 = vec4(0.0,1.0,0.0,1.0); } if (newTC2.x < 0.5 && newTC2.y >= 0.5 ) { res = baseval.b; res2 = vec4(0.0,0.0,1.0,1.0); } if (newTC2.x >= 0.5 && newTC2.y >= 0.5 ) { res = baseval.a; res2 = vec4(1.0,1.0,0.0,1.0); } gl_FragColor = mix(vec4(res,res,res,1.0),res2,0.3); } if (u_Section == 1.0) { gl_FragColor = vec4(basevalo.rrr,1.0); } if (u_Section == 2.0) { gl_FragColor = vec4(basevalo.ggg,1.0); } if (u_Section == 3.0) { gl_FragColor = vec4(basevalo.bbb,1.0); } if (u_Section == 4.0) { gl_FragColor = vec4(basevalo.aaa,1.0); } if (u_Section == 5.0) { gl_FragColor = vec4(basevalo.rgb,1.0); } }
void main(){ \n\ \n\ vec2 diff=gl_TexCoord[0].st-origin; \n\ float distSq=dot(diff,diff); \n\ float t=radius*radius*texScaled*texScaled; \n\ if(distSq<t){ \n\ gl_FragColor=vec4(impulseColor*impulseStrength+texture2D(tex,gl_TexCoord[0].st).xyz*(1.0-impulseStrength),1.0); \n\ }else{ \n\ gl_FragColor=vec4(texture2D(tex,gl_TexCoord[0].st).xyz,1.0); \n\ } \n\ } \n\
void main() { vec4 baseval00 = texture2D( u_Texture0, v_TexCoords ); vec4 baseval01 = texture2D( u_Texture0, v_TexCoords+vec2(0.0/u_TexResolution.x,1.0/u_TexResolution.y) ); vec4 baseval10 = texture2D( u_Texture0, v_TexCoords+vec2(1.0/u_TexResolution.x,0.0/u_TexResolution.y) ); vec4 baseval11 = texture2D( u_Texture0, v_TexCoords+vec2(1.0/u_TexResolution.x,1.0/u_TexResolution.y) ); gl_FragColor = (baseval00+baseval01+baseval10+baseval11)/4.0; }
void main() { vec3 pos = texture2D(tPositions, vUv).xyz; vec3 vel = texture2D(tVelocities, vUv).xyz; pos.x += vel.x; pos.y += vel.y; pos.z += vel.z; // Write new position out gl_FragColor = vec4(pos, 1.0); }
void main() { vec4 base = texture2D(background, fragmentTextureCoordinate.xy); vec4 blend = texture2D(foreground, fragmentTextureCoordinate.xy); vec3 result = vec3( mix(base.r, blend.r, blend.a), mix(base.g, blend.g, blend.a), mix(base.b, blend.b, blend.a) ); gl_FragColor = vec4( mix(base.rgb, result, foregroundOpacity), base.a + blend.a * foregroundOpacity); }
void main() { vec4 tex0 = texture2D( Texture0, (TexCoord0.xy + paramArrMap[8].xy) ); vec4 tex1 = texture2D( Texture1, (TexCoord0.xy + paramArrMap[9].xy)*mapSampScale ); vec4 tex2 = texture2D( Texture2, (TexCoord0.xy + paramArrMap[10].xy)*mapSampScale ); float[6] sv; float[6] vals; vals[0] = tex1.r; vals[1] = tex1.g; vals[2] = tex1.b; vals[3] = tex2.r; vals[4] = tex2.g; vals[5] = tex2.b; int i; int j; int curInd = -1; for (i = 0; i < 6; i++) { sv[i] = vals[int(paramArrMap[i].x)]; } float v0 = sv[0]*tex0.r;//*tex0.r; float v1 = sv[1]*tex0.g;//*tex0.g; float v2 = sv[2]*tex0.b;//*tex0.b; //float h = sqrt(v0 + v1 + v2); float h = pow(max(max(v0,v1),v2),0.4); //h *= 2.0; //(v0*v1*v2)*0.75+0.25;// // if (h > 1.0) { // h = 2.0-h; // } h = pow(h,1.5); h = clamp(h, 0.0, 1.0); gl_FragData[0] = vec4(h,0.0,0.0,0.0); }
void main() {\ if (isDepth) {\ float n = clipPlanes.x;\ float f = clipPlanes.y;\ float z = texture2D(texture, texCoord).x;\ z = (2.0 * n) / (f + n - z * (f - n));\ gl_FragColor = vec4(z,z,z,1.0);\ }\ else {\ gl_FragColor = texture2D(texture, texCoord);\ }\ }\0";
void main(void)\n\ {\n\ vec3 yuv;\n\ vec3 rgb;\n\ yuv.x = texture2D(tex_y, vec2(TexCoordOut.x*yborder,TexCoordOut.y)).r;\n\ yuv.y = texture2D(tex_u, vec2(TexCoordOut.x*uborder,TexCoordOut.y)).r - 0.5;\n\ yuv.z = texture2D(tex_v, vec2(TexCoordOut.x*vborder,TexCoordOut.y)).r - 0.5;\n\ rgb = mat3( 1, 1, 1,\n\ 0, -0.39465, 2.03211,\n\ 1.13983, -0.58060, 0) * yuv;\n\ gl_FragColor = vec4(rgb, 1);\n\ }";
void main() \ { \ mediump vec3 yuv; \ lowp vec3 rgb; \ yuv.x = texture2D(u_texture, v_texCoord).r; \ yuv.yz = texture2D(u_texture_u, v_texCoord).ar - 0.5; \ rgb = mat3( 1, 1, 1, \ 0, -0.39465, 2.03211, \ 1.13983, -0.58060, 0) * yuv; \ gl_FragColor = vec4(rgb, 1); \ gl_FragColor *= u_modulation; \ } \
string DisplacementFilter::_getFragSrc() { return GLSL_STRING(120, uniform float texelWidth; uniform float texelHeight; uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; void main() { vec2 uv = gl_TexCoord[0].xy; vec2 offset = texture2D(inputImageTexture2, uv ).xy * vec2(texelWidth, texelHeight); gl_FragColor = texture2D(inputImageTexture, uv + offset.xy); }
void main() \n\ { \n\ if (g_useLighting) \n\ { \n\ float l = length(v_position.xyz - g_light); \n\ float atten = min(2.0, 10.0 / (1.0 + l*1.0 + 0.8*l*l)); \n\ gl_FragColor = texture2D(s_texture, v_texcoord) * atten; \n\ } \n\ else \n\ { \n\ gl_FragColor = texture2D(s_texture, v_texcoord); \n\ } \n\ }";
void main(void) { float toneFactor = 1.0/6.0;///2.0; vec4 mapC = texture2D(uMapKd, vTexCoordinate); vec4 light= texture2D(uMapLight, vTexCoordinate); vec4 shad = texture2D(uMapShadow, vTexCoordinate); vec4 ambient = mapC * shad * 0.2; vec4 lightf = light * toneFactor * shad; gl_FragColor = mapC * lightf + light * (light.w - 1.0)*mapC.w*toneFactor + ambient; }
void main(void)\ {\ if (v[0][1] < 0.5) {\ vec2 n=vec2(fract(sin(dot(z.xy+v[0][0],vec2(12.9898,78.233)))*43758.5453));\ gl_FragColor=texture2D(t,.5*z.xy+.5+.0007*n)+n.x*.02;\ } else {\ vec2 pos = vTexCoord + vec2(-0.000, 0.0);\ gl_FragColor = vec4(0.0);\ for (int i = -0; i <= 0; i++) {\ gl_FragColor += texture2D(t, pos)/1.0;\ pos += vec2(0.000/1.0, 0.0);\ }\ }\ }";
string SobelEdgeDetectionFilter::_getFragSrc() { return GLSL_STRING(120, varying vec2 textureCoordinate; varying vec2 leftTextureCoordinate; varying vec2 rightTextureCoordinate; varying vec2 topTextureCoordinate; varying vec2 topLeftTextureCoordinate; varying vec2 topRightTextureCoordinate; varying vec2 bottomTextureCoordinate; varying vec2 bottomLeftTextureCoordinate; varying vec2 bottomRightTextureCoordinate; uniform sampler2D inputImageTexture; uniform float edgeStrength; void main() { float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r; float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r; float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r; float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r; float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r; float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r; float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r; float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r; float h = -topLeftIntensity - 2.0 * topIntensity - topRightIntensity + bottomLeftIntensity + 2.0 * bottomIntensity + bottomRightIntensity; float v = -bottomLeftIntensity - 2.0 * leftIntensity - topLeftIntensity + bottomRightIntensity + 2.0 * rightIntensity + topRightIntensity; float mag = length(vec2(h, v)) * edgeStrength; gl_FragColor = vec4(vec3(mag), 1.0); }
void main() { vec4 splatRec = texture2D(splat, gl_TexCoord[0].xy); vec3 splatColor = splatRec.rgb/(splatRec.a); vec4 directRec = texture2D(direct, gl_TexCoord[0].xy); //vec4 outCol = 0.75*directRec + vec4(splatColor, 1.0); //gl_FragColor = vec4(outCol.rgb, 1.0); gl_FragColor = vec4(splatColor, 1.0) + .5*directRec; }