Lighting and Shadow System
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Lighting and Shadow System
You're welcome
Re: Lighting and Shadow System
Looks really awesome! I have a few questions though, I am going to start working on a game where I would like to have multiple light sources just for aesthetics. But only the light, not that it casts shadows on objects etc. How do you think the best way of accomplishing this would be?
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Lighting and Shadow System
You could just make a circle with x radius and apply something like a fade from center shader to the circle.
Re: Lighting and Shadow System
Me too, I'll probably start porting this Java version as the process is explained really well and the code is easy to run. I've never seen a version of this implementation with the objects lit though. How far are you with your port?Ranguna259 wrote:That's a similar aproach to this one. I'm actually trying to reproduce that effect...
I use a very crude method at the moment, just multiply each point by a large enough scalar. I have been thinking of taking the lights height into equation to change the length, but it makes things more complicated. What do you do?Ranguna259 wrote:Since you draw the shadows how do you set their limit ? Do they stop once they reach a certain distance from the light source or when they hit the screen borders ?
Re: Lighting and Shadow System
Hey I modified the code and created a new gist with just lights https://gist.github.com/seanpackham/8779962 take a look at the code and comments for an explanation of the method. EnjoyJeeper wrote:Looks really awesome! I have a few questions though, I am going to start working on a game where I would like to have multiple light sources just for aesthetics. But only the light, not that it casts shadows on objects etc. How do you think the best way of accomplishing this would be?
Re: Lighting and Shadow System
I have updated my subtractive method with a smooth radial gradient light shader https://gist.github.com/seanpackham/8727943
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Lighting and Shadow System
Not far, I've been trying to find a rectangle to polar and a polar to rectangle shader but I think I'll start porting the code you linked too, let's compare results once we are doneargh wrote:Me too, I'll probably start porting this Java version as the process is explained really well and the code is easy to run. I've never seen a version of this implementation with the objects lit though. How far are you with your port?
In my previous CPU processed lightning system I used an algorithem to detect the intersection point between two lines and then I'd calculate the intersection point of a raycast with all the sides of the rectangles on the screen, the result would be the the point of where the raycast would end. Have your tried drawing the scene (the rectangles) after applying the shader ?argh wrote:I use a very crude method at the moment, just multiply each point by a large enough scalar. I have been thinking of taking the lights height into equation to change the length, but it makes things more complicated. What do you do?
1st - Draw scene
2nd - Apply shaders
3rd - Stop the shaders
4th - Draw the scene once again
Re: Lighting and Shadow System
Hey yesterday was slow going, was busy with freelance work. This is how far I am, shaders are ported but the rest needs some tinkering. I think I won't go further with this method as it is purely for shadows. Adding lit objects would mean I would first have to detect shadow casting edges like my subtractive algorithm and then run it through the shaders.Ranguna259 wrote:I'll start porting the code you linked too, let's compare results once we are done
I like this this article does that too http://www.gamedev.net/page/resources/_ ... dows-r2032Ranguna259 wrote: 1st - Draw scene
2nd - Apply shaders
3rd - Stop the shaders
4th - Draw the scene once again
I really lke the simplicity of the subtractive algorithm, it just has some weird edge cases which I may be able to get around.
I was thinking about what you said about shadows overlapping, for me it is ok if a shadow overlaps an entity but not a wall/building and I might be able to get around this with smaller lights and adding big chunks of exclusion geometry for buildings.
I also want to try and add the radial gradient to the shadow and trim the shadow length to the light length.
Re: Lighting and Shadow System
One of the limitations of your approach is that it assumes point light sources while displaying finite light sources.
Looks at the shadow of an object which is smaller than the light source.
Looks at the shadow of an object which is smaller than the light source.
Re: Lighting and Shadow System
Yip the subtractive approach has far to many limitations to be used as a multi light realistic shadow implementation. But it does work well for simple shadow scenarios.
credit: http://forums.tigsource.com/index.php?topic=8803.0
It is also useful for visibility as seen in Teleglitch (Only boundary walls cast "shadows")
credit: http://forums.tigsource.com/index.php?topic=8803.0
It is also useful for visibility as seen in Teleglitch (Only boundary walls cast "shadows")
Who is online
Users browsing this forum: No registered users and 3 guests