• Advertisement
Sign in to follow this  

Stencil buffer soft(blurry) edges

This topic is 2348 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

Hi, i used the stencil buffer to create a fog of war for my game, as my character is moving i am drawing circles to the stencil buffer setting pixels to 1 and after everything else is drawn i am drawing a transparent rectangle the size of the map, with stencil test enabled and set to NOTEQUAL to 1. That way i am getting a good fog of war but the edges are too sharp, they shood be soft. Is there a way to blur the edge of the stencil buffer? thanks..

Share this post


Link to post
Share on other sites
Advertisement

You could use render to texture and blur the result, but I'm failing to see why you can't just use normal fog.


Its a 2d top down game, i need the fog of war so that the player can see what terrain he has uncovered..

What should i render to texture? i Dont want everything blured, just the edges of the stencil mask.

Share this post


Link to post
Share on other sites
What you are looking for is an alpha blending of the stencil buffer, this is not possible. I suggest that you use a black texture with a alpha hole in it and project orthogonally over your scene.

Share this post


Link to post
Share on other sites

What you are looking for is an alpha blending of the stencil buffer, this is not possible. I suggest that you use a black texture with a alpha hole in it and project orthogonally over your scene.


Ok then, i suppose i have to have a texture the size of my map, and than make holes in it, holes being blurred circles.
But i'm not quite sure how i would do this, maybe if i had a 32 bit texture with a alpha hole in it and than if i could put the alpha values of that texture to the alpha values of the texture that i want to make holes in...

And then as my character moves i could make holes in the big texture by changing the original alpha with my hole texture.. But again i don't know how to do this?

Share this post


Link to post
Share on other sites
Maybe I do not fully understand your concept of the fog of war. Are you talking about uncovering parts of the map or a dynamic fog, that moves with your character, so that parts of the map that you already visited get invisible again once you left the area?

anyway i think a texture the size of your screen should do for the visual effect. Maybe you should check out FBOs (FrameBuffer Objects) for that purpose.

Share this post


Link to post
Share on other sites

Maybe I do not fully understand your concept of the fog of war. Are you talking about uncovering parts of the map or a dynamic fog, that moves with your character, so that parts of the map that you already visited get invisible again once you left the area?

anyway i think a texture the size of your screen should do for the visual effect. Maybe you should check out FBOs (FrameBuffer Objects) for that purpose.



No its not dynamic, i just have to uncover parts of the map with player movement. Anyway I'm looking into FBO's and generally need to learn OpenGL more to implement these effects... Thanks...

Share this post


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

  • Advertisement