Hello Sajjadul,

Sajjadul Islam wrote:
> Happy Easter to everyone in the forum.
> I would like to discuss a design issue for lighting calculation for shaders.
> I am trying to render a very same geometry with different shaders.
> I am using SwitchMaterialPtr to accomplish that.
> 
> Most shaders do need lighting interaction and this is where i need some 
> suggestion.
> 
> According to  the tutorial OpenSG creates a default light when no 
> lighting is defined, and we can access that light source in both 
> shaders(vertex and fragment)
> by built-in uniform variables.(gl_LightSource[0------7]).
> 
> I want to select different types of lights and different types of 
> material with key press event.
> 
> 
> First of all i am describing the process i followed
> 
> 
> 1. I can load a model and change material properties using the utility 
> SwitchMaterialPtr and customized shader programs.
> 
> 2. while doing step 1 i always had a default headlight(directional) *on 
> *that is provided by the SimpleFileManager.
> 
> 3. Now i want to disable that default light and create different lights 
> of my own and select between them interactively.
> 
> 4.I have created different light cores(point , spot and directional ) 
> and added the corresponding nodes to the root scene. Each of their 
> beacons is pointing to my utah teapot node so that it and its children 
> will be lit with any of the selected light sources.

the beacon of a light describes the coordinate system that is used to 
place the light in the scene, the tree below the light is what is being 
lit by the light (at least if local lights are used, that is an option 
of the render action AFAIK).

> even if the head light is disbled will that be accessed in the shader 
> program with gl_LightSource[0]?

i haven't checked this, but the lights available through gl_LightSource 
are most likely those that are enabled when the shader is called, not 
all those present in the scene.

> and i have created point light , spot light and directional 
> respectively. In that case will be accessible in the shader program
> as gl_LightSource[1], gl_LightSource[2], gl_LightSource[3]?

they should be accessible, if they are active. The index they are 
assigned depends on the order they are activated in by the render action.
For a shader there does not exist something like a spot light or a 
directional light, these are fixed function pipeline constructs. Since 
they are a useful classification of lights anyways, you can examine the 
values of gl_LightSource[i] to decide what type of light you are dealing 
with, e.g. spotCutoff < 180 means it's a spot light, position.w == 0 
means it's a directional light.

        Hope it helps,
                Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to