2D Soft Shadows

Started by
10 comments, last by LonelyStar 18 years, 11 months ago
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
Advertisement
I'm also very interested in this.

Good luck! :)
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.


Mind sharing how you did it?
Ewww jaggies [razz] except for that, the screen looks good, any binaries up for download?
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 :(
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.
You might want to check out bluescrn's latest LD48h entry. Full source code available. It's unfortunetly not soft shadowing, but nor is any of the other things posted here. Maybe it will help anyway.
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
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.

This topic is closed to new replies.

Advertisement