gl_LightSource issue

I’m trying to use gl_LightSource[#] to get parameters from a light in my scene without any luck. I’ve set the GLSL version to 1.2, as anything higher gives an error that gl_LightSource has been deprecated. Is this working in 088?

What I really want to do is get the light’s position in camera space, but to troubleshoot, I’ve put together a test scene that’s a simple as I could imagine. Just Geometry, Light and Camera feeding into a Render and then a GLSL Top. The Frag shader just outputs a solid color set to the light’s diffuse color.

void main(){
  gl_FragColor= gl_LightSource[0].diffuse;
}

088 Toe attached. Is anyone using these light parameters? Am I missing something or do I perhaps have things at the wrong level?
GLSLTest.toe (5.85 KB)

If you were looking at the documentation today then you may have been getting the wrong info. It was the old 077 on that page due to an editing mistake. Take a look now
derivative.ca/wiki088/index. … L_Material

In particular you’ll want to look at the uTDLights[] array.

Thanks for the reply, Malcolm, and for updating the documentation.

I’ve created a new test and I’m getting ‘undefined variable’ errors:

Vertex Shader Compile Results: 

Compiled Successfully

=============

Pixel Shader Compile Results: 

Compiled Successfully

=============

Program Link Results: 
Vertex info
-----------
0(5) : error C1008: undefined variable "TDCamToProj"
0(5) : error C1008: undefined variable "TDDeform"

Fragment info
-------------
0(3) : error C1008: undefined variable "uTDLights"

Pixel Shader:

out vec4 fragColor;

void main(){
	fragColor = vec4(uTDLights[0].diffuse,1);
}

Vertex Shader:

 void main()
 {
    gl_Position = TDCamToProj(TDDeform(P));
 }

The GLSL Top is set to version 3.30. It seems like the built-ins aren’t working?

You won’t get any lighting info in a GLSL TOP, only a GLSL MAT. The TOP works much differently, as it’s only a 2D pixel based operation, not a geometric lighting operation.

Well, my real goal is to try to get the position of the light in camera space. Is there another way to access the x,y position of the light in camera space besides GLSL in a MAT?

I’m trying to simulate volumetric light using the tox posted here by Jeffers, feeding in the actual position of the light to the x/y parameter that controls the origin of the radial blur.

You can use the Object CHOP to get the position of a Light COMP relative to a Camera COMP. The feed that position into the GLSL TOP via a uniform vector parameter. Does that help at all?

Yes - I believe that will do it!

I’ll post images/video when I get it working right.

Thanks, Malcolm.