Re: [Algorithms] It looks terrible (was: Lightmap Terrain)
Brought to you by:
vexxed72
From: Sam K. <sa...@ip...> - 2000-08-27 16:11:31
|
Niki, Here's something I've done in the past, which gets rid of the hard edge from "just darkening by some ammount if the ray intersected" and looks pretty good: Cast a ray from the sun to the sample point (Instead of Sample point to sun). (Starting at the edge of the map, or further if the terrain is tiled). You have a running shadow height (SHeight) which is set to 0. and a (RayDy) variable which is the y dropoff of the ray per pixel moved. Move along the ray (in x & z) towards the sample point. At each Heightmap pixel the ray passes over on the way do the following: If(SHeight<HeightmapPixelVal) { SHeight = HeightmapPixelVal; } else { SHeight -= RayDy; } When the sample point is reached, the value in SHeight is examined, the smaller it is the "less shadow" is here the bigger the "more shadow". This gives lovely graduations in the shadow, and real dark areas, and subtle lighter areas. Another nice trick is, if you store the resulting shadow height at every sample point to form a "shadow buffer", objects on the terrain can fall into shadow correctly if you compare their heights to the height in the "shadow buffer" even when they are not on the ground. This in effect is 2.5d volumetric shadows. Hope this helps, sam -----Original Message----- From: Klaus Hartmann <k_h...@os...> To: gda...@li... <gda...@li...> Date: 27 August 2000 2:48 PM Subject: [Algorithms] It looks terrible (was: Lightmap Terrain) >Hi all, > >Please have a look at the following image (~310 KB): >http://www.thecore.de/TheCore/shadows.jpg > >This lightmap looks majorly terrible, and I'm looking for ways to enhance >this. I use the simple dot-product approach, and I have two light source. >One light source (sun) is to the east, and the other ('anti' sun) is to the >west. I use two light sources, because I don't like ambient. I compute the >light for each texel, and then I cast a ray towards the sun (directional >light). If this ray intersect with the surface before it reaches the sun, >then I decrease the texel's intensity by some amount. I don't reflect or >refract rays. I figured, that reflection probably wouldn't make much sense, >because there's only a few cases where the reflected ray would hit the >terrain again (or am I wrong?). > >How can I make this look better? For example, is there a way to have real >penumbrae in the shadows. Of course, I could blur the image, but that just >wouldn't be the same. > >Any ideas? Honestly... a simple dot-product (without shadows) looks more >than twice as good (I can upload the same scene without shadows, if >requested). >Niki > >_______________________________________________ >GDAlgorithms-list mailing list >GDA...@li... >http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list |