Jump to content
  • Advertisement
Sign in to follow this  
RPTD

How doing GLSL + PCF + jitter?

This topic is 4413 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Does your code look like this?


vec3 shadowST = projCoord.xyz / projCoord.w;
float mapScale = 1.0 / 1024.0; //match this to shadowmap size
vec4 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.

Share this post


Link to post
Share on other sites
Nah, I use something like this:
shadow2D(shadowmap, vec3( shadowST.s + pixelSize, shadowST.t + pixelSize, shadowST.p ));[/quote]

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!