PDA

View Full Version : How to get normals of each pixel fast?



zrzmonkey
06-25-2011, 06:43 AM
I want to get normals of each pixel in fragment shader.I have tried two ways,but they are both slow.
The first is to calculate in fragment shader directly by depth texture. But I have to use these normal mang times,so the efficiency is slow.
The second way is to calculate all normals of every pixels on screen before use fragment shader by cpu.But it is also slow.
So,is there a way to get normals of each pixel fast or a way without calculation?

BionicBytes
06-25-2011, 07:12 AM
But I have to use these normal mang times
What does that mean?



The second way is to calculate all normals of every pixels on screen before use fragment shader by cpu.But it is also slow.
So,is there a way to get normals of each pixel fast or a way without calculation?

you could use a normalmap tetxure.

V-man
06-25-2011, 09:19 AM
Make a RTT and write out your object's normals to it. Then you can sample those normals. The format for the RTT should be GL_RGBA32_ARB.

Alfonse Reinheart
06-25-2011, 11:12 AM
The format for the RTT should be GL_RGBA32_ARB.

Why? He could use GL_RGBA16. Or even better, GL_RGB10_A2.