Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Shadowmapping with NGC

Author
Message
DcZee
22
Years of Service
User Offline
Joined: 28th Apr 2003
Location:
Posted: 26th Oct 2004 00:31
hehe I had to do it,..and it works quite well. Place your objects on the terrain and then use NGC's RayIntersectTypePRO (v2.03) command to shadow map your terrain. Make a pure white, rgb(255,255,255) image that loads in and is used for Set Lightmapping ON terrain,lightmap. Shoot the ray from your "light source" to wards your terrain at intervals equivalent to the size of the lightmap you will be using. (ex if your terrain is 1000x1000 and your lightmap is 500x500 then you would shoot to every other loc on your terrain,...0,2,4,6,8 etc corresponding to pixels 0,1,2,3,4 on your light map). I dont want to get detailed here. IF your ray intersects an object (filter out the terrain object) then place a rgb(0,0,0) Dot at that corresponding location in your lightmap image. You can vary the intensity of the shadow many different ways. When complete, save your lightmap image to disk. On reload, your shadows will appear on the terrain.
A couple things to remember here,..1) your terrain x,z (0,0) might be at the lower left corner whereas your image map uv (0,0) starts at the upper left corner,..so be aware you might have to alter the way you trace the terrain to get the two matched up.

Its not fast,...but creates a nice static shadow map for your terrain. also, if you have your own ray routine it should work for that as well.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Oct 2004 00:40 Edited at: 26th Oct 2004 00:43
Thanks for the info, it was on my to-do list!

What kind of terrain are you using? Advanced Terrain or something else? I ask because I'm unsure how you've added a second texture as a lightmap. I imagined you would have to take the texture map and modify it (darken the pixels).

Quote: "You can vary the intensity of the shadow many different ways."


Yes, I considered an algorithm where you softened edges by detecting changes from light to shadow. You could set a fade value, and use this for the circumference of your fade.

You could also change it dependant on the distance from object to ground. I can't remember if it's in V2.03, but in 3 you get a list of intersect points, not just the first one.

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
DcZee
22
Years of Service
User Offline
Joined: 28th Apr 2003
Location:
Posted: 27th Oct 2004 10:47
Yes! great ideas,..but for now i load the shadow map into psp and do some filtering lol,...

Im using a .X file at the moment cause im using 5.7 and advanced is toast right now,..however it works for either. The only thing that changes is that i can sight my terrain height from get terrain ground height, instead of firing a rayinstersect at 90 degrees to the terrain surface. But,..it works fine and actually im very surprised that I havent noticed any considerable frame rate drops between using advnaced terrain or a .X file LOL. Anyhow, they both are just objects so u can use the object commands on either one. Too bad they dont work on the matrix!!

Im using the simple Dot/INK method to paint my shadow dots on a bitmap that then becomes the image map for the lightmap (set lightmapping on obj,lightmapimage. I could use lock and dwords but i was looking for a quick fix (not a fast one). So,..you have a basic texturemap already on the terrain,... then you add the lightmapping with the command Set Lightmapping ON terrainnumber,lightmapimage.

I then save that bitmap to the disk in bmp format so i can edit it with my paint program (contrast and touchups, blurs etc),..takes the jaggies out of the map and creates instant soft shadows )

Login to post a reply

Server time is: 2025-05-30 23:59:04
Your offset time is: 2025-05-30 23:59:04