projection
projection
well, i was having a look at shadow mapping, and that started me thinking on all the stuff i don't know..
and that led me to wondering how on earth the texture is projected.
from this wikipedia page: http://en.wikipedia.org/wiki/Shadow_mapping
there is this picture:
as you can see (or maybe not, look at the page for more), they have taken what a camera sees, and then put that onto an image that another camera sees...they made it look correct!
I think this is to do with texture projection done with a shader, but i have no idea how it works, and despite searching around all i find is bits of code that relate to one project and not another, and none actually explain how it works!
so although this may not be an easy thing to ask, i would like to know (in detail) how texture projection (or whatever they did) works.
If you have some good links that explain it, or maybe if someone knows and can explain it themselves, that would be great.
and that led me to wondering how on earth the texture is projected.
from this wikipedia page: http://en.wikipedia.org/wiki/Shadow_mapping
there is this picture:
as you can see (or maybe not, look at the page for more), they have taken what a camera sees, and then put that onto an image that another camera sees...they made it look correct!
I think this is to do with texture projection done with a shader, but i have no idea how it works, and despite searching around all i find is bits of code that relate to one project and not another, and none actually explain how it works!
so although this may not be an easy thing to ask, i would like to know (in detail) how texture projection (or whatever they did) works.
If you have some good links that explain it, or maybe if someone knows and can explain it themselves, that would be great.
you need to write a shader that does two scene passes.
In pass one, you build a like projection matrix (like a camera projection matrix, but from the lights point of view) You then renderer that scene to texture. the PS output will be the "depth" of the pixel in the scene.
In the second scene pass, you use the RTT to calculate the shadows on each object.
There should be some examples in the DX or Nvidia SDK's
In pass one, you build a like projection matrix (like a camera projection matrix, but from the lights point of view) You then renderer that scene to texture. the PS output will be the "depth" of the pixel in the scene.
In the second scene pass, you use the RTT to calculate the shadows on each object.
There should be some examples in the DX or Nvidia SDK's
This might help...
http://www.riemers.net/eng/Tutorials/XN ... eries3.php
It's XNA / C#, but it shows the principals behind shadow mapping (although not a very good implementation)
http://www.riemers.net/eng/Tutorials/XN ... eries3.php
It's XNA / C#, but it shows the principals behind shadow mapping (although not a very good implementation)
I have figured out the projection stuff.
For the next bit i have run into another problem. I have created a render target of the depth of the scene...now i need to access it from a shader.
How can i send texture data to a shader without having it on the model?
I am sure this is possible as it seems to happen on that reimers site.
He has in his HLSL code this:
and in his directx code he has this:
Therefore i am sure it is possible to make a render target texture available to my shaders. But with irrlicht and the MyShaderCallBack thing, it appears to only allow me to send floating point values.
can someone point me in the right direction? Does it involve sending a pointer somehow?
For the next bit i have run into another problem. I have created a render target of the depth of the scene...now i need to access it from a shader.
How can i send texture data to a shader without having it on the model?
I am sure this is possible as it seems to happen on that reimers site.
He has in his HLSL code this:
Code: Select all
Texture xShadowMap;
sampler ShadowMapSampler = sampler_state { texture = <xShadowMap> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = clamp; AddressV = clamp;};
Code: Select all
effect.SetValue("xShadowMap", RenderTexture);
can someone point me in the right direction? Does it involve sending a pointer somehow?
There's source code on my website that may be of help to you. I do stuff like render into a texture and then use that texture as input to a shader. Irrlicht makes it real easy to do.
http://sio2.g0dsoft.com
http://sio2.g0dsoft.com
which one is it? i downloaded the hardware ray trace 2 one but it had no source, and i downloaded the per pixel lighting example with water one, and it sent the texture normally by putting it on a model (as far as i can tell anyway).
I have slow internet so i would rather not download them all just to find this one.
I have slow internet so i would rather not download them all just to find this one.
What do you mean "which one is it"? How about the one that says "rendered into an Irrlicht-managed rendertarget" and "source code included".esaptonor wrote:which one is it? i downloaded the hardware ray trace 2 one but it had no source, and i downloaded the per pixel lighting example with water one, and it sent the texture normally by putting it on a model (as far as i can tell anyway).
I have slow internet so i would rather not download them all just to find this one.
I did download that one (the water and perpixel lighting one), but from what i could see the render target texture is put on the mesh and used that way ...i may be wrong though, but if that is the case, then that is not what i was after:
I don't want to have to add my shadow map texture as a 3rd texture to every model and then update it for every model every frame. What i need is a way for me to update the render target within irrlicht, and then send it to the shader, the same way you can send mWorldViewProj variable etc.
am i making sense? is there a way to do it that way? or did you already do it that way and i have missed it?
if i did miss it somehow can you explain where it is and how you did it so that i can't possibly miss it next time....
thanks for taking the time to help,
esaptonor
I don't want to have to add my shadow map texture as a 3rd texture to every model and then update it for every model every frame. What i need is a way for me to update the render target within irrlicht, and then send it to the shader, the same way you can send mWorldViewProj variable etc.
am i making sense? is there a way to do it that way? or did you already do it that way and i have missed it?
if i did miss it somehow can you explain where it is and how you did it so that i can't possibly miss it next time....
thanks for taking the time to help,
esaptonor