Shadows in raycasting
Author |
Message |
metachief
|
Posted: Wed Oct 08, 2008 2:57 pm Post subject: Shadows in raycasting |
|
|
I made a raycaster, but it doesn't look realistic since there are no shadows in corners, etc... Could someone explain to me how I would darken corners in my game. By the way, I am not using bitmaps for texturing. Also, any suggestions on how to make it look better would be nice.
Description: |
|
Filesize: |
1.09 MB |
Viewed: |
83 Time(s) |
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
SNIPERDUDE
|
Posted: Wed Oct 08, 2008 4:04 pm Post subject: Re: Shadows in raycasting |
|
|
ok first off don't draw boxes around each section.
Secondly - to your problem, don't make the wall pieces grey. Really ugly that way. Instead, use your distance integer in a fraction in RGB to create depth using colours. Voila.
ex: Turing: | RGB.SetColour (255, (1 - (Ray_Dist / Max_Dist )), (1 - (Ray_Dist / Max_Dist )), (1 - (Ray_Dist / Max_Dist ))) |
That is a rough example that makes the bar black when it is at its farthest distance (that you are measuring) and white at its closest. I suggest you play around with the RGB module a bit and work out the math to get the colours you want.
Same goes for the floor.
Here's an example of my old programme to give you an example: I used red as my base colour and added the shading through fractions on RGB.
Description: |
Screenshot of my old raytracing program |
|
Filesize: |
598.6 KB |
Viewed: |
78 Time(s) |
|
|
|
|
|
|
|
metachief
|
Posted: Wed Oct 08, 2008 4:47 pm Post subject: RE:Shadows in raycasting |
|
|
Never used RGB before! I guess I have to learn it now. Thank you lots for helping me out. By the way, did you post up your raycasting game. If you haven't you should, it looks nice!
|
|
|
|
|
|
andrew.
|
Posted: Wed Oct 08, 2008 6:13 pm Post subject: RE:Shadows in raycasting |
|
|
RGB isn't as hard as it sounds. I actually taught it to myself for having transparency (but it's crap for that though).
|
|
|
|
|
|
SNIPERDUDE
|
Posted: Wed Oct 08, 2008 6:50 pm Post subject: Re: Shadows in raycasting |
|
|
No, for transparencies look at my post here (last post).
For my old game, look here.
Due note that it is an older version, and because I used a different algorithm (per-pixel distance checking) it is much slower. Runs fine on a fast comp though. Either way the game has been worked on since, and actually looks better. Because the newer version still has several bugs (I'm hoping for it to be a big release) I will not be posting it quite yet.
Good luck with your programme though, and let me know how it turns out. And RGB is really easy to learn, just make a programme on the side to just experiment, that's what I did.
|
|
|
|
|
|
metachief
|
Posted: Wed Oct 08, 2008 10:16 pm Post subject: RE:Shadows in raycasting |
|
|
Ya, ok. Also, what is the difference between checking every pixel and predicting the points to check for on a grid? What I mean is: is one or the other better to use? Perhaps by checking every pixel, you could get better detail or something? I used the grid method.
|
|
|
|
|
|
SNIPERDUDE
|
Posted: Thu Oct 09, 2008 6:55 am Post subject: RE:Shadows in raycasting |
|
|
No using the grid method is better. The only occasion per-pixel checking should be used is if your maps don't follow a grid. The major disadvantage of this is it runs alot slower, minimizing your chance of expanding your game to have other features (that would also eat up speed) such as special effects or weather.
In short, Ray-Casting (checking by grid) is much faster and better than Ray-Tracing (per-pixel checking).
|
|
|
|
|
|
|
|