PDA

View Full Version : Regarding a simple toon shader



Mukund
07-09-2011, 04:59 AM
Hello Everyone,

I am new to shaders. I am going through some tutorials online. There is this tutorial about Toon Shaders:

TUTORIAL (http://www.lighthouse3d.com/tutorials/glsl-tutorial/toon-shader-version-ii/)

Now, it says:


In this section we will do the toon shader effect per fragment. In order to do that, we need to have access to the fragments normal per fragment. Hence the vertex shader only needs to write the normal into a varying variable, so that the fragment shader has access to the interpolated normal.

What I am confused is, we specify normals per vertex. But how can we get access to normals at fragments? Is there some interpolation done internally?

Could anyone please clarify this for me?
Thanks.

Aleksandar
07-09-2011, 06:52 AM
Do you know how varying variables "work"?

Those tutorials you are talking about are pretty ancient, but still one of the best on the net. Antonio Ramires Fernandes did a great thing, and I'm glad he is back again.

Your problem is that you didn't read the tutorial from the start.
So, get back to the beginning and patiently read everything.

I just have to add that interpolation is presented only if interpolation qualifier is not flat. The default value is smooth which stands for perspective correct interpolation.

Also be aware that GLSL after ver. 1.30 doesn't use varying variables. Now they are in/out.

Mukund
07-09-2011, 10:10 AM
Thanks Aleksandar, i will read it from the beginning.