Author Topic: lighting problem  (Read 1133 times)

Offline zsele

  • byte
  • *
  • Posts: 3
    • View Profile
lighting problem
« on: October 12, 2012, 03:31:18 pm »
hi

its probably a very stupid question, but i've just started use jpct. ::) So i made a world with cubes and added a (only one!) (green) light point over the red cube, but its look this:



i use opengl rendering and it has been added with this code:
Code: [Select]
world.addLight(defaultPos[i], defaultColors[i]);so i have no idea why looks all cube the same or what is this

Thanks and sorry for my and English.
« Last Edit: October 12, 2012, 03:43:31 pm by zsele »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: lighting problem
« Reply #1 on: October 12, 2012, 06:24:47 pm »
It's totally normal behaviour. If you place a light source in the scene, it will light all objects until you set some attenuation and/or discard distance for it.

Offline zsele

  • byte
  • *
  • Posts: 3
    • View Profile
Re: lighting problem
« Reply #2 on: October 12, 2012, 07:41:59 pm »
yes, but every cube has this texture: http://dl.dropbox.com/u/6900766/stone.jpg
and i think it shuold look like this:http://dl.dropbox.com/u/6900766/light1.png
so i dont understand why have every cube a green and a dark side

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: lighting problem
« Reply #3 on: October 12, 2012, 08:05:09 pm »
That's how vertex lighting works. The intensity of the light (from black to green in this case) is based on the angle between the vertex normals and the vector from the light to that vertex. The resulting light intensity is then interpolated across the triangle. The vertex normal is calulated as the average of the face normals of the adjacent faces. That means that the vertices with normals pointing towards the light are lit more and the vertices with normals pointing away from the light are lit less.
To get something similar to what you posted, you have to move the light up and set some attenuation. It won't look as perfect as in your image, but at least more like it.

Offline zsele

  • byte
  • *
  • Posts: 3
    • View Profile
Re: lighting problem
« Reply #4 on: October 12, 2012, 08:57:22 pm »
hm. Yes I said it's a stupid question:D thanks for your help

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: lighting problem
« Reply #5 on: October 12, 2012, 09:07:05 pm »
For better results you have to create box in some modelling application, export to the OBJ file and load into your application. And do not forget to check, that you load normals from OBJ file.