0

I am rendering a 3D cube using openTK and my lighting is not rendering as expected. Are the r,g,b (last 3 values of the vertex lines) values the correct normal values that I should be using?

This is the format of the cube that I have been given:

Vertex Format x,y,z,r,g,b
24
-0.2,-0.2,-0.2,0,1,0
0.2,-0.2,-0.2,0,1,0
-0.2,0.2,-0.2,0,1,0
0.2,0.2,-0.2,0,1,0
-0.2,-0.2,0.2,0,1,0
0.2,-0.2,0.2,0,1,0
-0.2,0.2,0.2,0,1,0
0.2,0.2,0.2,0,1,0
0.2,-0.2,-0.2,1,0,0
0.2,-0.2,0.2,1,0,0
0.2,0.2,-0.2,1,0,0
0.2,0.2,0.2,1,0,0
-0.2,-0.2,-0.2,1,0,0
-0.2,-0.2,0.2,1,0,0
-0.2,0.2,-0.2,1,0,0
-0.2,0.2,0.2,1,0,0
-0.2,-0.2,-0.2,0,0,1
-0.2,-0.2,0.2,0,0,1
0.2,-0.2,-0.2,0,0,1
0.2,-0.2,0.2,0,0,1
-0.2,0.2,-0.2,0,0,1
-0.2,0.2,0.2,0,0,1
0.2,0.2,-0.2,0,0,1
0.2,0.2,0.2,0,0,1
Index Format v1,v2,v3
12
1,0,2
1,2,3
4,5,6
6,5,7
9,8,10
9,10,11
12,13,14
14,13,15
17,16,18
17,18,19
20,21,22
22,21,23
LNAS
  • 11
  • 3
  • no they're not. see [change 2D object to 3D object OpenGl](http://stackoverflow.com/a/43627507/2521214) how the cube normals should look like ... you need add the normals manually or compute them by cross product .. – Spektre Apr 27 '17 at 08:04

1 Answers1

0

No, these are definitely not the correct normals.

Since a cube has 6 sides with different orientation, there also have to be 6 different normals. Currently you only have three. Note, that the sign of the normal vectors matter, so [1, 0, 0] != [-1, 0, 0].

BDL
  • 21,052
  • 22
  • 49
  • 55