Results 1 to 3 of 3

Thread: Manipulating gl_LightSource[gl_MaxLights]

  1. #1

    Manipulating gl_LightSource[gl_MaxLights]

    The The OpenGL Shading Language Spec version 1.20 shows the following:
    Code :
    struct gl_LightSourceParameters {
        vec4  ambient;             // Acli
        vec4  diffuse;             // Dcli
        vec4  specular;            // Scli
        vec4  position;            // Ppli
        vec4  halfVector;          // Derived: Hi
        vec3  spotDirection;       // Sdli
        float spotExponent;        // Srli
        float spotCutoff;          // Crli
                                   // (range: [0.0,90.0], 180.0)
        float spotCosCutoff;       // Derived: cos(Crli)
                                   // (range: [1.0,0.0],-1.0)
        float constantAttenuation; // K0
        float linearAttenuation;   // K1
        float quadraticAttenuation;// K2
    uniform gl_LightSourceParameters  gl_LightSource[gl_MaxLights];

    Also, shows the following code snippets:
    Code :
    lightDir = normalize(vec3(gl_LightSource[0].position)); shows many uniform* functions but nothing seems to deal with an array of uniform variable like gl_LightSource[0].

    How do we set the gl_LightSource[0] fields in JavaScript? For example, (gl_LightSource[0].position

    Thanks in advance for your help.

  2. #2
    Join Date
    Oct 2009
    London, UK

    Re: Manipulating gl_LightSource[gl_MaxLights]

    Hi pion,

    WebGL is based on OpenGL ES 2.0 -- that is, the version of OpenGL designed for restricted hardware like cellphones -- and doesn't support lighting out of the box; you have to code it yourself. The version of the spec you're looking at and the lighthouse3d example are for the full desktop OpenGL, which has more features.

    I think you've already seen the tutorials I've been putting together (or someone else called pion has but if you take a look at lessons 7 and 12 you'll probably get some useful pointers.


  3. #3
    Senior Member
    Join Date
    May 2010

    Re: Manipulating gl_LightSource[gl_MaxLights]

    To be honest - even in desktop OpenGL, you're better off ignoring all of those built-in variables. They are just an ugly transition mechanism for people edging gradually from fixed-function pipelines to full-on shader rendering. You might as well pick your own uniforms, name them what you want - and optimize your lighting to do exactly what you need.

    But, indeed, in OpenGL-ES 2.x and WebGL, those variables are **gone**.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean