Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Lighting don't work properly with deffered rendering

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2015
    Posts
    23

    Question Lighting don't work properly with deffered rendering

    Hello, I have a problem I tried to solve but it have passed around 2 months and I still whasn't able to solve it, When I moved the lighting calculations in the final shader of the gbuffer it seems it does not work properly:


    As you can see the problem is that the lighting creates something that looks like squares on the plane with strange relatively hard transition, another problem is that the lighting is the same even when I change the position of the objects, The only thing that affects it is the rotation and position of light, so it seems to me like the positions are wrong but not the rotation, I send the positions using a sampler2d xyz->rgb this is how they look if I visualize them:


    I am almost certain the positions are the problem, this is what the texture is:

    postexture = vec4(M * vec4(position, 1.0));

    And this is the calculation in the final shader:

    vec3 fpos = texture(positiontex, pos).xyz;
    ...
    vec3 surfaceToLight = light.position - fpos;
    float brightness = dot(norm, surfaceToLight) / (length(surfaceToLight) * length(norm));
    brightness = clamp(brightness, 0.2, 1);
    ...

    Please help me pass through this problem

  2. #2
    Junior Member Newbie
    Join Date
    Mar 2015
    Posts
    23
    Can someone help me please ?

  3. #3
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,962
    Based on your image I'd say your positions are clamping at 0.0-1.0, with a narrow transition area.

    You also seem to be storing world positions not something light space position prior to your position buffer write.

    So try float buffers or some other extended range and precision format and try performing a partial lighting position offset prior to writing tor position.

    Of course the position thing depends heavily on your deferred shader work but it makes sense to calculate what you can at high precision prior to your intermediate buffer write that might for example use a HALF format.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •