0
\$\begingroup\$

Given that I have the TerrainShader class and DefaultShader class. Also a FBO (Frame Buffer Object) shadow map

The TerrainShader has all the terrain, light, shadow related calculations. While the DefaultShader has the generic objects light, shadow related calculations.

I have successfully cast a directional shadow map when I only use DefaultShader alone with random cube objects and a plane. Now the problem was when I move or use a terrain instead of TerrainShader, the shadow is not cast in the terrain.

Question: Am I using the FBO the correct way or I am doing it wrong.

Solution Idea (Not yet applied)

  • Merge terrain and default shader as one and create a flag if object or terrain will be rendered? (Still not sure if this is correct.)

Pseudocode (Current successful implementation)

  • Create shadow map fbo
  • Create default shader
  • Create depth shader
  • bind shadow map fbo
  • clear depth
  • render cubes & plane using depth shader (mvp)
  • unbind shadow map fb
  • clear color and depth
  • render cubes & plane using default shader

Pseudocode (with Terrain shadow not working)

  • Create shadow map fbo
  • Create default shader
  • Create terrain shader
  • Create depth shader
  • bind shadow map fbo
  • clear depth
  • render cubes & plane using depth shader (mvp) and exclude terrain
  • unbind shadow map fb
  • clear color and depth
  • render cubes using default shader
  • render terrain using terrain shader
\$\endgroup\$
0
\$\begingroup\$

I turns out that I made a mistake, I have filtered out terrain in the list of entities. So by including the terrain again, the shadow map is now displayed in terrain

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .