SimoPI

02-19-2010, 07:32 AM

Hi, i'm new. First, sorry for my english.

I have a problem coding the shape normals. I'm not sure about the code i'm writing, because i'm a beginner in opengl and glsl.

Assume a triangle: (i1, i2, i3)

Assume a vertex: (v1, v2, v3), obtained from triangle[i1]

In opengl, i compute the normals in this way:

vector3 a, b;

a = v3-v1;

b = v2-v1;

vector3 normal = a^b; //cross product

Is that right?

I must send these values to a GLSL bump mapping, and it wants a normal for every vector. But i have ONE normal, computed from 3 vectors.

I need a normalArray implementation where i can send a normal for every vertex. I think i must reply the computed normal in v1, v2 and v3, but i don't know how...

Someone can help me?

I have a problem coding the shape normals. I'm not sure about the code i'm writing, because i'm a beginner in opengl and glsl.

Assume a triangle: (i1, i2, i3)

Assume a vertex: (v1, v2, v3), obtained from triangle[i1]

In opengl, i compute the normals in this way:

vector3 a, b;

a = v3-v1;

b = v2-v1;

vector3 normal = a^b; //cross product

Is that right?

I must send these values to a GLSL bump mapping, and it wants a normal for every vector. But i have ONE normal, computed from 3 vectors.

I need a normalArray implementation where i can send a normal for every vertex. I think i must reply the computed normal in v1, v2 and v3, but i don't know how...

Someone can help me?