Hi!
I need the depth texture of the scene to use it for shadows via a shader.
As I check the shadowmapping demo I see that the FBOrenderer is using the colorbuffer and converting it to a depth texture. But why not use the depth texture directly?
Is the FBOrenderers depth texture not working? I cannot make it work.
Is there another way of creating a depth texture that can be used in my shaders?
Cheers!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel, where is the ShadowMappingFBO example ? i didn't found it. The Lazarus ShadowFBO example is the same as Delphi and both use ColorTextureName.
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Jerome!
I cannot manage to make the FBORenderer actually render a depthTexture. The only way seems to be to use a shader to genereate a depthtexture from the the ColorTextureName.
The demo is here: https://sourceforge.net/p/glscene/code/HEAD/tree/trunk/Demos/Delphi/specialsFX/ShadowmappingFBO/
It has a much bigger TGLFBORenderer unit than the Lazarus version, so maybe there is some update that fixes the depthTexture generation?
Cheers!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel, under Lazarus, the Delphi FBORenderer unit is split in two Units : GLFBO and GLFBORenderer
I converted the ShadowMappingFBO sample, it work well except the HUDSprite something is not correct with the ShadowMapVis_fp script. I think the problem is shader2 is apply after Shader1
See the screenshot. I joined the zip of the converted sample. Just copy the resources needed from Delphi media folder to Lazarus media folder.
I have some issues making the resolution of the shadow good enough.
But my biggest concern is that as soon as my model move, the shadows gets displaced and I cannot solve it: https://youtu.be/5Uk9PaEGrBA
Is a different Matrix needed?
Cheers!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel, hum do you same code as sample for initalize matrix ? Take llook to the Scale and bias parameters. It's seem the Shadow not follow the model but stay in center of the screen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel, well see to move directOpenGLrenderer , indeed matrix for the shadow must be relative to the world and not attached to objects in a certain case is logic .
The person who's made this sample at base, SceneRoot not move. So it's correct.
But when you move sceneroot, directOpenGLrenderer's modelview matrix is also modified and going to wrong.
I think for solving this behaviours is to use absolutmatrix instead of relative and compute the modelview matrix ourself
But by moving directOpenGLrenderer directly in the Root is a quick and working hack ! +1
Cheers
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I need the depth texture of the scene to use it for shadows via a shader.
As I check the shadowmapping demo I see that the FBOrenderer is using the colorbuffer and converting it to a depth texture. But why not use the depth texture directly?
Is the FBOrenderers depth texture not working? I cannot make it work.
Is there another way of creating a depth texture that can be used in my shaders?
Cheers!
I was using the Lazarus shadowFBO demo, but now I noticed the Delphi version called shadowmappingFBO. I will check that out first.
Cheers!
Hi Daniel, where is the ShadowMappingFBO example ? i didn't found it. The Lazarus ShadowFBO example is the same as Delphi and both use ColorTextureName.
Regards
Hi Jerome!
I cannot manage to make the FBORenderer actually render a depthTexture. The only way seems to be to use a shader to genereate a depthtexture from the the ColorTextureName.
The demo is here: https://sourceforge.net/p/glscene/code/HEAD/tree/trunk/Demos/Delphi/specialsFX/ShadowmappingFBO/
It has a much bigger TGLFBORenderer unit than the Lazarus version, so maybe there is some update that fixes the depthTexture generation?
Cheers!
Hi Daniel, under Lazarus, the Delphi FBORenderer unit is split in two Units : GLFBO and GLFBORenderer
I converted the ShadowMappingFBO sample, it work well except the HUDSprite something is not correct with the ShadowMapVis_fp script. I think the problem is shader2 is apply after Shader1
See the screenshot. I joined the zip of the converted sample. Just copy the resources needed from Delphi media folder to Lazarus media folder.
Cheers
Thanks alot Jerome!!!
It works like a charm!
I have some issues making the resolution of the shadow good enough.
But my biggest concern is that as soon as my model move, the shadows gets displaced and I cannot solve it:
https://youtu.be/5Uk9PaEGrBA
Is a different Matrix needed?
Cheers!
Hi Daniel, hum do you same code as sample for initalize matrix ? Take llook to the Scale and bias parameters. It's seem the Shadow not follow the model but stay in center of the screen
Hi Jerome!
Yes, it's all the same code.
If you try this in the the ShadowMappingFBO sample, you'll see the same problem there.
The shadow starts to move away, ahead of the objects, the same way as in my program.
Any idea what might cause this?
Cheers!
Hi!
Is there a specific reason why the directOpenGLrenderer is child of the sceneroot dummycube?
Moving it to the GlScene root solves the issue!
Hi Daniel, well see to move directOpenGLrenderer , indeed matrix for the shadow must be relative to the world and not attached to objects in a certain case is logic .
The person who's made this sample at base, SceneRoot not move. So it's correct.
But when you move sceneroot, directOpenGLrenderer's modelview matrix is also modified and going to wrong.
I think for solving this behaviours is to use absolutmatrix instead of relative and compute the modelview matrix ourself
But by moving directOpenGLrenderer directly in the Root is a quick and working hack ! +1
Cheers
Hi Jerome!
Yes, it seems to be working nicely!
https://youtu.be/GNcFy8XMVJg
Now my problem is the resolution and the shadow acne.
Maybe I should look at cascaded shadow maps. Do you know some glScene demo using those?
Cheers!