Author Topic: Per pixel lighting/shadows  (Read 2756 times)

Offline Kaiidyn

  • long
  • ***
  • Posts: 103
    • View Profile
Per pixel lighting/shadows
« on: January 19, 2011, 01:29:22 pm »
I have a simple box with a light, but the light casts on the triangles of the box and that is..... ugly.. =p
Is there any way to enable a per pixel lighting or shadow casting?
if so, how would i go about doing that?
« Last Edit: January 19, 2011, 01:31:26 pm by Kaiidyn »
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per pixel lighting/shadows
« Reply #1 on: January 19, 2011, 01:36:22 pm »
What exactly is ugly? Do you have a screen shot? I'm not sure if i understand the actual problem.

Offline Kaiidyn

  • long
  • ***
  • Posts: 103
    • View Profile
Re: Per pixel lighting/shadows
« Reply #2 on: January 19, 2011, 02:44:00 pm »
i dont think a screenshot will propperly capture what i mean, so i made a small video..

http://93.95.149.126/light.mpeg

as the cube rotates, you see the light go on and off on the different triangles, hence the ugly thing.
Is there any way to go around this? (per pixel light, instead of per triangle or w/e)
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per pixel lighting/shadows
« Reply #3 on: January 19, 2011, 05:26:02 pm »
I see...the usual vertex lighting artefacts. They are especially visible on a cube, because the vertex normals at the corners are very different from each other. You might improve this with per pixel lighting but you have to use shaders for this. That's means that you (apart from having to learn GLSL and to write the shader code) will lose fixed function support (as mentioned in AGP's water thread lately)...i'm not sure if it's worth it in this case. It might be sufficient to increase the the polygon count of the cube. Splitting each triangle into two might look already good enough.