How doing GLSL + PCF + jitter?

Started by
2 comments, last by RPTD 17 years, 6 months ago
Tried googling around like mad but found nothing that helped me one single bit. I have right now a shadow map working in GLSL with PCF. Now as we all know this turns out still blocky hence some jittering is required to make things more nice to look at. Now that's where I don't get any further. How to I make this "jittering" in GLSL? I know the basics of this in that you take the center of the point and add a random offset in s and t direction beeing half the pixel size. Now though how doing this? In he GLSL docs there is mentioned a "noise2" function which takes a vec2 and gives a pseudo-random vec2 out. Is this what I need for jittering? Or is there some other function that should be used there?

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

Advertisement
Does your code look like this?

vec3 shadowST = projCoord.xyz / projCoord.w;float mapScale = 1.0 / 1024.0; //match this to shadowmap sizevec4 shadowColor = shadow2D(shadowmap, shadowST);	shadowColor += shadow2D(shadowmap, shadowST.xyz + vec3( mapScale,  mapScale, 0));shadowColor += shadow2D(shadowmap, shadowST.xyz + vec3( mapScale, -mapScale, 0));shadowColor += shadow2D(shadowmap, shadowST.xyz + vec3( mapScale,  	  0, 0));shadowColor += shadow2D(shadowmap, shadowST.xyz + vec3(-mapScale,  mapScale, 0));shadowColor += shadow2D(shadowmap, shadowST.xyz + vec3(-mapScale, -mapScale, 0));shadowColor += shadow2D(shadowmap, shadowST.xyz + vec3(-mapScale,  	  0, 0));shadowColor += shadow2D(shadowmap, shadowST.xyz + vec3(        0,  mapScale, 0));shadowColor += shadow2D(shadowmap, shadowST.xyz + vec3(        0, -mapScale, 0));shadowColor = shadowColor / 9.0; //9 samples


Could make this into a for loop if your card supports it.
Nah, I use something like this:
shadow2D(shadowmap, vec3( shadowST.s + pixelSize, shadowST.t + pixelSize, shadowST.p ));

as this should be quicker ( no + operator involved ).

But I can change to whatever is required to get jittering to work.

And BTW for-loops are a no-no in shaders even if the language provides it.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

Nobody an answer? Hardly can imagine nobody used PCF with GLSL so far. Can somebody help me there? I tried out once with noise2 but it doesn't change anything at all hence I have to do something wrong but I have no clue what.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

This topic is closed to new replies.

Advertisement