   P.R.T. and Terrain Rendering
  Hello all,I've just been discussing possible projects with a mentor, and as an offshoot of original discussions I was thinking about combining terrain rendering and Pre Computer Radiance Transfer / Spherical Harmonic Lighting. I had a look on google and some of my other haunts but couldn't find any good examples of it having been done. Has anyone here seen it attempted?I'm no expert on SH/PRT lighting, but I've read the basics and looked at the DX-SDK implementation. One of the key requirements is the "single texel mapping", that is, one pixel in a texture maps to only one part of the geometry - a factor that is often a basic feature of terrain texture maps... The other being that the geometry is static and only the lights are dynamic, again, another common feature of terrain engines. Apart from the potentially huge pre-processing and data storage requirements, once up and running I could imagine it would be an impressive demo - especially with the global illumination like qualities (soft shadows/diffuse reflections..).Any thoughts on something like this? Do-able (or already done!)?Cheers,Jack   
  It's certainly doable and heightmaps make the implementation easier since both ray tracing and the unique texture mapping are simplified. Terrains are also mainly lit by the sky/sun which are very far away which is another assumption of PRT, so that also makes it suitable. However, you'll have poor results trying to get sharp shadows from the sun on a clear day with PRT so you'll probably have to combine it with simple direct lighting perhaps utilising shadow mapping for shadows, to get good results.   ;Quote:However, you'll have poor results trying to get sharp shadows from the sun on a clear day with PRTYeah, I read somewhere that the quality of shadowing would probably be quite poor. Yet, at the same time, would a light source as far away as the sun generate noticeably sharp shadows in many cases? I'd of thought it wouldn't be too much of a problem as long as it made a reasonably area behind a mountain (for example) darker than everything else around it. Could look quite good as a form of soft shadowing?Quote:combine it with simple direct lightingWould this work? Because of the differences in the algorithms used (and the possibility for diffuse inter-reflections) wouldn't it end up very noticeable where the shadows and direct lighting came from - and that they weren't part of the same solution?Thanks for the replyJack   ;  I agree with mixing in a shadow-map. The sun subtends 0.5 degrees in sky or something like that so it gives quite sharp shadows for all but casters that are far away from the receiver - the sharpness decreases with distance between the two.For sun in the sky I would treat the two separately - I think Sloan (author of PRT) also suggested this in a GDalgorithms post somewhere. He suggested either using direct shadow maps or a steerable basis (see "steerable illumination textures") for the sun and using SH basis for the sky (since the sky, minus the sun, is alot smoother and low-frequency). I looked into steerable basis but I prefer shadow maps, but you miss out on sunlight interreflections (you get direct sunlight, direct skylight and skylight interreflections). Maybe add polynomial texture maps to capture sunlight interreflections (ie, simulate sunlight, minus surrouding skylight, and subtract the direct contribution, ie keep the 2nd, 3rd, etc bounces) and store in a polynomial texture.   ;Quote:it gives quite sharp shadows for all but casters that are far away from the receiver - the sharpness decreases with distance between the two.Really... will have to look into this stuff in more detail then [smile]Quote:He suggested either using direct shadow maps or a steerable basis (see "steerable illumination textures") for the sun and using SH basis for the skyI'll definitely look into that. Sounds interesting, but definitely makes the project a whole lot more complicated!Many thanks for your help!Jack   ;  If you've ever been out walking on a sunny day then you would notice that the shadow is pretty sharp.  One thing to remember though is that PRT is not just Spherical Harmonics.  You could also you Haar Wavelets to store your transfer functions, resulting in 'All frequency' Shadows, I have to admit I have not implemented Haar PRT but that would solve the hard shadow problem.I agree that the effect would be incredible, especially if you are going to implement sky-light illumination models to create the incident lighting coefficients.One advantage of mixing the SH represenation with e.g. shadow map is that dynamic objects can be supported (although this can also be done with neighbourhood transfer)   ;Quote:If you've ever been out walking on a sunny day then you would notice that the shadow is pretty sharp.I suppose I really should be more attentive [embarrass] - I go walking most weekends, clock up a few hundred miles a year...Quote:I have not implemented Haar PRT but that would solve the hard shadow problem.This sounds more promising. Sounds like it'll match the style of algorithm/method better than a completely different shadowing technique.Quote:especially if you are going to implement sky-light illumination models to create the incident lighting coefficients.I hadn't considered this yet. I'm still trying to spec-out a rough idea of what is possible and, as a subset, what is possible within my time constraints (about 10-12 months part time work).I'm initially thinking of large scale terrain rendering (to cover some ground with  LOD and/or paging data in/out of memory efficiently), combined with a decent lighting model (i.e. what is discussed here). Dynamic objects would be nice, but not necessarily required. As for sky/clouds, that could be simplified by constraining the camera to a "Real-Time Strategy" type eye-in-the-sky approach, or could be fully implemented as a skybox/dome.From the outset I won't be able to fit all of that together, but if I can pick a realistic subset/simplification of the full project then that'd be great.Cheers,Jack   ;Quote:Original post by jollyjeffersHello all,I've just been discussing possible projects with a mentor, and as an offshoot of original discussions I was thinking about combining terrain rendering and Pre Computer Radiance Transfer / Spherical Harmonic Lighting. I had a look on google and some of my other haunts but couldn't find any good examples of it having been done. Has anyone here seen it attempted?I'm no expert on SH/PRT lighting, but I've read the basics and looked at the DX-SDK implementation. One of the key requirements is the "single texel mapping", that is, one pixel in a texture maps to only one part of the geometry - a factor that is often a basic feature of terrain texture maps... The other being that the geometry is static and only the lights are dynamic, again, another common feature of terrain engines. Apart from the potentially huge pre-processing and data storage requirements, once up and running I could imagine it would be an impressive demo - especially with the global illumination like qualities (soft shadows/diffuse reflections..).Any thoughts on something like this? Do-able (or already done!)?Cheers,JackYou can certainly do PRT on your terrain - but I'd argue it isn't that useful. PRT stores the basis functions of light response, so that with any given infinite direction lighting enviroment, an object can respond appropriatly.The only thing is - with a terrain, there is usually only 1 infinite light object, the sun. If the sun isn't moving, well, there isn't any point to PRT - you would just bake the lighting into the texture. PRT is used to make an object's enviroment have influence on it, since this will change based on the objects position and orientation.Since an enviroment is static, it doesn't face this problem - the enviroments interaction with itself is static, or a function of the time of day and cloud cover. Terrain should be paramertized with these functions. That is, if you wanted to make a setting sun, then using SH wouldn't be the best way to do it since the light can only move along one arc - a simpler basis function would work much better.If you want hard shadows, then a use horizon shadows for terrain. They are cheap and easy.   ;  Hard shadows aren't really realistic in terrains. As Soiled pointed out, sunlight produces sharp shadows, but they grow less sharp as the distance between the shadow caster and the reciever increases. A mountain doesn't cast hard shadows on the plains below, it just looks that way when seen from far away. The transition from full shadow to full sunlight stretches over several meters, in some cases as much as 100 meters. A filtered lightmap or even vertex colors is enough for this.I'm not sure how much it applies to PRT/SH in terrain rendering though.AFAIK the standard way of lighting the shaded parts of terrain is by using an ambient light value, and while it's "ok", it could be better. I think SHL could be a great idea in terrain rendering, but a SHL probe of only the indirect/skylight part could be a better option. This could be used in the shaded areas (or entire terrain when overcast, while areas with direct sunlight would use a blend between SHL and a directional light. I don't know how/if retransmitted light from the rest of the terrain could be factored in. Perhaps HDR would also be useful, since the SHL probe would otherwise be very dark (5-10% of full brightness perhaps... dunno) and thus have very little dynamic range. It might also be possible to use a normal 24bit image for the probe and change the value in the shader. I've never used either, but I noticed that the HDR example in the DX SDK spent 100% of my CPU (2800+ AMD).The thing you must consider is wether the perhaps indesceranble increase in visual quality and realism is worth the extra cycles. I'd be interested in seeing the results though, and will be watching this topic :)NOTE: I've never used PRT and my knowledge is minimal. I may way off. IIRC SH is a texture that is looked up in based on the normal of the pixel/vertex. The way I've interpreted this is that this texture is a half sphere view of the sky (light blue near sun that darkens and goes towards purple as the angle/distance from the sun increases). This is also the reason I think that disregarding the sun itself (just keeping the athmospheric scattering) is a good idea.   ;Quote:Original post by EvilDecl81The only thing is - with a terrain, there is usually only 1 infinite light object, the sun. If the sun isn't moving, well, there isn't any point to PRT - you would just bake the lighting into the texture. PRT is used to make an object's enviroment have influence on it, since this will change based on the objects position and orientation.Since an enviroment is static, it doesn't face this problem - the enviroments interaction with itself is static, or a function of the time of day and cloud cover. Terrain should be paramertized with these functions. That is, if you wanted to make a setting sun, then using SH wouldn't be the best way to do it since the light can only move along one arc - a simpler basis function would work much better.Thats a good point, but I think your neglecting the fact that although the sun moves along one arc the position of the sun has a big impact on the incident light from the entire sky.  I think PRT would be useful here because of this, especially if you wanted the lighting of your terrain to match PRT lit objects(even if you just use it for self-shadowing and produce dynamic shadows using some other method)Check out :Check out this for daylight models. If you do implement this then please let us know I'd be very interested in seeing your results!   