dletozeun
11-14-2006, 02:42 PM
Hello,
I would setup shadow mapping with opengl. I have read several source codes that implement this technique, but when they have to render scene at the light point of view, they draw polygons as if they would draw these one on the framebuffer...
But the only thing we need when we render the scene at the light point of view is the Z-buffer and what I would to know is :
When I render the scene at the light point of view, can I stop rendering at the Z-buffer?
I think I have understood how I can read the Z-buffer data with opengl functions.
But I do shadow mapping using Opengl shaders, I think it is easyly than with opngl extensions...
So, This is what I want to do:
1) Render the scene at the light point of view and save the Z-buffer in a texture
(here there is not particular thing to do with vertex ans fragment shaders)
2) Render the scene at the camera point of view.
It is here that shaders intervene.
In the vertex shader, I think there is nothing particular...but In the fragment shader where I set up per pixel lighting, I think that I have to watch if each fragment is at the light point of view, in front of or behind the fragment in the Z-buffer saved previously in order to know if it is a lighted or a shadowed fragment.
=> Here, I have some questions that I ask myself:
1) gl_Vertex is a special variable of GLSL where the current vertex coordinates are saved. And if I save this variable in a 'varying' variable, is this last one interpolated in the fragment shader? It could be very interesting if I want to modulate interpolated fragment coordinates with light modelview and perspective matrices!
Moreover I don't know I can read Z buffer saved data (the texture) in opengl shaders, but I think it is the same thing as read color in texture mapping with shaders...
I hope that this explanation is clear understanding! Thank you for for help me!
I would setup shadow mapping with opengl. I have read several source codes that implement this technique, but when they have to render scene at the light point of view, they draw polygons as if they would draw these one on the framebuffer...
But the only thing we need when we render the scene at the light point of view is the Z-buffer and what I would to know is :
When I render the scene at the light point of view, can I stop rendering at the Z-buffer?
I think I have understood how I can read the Z-buffer data with opengl functions.
But I do shadow mapping using Opengl shaders, I think it is easyly than with opngl extensions...
So, This is what I want to do:
1) Render the scene at the light point of view and save the Z-buffer in a texture
(here there is not particular thing to do with vertex ans fragment shaders)
2) Render the scene at the camera point of view.
It is here that shaders intervene.
In the vertex shader, I think there is nothing particular...but In the fragment shader where I set up per pixel lighting, I think that I have to watch if each fragment is at the light point of view, in front of or behind the fragment in the Z-buffer saved previously in order to know if it is a lighted or a shadowed fragment.
=> Here, I have some questions that I ask myself:
1) gl_Vertex is a special variable of GLSL where the current vertex coordinates are saved. And if I save this variable in a 'varying' variable, is this last one interpolated in the fragment shader? It could be very interesting if I want to modulate interpolated fragment coordinates with light modelview and perspective matrices!
Moreover I don't know I can read Z buffer saved data (the texture) in opengl shaders, but I think it is the same thing as read color in texture mapping with shaders...
I hope that this explanation is clear understanding! Thank you for for help me!