10 Other fragment outputs
MRT: one draw, two images
One fragment shader with two outputs: colour goes to texture 0, normals to texture 1. A second pass combines them for lighting.
-3.143.14
Exercise
Runs once per pixelDrag numbers, or edit the code
JS side
In GLSL ES 3.00 outputs are out variables you declare. layout(location = N) lets one draw write several textures at once — deferred rendering is built on it.
Try it
- Switch to “Light from both images” and turn the light: this pass reads only the two images and never draws the model
- Make gNormal output vWorld * 0.5 + 0.5 and see what image 1 becomes
- Delete the gNormal line and look at image 1