I'm trying to write my own edge detection post-processing shader (for fun), and I'm approaching it as follows:
- Render the scene.
- Render the depth value of each pixel.
- Render the normal value of each pixel.
- Apply something like a Sobel filter using the depth + normal render as input.
- Use the results of the Sobel filter to add edges onto the scene render.
What would be the easiest way to achieve step 3?
I could replace the materials of all objects in my scene with materials that render normals, renderer it, and then change the materials back, but I'm hoping for a cleaner solution.