Jump to content
  • Advertisement
Sign in to follow this  
LonelyStar

OpenGL 2D Soft Shadows

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

Hello together, I am looking for a way to implement dynamic shadows for a 2D enginge using OpenGL as described in "http://www.gamedev.net/reference/articles/article2032.asp". The problem with the way described in the article is, that it uses the alpha channel with blending to create the desired effect. I am already using the alpha channel with blending to draw my half-transparent sprites and I do not see how both that could be combined. I have found a lot of techniques how to do dynamic shadows in 3D but I am not sure I to use one of those to do it in 2D. I thought about "Vertex/Pixel Shaders" but I did not find enough information about them to know if it would work. Anybody any Idea/Hint how to do it? Like a known technique wich would be good for adapting to the 2D case? Thanks! Nathan

Share this post


Link to post
Share on other sites
Advertisement
How about multitexturing?

I would want to thank you [smile]. I was sitting here having nothing to do when I noticed your post. I thought hmm.. maybe I can create a demo that generate 2D shadows just using a pixel shader. So now about an hour or so later, here is a small screenshot of the demo. Pretty simple thing really.


Share this post


Link to post
Share on other sites
I will upload a demo perhaps later today. I just need to tweak it a bit first.

This shader should be run on a graphics card that has shader model 3.0. I dont have one so in order to be able to run the shader at all, I have to live with jaggies :(

Share this post


Link to post
Share on other sites
Here is the demo: Dynamic 2D Shadows Demo. Please do not blame me if this demo doesn’t run on your computer or that it is slow, it has been something that I put together last night.
Here is a screenshot of how it should look like.

Share this post


Link to post
Share on other sites
Hi!
Firstly: Thanks for all your ansers!
Multitexturing: I have not found anything that tells me how to do dynamic lights with multitexturing ... only static light-maps. Have I not searched hard enought?

Your demo "AxoDosS" looks really cool. Also I do almost nothing about shaders, I feel like a pixel shader is a little bit overkill. Would it not also work with a vertex shader?
Do you think it is possible to also do more soft-shadows with a vertex-shader?

Thanks!!!
Nathan

Share this post


Link to post
Share on other sites
Quote:
Original post by LonelyStar
Hi!
Firstly: Thanks for all your ansers!
Multitexturing: I have not found anything that tells me how to do dynamic lights with multitexturing ... only static light-maps. Have I not searched hard enought?

Your demo "AxoDosS" looks really cool. Also I do almost nothing about shaders, I feel like a pixel shader is a little bit overkill. Would it not also work with a vertex shader?
Do you think it is possible to also do more soft-shadows with a vertex-shader?

Thanks!!!
Nathan


Here is how I was thinking. You have two texture.
Texture 1: RGB = your sprite color, A (alpha) = You sprite transparency value.
Texture 2: Your generated shadow (as described in the article)
Would it not work if you would modulate these two textures? Or maybe use multipass rendering (render your sprite first and then the shadows)?

The method I used in my program is a simple but slow one, I would not recommend to use it when you can use faster methods that work in most cases.

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!