loop calculations

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
mageonline
Gnoblar
Posts: 10
Joined: Tue Aug 11, 2015 7:22 am
Location: Finland

loop calculations

Post by mageonline »

Hello,

I have a vertex program which takes 8 lights, so there is a for loop to process these lights.

First question is what are the direction and attenuation parameters for absent lights when there are only 3 lights in the scene?

Secondly, what's the best way to loop through the active lights?

I was thinking to use for loop with the ACT_LIGHT_COUNT parameter, but i understood it's best to loop for constant range.
If i loop always to 8, then i need some IF statement to skip inactives, unless there is a trick to cancel out the inactives...

Code: Select all

	uniform float4   	uLightPosition[8],
	uniform float4		uLightAttenuation[8],
	uniform float4		uLightColor[8],
Any hints? Thanks in advance!
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 220

Re: loop calculations

Post by scrawl »

I believe inactive lights have their colors set to (0,0,0,0) so they have no effect on the output color. At least I've always done it that way without checks for inactive lights, that works fine.
User avatar
mageonline
Gnoblar
Posts: 10
Joined: Tue Aug 11, 2015 7:22 am
Location: Finland

Re: loop calculations

Post by mageonline »

Thanks, i dig a little Ogre sources and found out blank light gets attenuation(0,1,0,0), diffuse(0,0,0), specular(0,0,0).
Now my shader runs without IFs, and it's all looking good. (bricks on the gate and light shades on character face/dress)
o1.jpg
Any guru knows what happens to light position in case of blank lights?
I could save an additional vector scale if they would match the vertex position e.g. the direction vector would be (0,0,0).

edit: not the light direction, but its position I'm interested in
You do not have the required permissions to view the files attached to this post.