In the process of incorporating shadow maps for shadows, I am attempting to render a scene to a separate framebuffer (texture). Despite my efforts, I have not been able to achieve the desired outcome. After simplifying my codebase, I am left with a set of basic instructions aimed at rendering a scene to a texture and then displaying it.
The program is comprised of two components:
- Ground program
- Teapot program
The first component is responsible for rendering a rectangle with a specific texture, while the second one renders a colorful teapot based on its position. The rendering steps are as follows:
- Switch to the framebuffer
- Render the teapot
- Switch back to the normal buffer
- Render the teapot again
- Render the ground
The fragment shader for the ground looks like this:
gl_FragColor = texture2D(shadowMap, fTexCoord);
The 'shadowMap' represents the texture rendered in step 2. As expected, I can see a floating teapot with a rectangle drawn beneath it. However, I also anticipate the 'ground' to feature a teapot since we rendered the scene without the ground to the framebuffer/texture.
Functions in the Code:
- setup2(): sets up all the buffers and uniforms.
- render(): renders the scene.
Note: This code has been modified and simplified for an assignment purpose, deviating significantly from the original task :).