projection

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

projection

Post by esaptonor »

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:
Image

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.
TheC
Posts: 93
Joined: Fri May 05, 2006 7:50 am

Post by TheC »

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
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

it wasn't the shadows i was concerned about, i just want to know how they managed to overlay the lights point of view correctly onto the cameras point of view...but i will check out some examples in the mean time
nomad
Posts: 53
Joined: Thu Jan 05, 2006 12:35 pm
Location: Wales

Post by nomad »

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)
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

thanks, i will check it out
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

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:

Code: Select all

Texture xShadowMap;

sampler ShadowMapSampler = sampler_state { texture = <xShadowMap> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = clamp; AddressV = clamp;};
and in his directx code he has this:

Code: Select all

effect.SetValue("xShadowMap", RenderTexture);
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?
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

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
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

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.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

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.
What do you mean "which one is it"? How about the one that says "rendered into an Irrlicht-managed rendertarget" and "source code included". :evil:
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

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? :oops:
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
Post Reply