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: help needed in deferred shading

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2006
    Location
    Leiden
    Posts
    4

    help needed in deferred shading

    i'm busy with creating an editor, recently i've switched to deferred shading as opposed of forward shading, everything is working so far i've set up my fbo's and render a full screen quad. but i'm having difficulties to get the actual light working. I've uploaded the binary to this site :

    http://home.hccnet.nl/pj.holverda/ (binary.rar)

    there is a basic map included in the rar, which can be loaded.
    the actual deffered pass is in data/glsl/deferred_light.frag/vert
    can you guys please, modify this, to add a point light(and maybe a directional light ) at a specific location.



    regards,

    Paul

  2. #2
    Intern Newbie
    Join Date
    Jan 2008
    Posts
    43

    Re: help needed in deferred shading

    Your problem is too broad, try to narrow it down to the point where its a specific question and you'll have more luck. Most people are unwilling (or unable) to download a random binary and work through large amounts of other peoples source.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2006
    Location
    Leiden
    Posts
    4

    Re: help needed in deferred shading

    okay i'm sorry, but try to download it anyway, the editor is coming along nicely

    here are the relevant shaders
    //vert
    varying vec4 view;
    varying vec3 eyeLight;
    varying vec2 texCoord;


    void main(void)
    {
    gl_Position = ftransform();
    view = (gl_ModelViewMatrix * gl_Vertex);
    //eyeLight = (gl_ModelViewMatrix * vec4(0.0,0.0, 256.0, 1.0)).xyz;
    texCoord = gl_MultiTexCoord0.xy;


    }




    //fragment
    uniform sampler2D tex0; //diffusetex
    uniform sampler2D tex1; //normaltex(in eye space)
    uniform sampler2D tex2; //depth texture
    uniform vec3 lightPos;
    uniform vec2 planes;
    varying vec4 view;

    varying vec3 lightVec;
    varying vec3 eyeLight;

    varying vec2 texCoord;


    void main(){
    vec4 base = texture2D(tex0, texCoord);
    vec3 bump = texture2D(tex1, texCoord).xyz ;
    float depth = texture2D(tex2, texCoord).r ;

    float z = planes.y/(planes.x - depth);

    //view = normalize(view);
    vec3 modelView = vec3 (view.xy/view.z * z, z);

    // compute light vector
    vec3 LightVector = normalize( eyeLight-modelView );


    float NdotL = dot( bump, LightVector );
    //gl_FragData[0] = vec4(bump, 1.0);
    gl_FragData[0] = base;//pow( depth, 100.0 );
    }

    i've think i'm almost there, i just need some pointers(no pun intended)

    regards,

    Paul

Posting Permissions

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