Hallo

I am following the tutorial on ((tutorial effects normals)) for basic normals calculation but i see that normals need to go through the same math function that I am using to generate the mesh… any hint, tutorial?

tx

S.

```
- define pi 3.14
float2 Scale = 1;
float2 Offset = 0;
float3 Cone(float2 uv)
{
uv *= Scale;
uv += Offset;
float u = uv.x * 2*pi;
float v = uv.y;
float3 newPos;
newPos.x = 1.2*(1 -v/(2*pi))*cos(3*v)*(1 + cos(u)) + 3*cos(3*v);
newPos.y = 9*v/(2*pi) + 1.2*(1 - v/(2*pi))*sin(u);
newPos.z = 1.2*(1 -v/(2*pi))*sin(3*v)*(1 + cos(u)) + 3*sin(3*v);
return newPos;
}
float NeighbourOffset = 0.001;
vs2ps VS(
float4 PosO : POSITION,
float4 TexCd : TEXCOORD0)
{
//declare output struct
vs2ps Out;
//calc new position
float3 p = Cone(PosO.xy);
//calc neighbour pos in u direction
float3 n1 = Cone(PosO.xy + float2(NeighbourOffset, 0));
//calc neighbour pos in v direction
float3 n2 = Cone(PosO.xy + float2(0, NeighbourOffset));
//get tangent vector 1
float3 t1 = p - n1;
//get tangent vector 2
float3 t2 = p - n2;
//get normal
float3 NormO = cross(t1, t2);
//set new pos
PosO.xyz = p;
//put normal in view space and normalize it
Out.NormV = normalize(mul(NormO, tWV));
//inverse light direction in view space
Out.LightDirV = normalize(-mul(lDir, tV));
//inverse view dir in view space
Out.ViewDirV = -normalize(mul(PosO, tWV));
//transform position (projected)
Out.Pos = mul(PosO, tWVP);
//transform texturecoordinates
Out.TexCd = mul(TexCd, tTex);
return Out;
}
```