Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform sampler2D texture;
- uniform float width;
- uniform float border;
- //third step in the lighting algorithm.
- //reduces the occlusion map to 2 pixels horizontally
- //(each pass halves the texture size horizontally)
- /*the original reduction shader from Zima only used min(pixel, pixelRight), adding the left pixel
- somehow made it work better, i dont know why, should technically be the same thing right? maybe my
- downscaling method is sloppy or theres some mipmapping going on im not aware of, even though i only
- scale down in the x axis, but i spent weeks on this already and just dont care anymore*/
- void main()
- {
- float pixeltopixeldistance = 1.0f / width;
- //odd pixel?
- bool thisrow = fract(gl_TexCoord[0].x * width / 2.0f) < 0.5f;
- vec2 otherpixel = texture2D(texture, gl_TexCoord[0].xy - vec2(pixeltopixeldistance,0)).rg; //color to the right
- vec2 color = texture2D(texture, gl_TexCoord[0].xy);
- vec2 result = vec2(min(color, otherpixel)); //, min(min(color.g, colorL.g) , colorR.g));
- if (!thisrow && !(gl_TexCoord[0].x < 0.5f && gl_TexCoord[0].x + pixeltopixeldistance > 0.5f))
- gl_FragColor = vec4(min(color, otherpixel),0,1);
- }
- /*
- void main()
- {
- float pixeltopixeldistance = 1.0f / width;
- //odd pixel?
- bool thisrow = fract(gl_TexCoord[0].x * width / 2.0f) < 0.5f;
- vec2 pixeloffset = vec2(pixeltopixeldistance,0).rg;
- if(thisrow) pixeloffset *= -1.f;
- vec2 otherpixel = texture2D(texture, clamp(gl_TexCoord[0].xy + pixeloffset, vec2(0.0f, 0.0f), vec2(1.0f,0.0f)));
- vec2 color = texture2D(texture, gl_TexCoord[0].xy);
- vec2 result = min(color, otherpixel); //, min(min(color.g, colorL.g) , colorR.g));
- if (
- !thisrow &&
- !((gl_TexCoord[0].x < border) && (gl_TexCoord[0].x + pixeloffset.x >= border)) &&
- !((gl_TexCoord[0].x > border) && (gl_TexCoord[0].x + pixeloffset.x <= border))
- )
- gl_FragColor = vec4(min(color, otherpixel), 0, 1);
- }
- */
- /*
- void main()
- {
- float pixeltopixeldistance = 1.0f / width;
- //odd pixel?
- bool thisrow = fract(gl_TexCoord[0].x * width / 2.0f) < 0.5f;
- vec2 otherpixel;
- if(!thisrow) otherpixel = texture2D(texture, gl_TexCoord[0].xy - vec2(pixeltopixeldistance,0)).rg; //color to the left
- else otherpixel = texture2D(texture, gl_TexCoord[0].xy + vec2(pixeltopixeldistance,0)).rg; //color to the right
- vec2 color = texture2D(texture, gl_TexCoord[0].xy);
- vec2 result = vec2(min(color, otherpixel)); //, min(min(color.g, colorL.g) , colorR.g));
- gl_FragColor = vec4(min(color, otherpixel),0,1);
- }
- */
- /*
- void main()
- {
- float pixeltopixeldistance = 1.0f / width;
- //odd pixel?
- bool thisrow = fract(gl_TexCoord[0].x * width / 2.0f) < 0.5f;
- vec2 otherpixel = texture2D(texture, gl_TexCoord[0].xy - vec2(pixeltopixeldistance,0)).rg; //color to the right
- vec2 color = texture2D(texture, gl_TexCoord[0].xy);
- vec2 result = vec2(min(color, otherpixel)); //, min(min(color.g, colorL.g) , colorR.g));
- if (!thisrow && !(gl_TexCoord[0].x < 0.5f && gl_TexCoord[0].x + pixeltopixeldistance > 0.5f))
- gl_FragColor = vec4(min(color, otherpixel),0,1);
- }
- */
- /*
- void main(){
- vec2 color = texture2D(texture, gl_TexCoord[0].xy);
- vec2 colorR = texture2D(texture, clamp(gl_TexCoord[0].xy + vec2(1.0f / width, 0.0f), vec2(0.0f, 0.0f), vec2(1.0f,1.0f)));
- if(gl_TexCoord[0].x < border && gl_TexCoord[0].x + 1.0f / width > border)
- discard;
- else gl_FragColor = vec4(min(color, colorR), 0, 1);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement