10 Other fragment outputs
discard: drop this pixel
Fragments whose noise is below the threshold are dropped: no colour, no depth. Through the holes you see the sphere’s inside.
01
01
Exercise
Runs once per pixelDrag numbers, or edit the code
JS side
gl.uniformMatrix4fv(uModel, …) // rotation -0.35 / 0.10discard makes the fragment write nothing: no colour, no depth, so whatever is behind shows through. gl_FrontFacing tells you whether you see a front or a back.
Try it
- Set the threshold to 0.6: the sphere is full of holes
- What colour is the inside you see through the holes? Why?
- Change discard to color = vec3(0.0) and compare