Search code examples
c#.netxna-4.0hlsl

"Image Based Light" HLSL


I have a code in HLSL which aims to simulate the IBL (Image-based light http://en.wikipedia.org/wiki/Image-based_lighting). To simulate the IBL is necessary to have a texture from "world" around the object, I want to dynamically generate the texture by the position of the object. I have 2 problems:

• How to generate a texture of the world in 360 degrees around the object? I need 6 cameras of 45 degrees each, or is possible do this with only one?

• I already know how to map a cubic texture with "sampleCUBE" but I have the same image in the 6 sides, how do I get each side has its own texture?

https://i.sstatic.net/Iz6RZ.png

the IBL is present in games like Forza 4 and Crysys 2.


Solution

  • You may need 6 renders (might be 2 or 4 if you set huge FOV but it will result in distortion and will be harder to work with) or you can render it in single pass if you can use cubemap as render target or use some sort of rendering to spherical map link Without full picture you will not have enough data to work with. But those renders may include very basic shaders and low resolution output. Also you do not need to refresh them each frame instead you can move texture a bit and refresh each 5 frames for close object and each 10 for far objects. And most important is that you need "Image Based Light" only on visible parts so you may use only up to 3 passes instead 6.