[Solved] Using ACT_LIGHT_CUSTOM to set shadow parameters

Problems building or running the engine, queries about how to use features etc.
Post Reply
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

[Solved] Using ACT_LIGHT_CUSTOM to set shadow parameters

Post by vincegdm »

Hi,

I'm trying to get shadow parameters to my shaders by passing them through the setCustomParameter function of Light.
It's working great for all the lights except the last one, but I can't figure out why.

I'm setting the custom indices like this:

Code: Select all

fragParams->setNamedAutoConstant("shadowParams", Ogre::GpuProgramParameters::ACT_LIGHT_CUSTOM, lightIndex, shadowParamsIndex);
And setting the values like this:

Code: Select all

light->setCustomParameter(shadowParamsIndex, Ogre::Vector4(param0, param1, 0.0, 0.0));
I read here http://www.ogre3d.org/forums/viewtopic.php?f=2&t=82892 about marking the parameters as dirty but it seems only remotely related and doesn't work.

What am I missing?

EDIT: I should probably mention each light contribution is computed in its own pass.
Last edited by vincegdm on Thu Dec 29, 2016 7:52 am, edited 1 time in total.
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Re: Using ACT_LIGHT_CUSTOM to set shadow parameters

Post by vincegdm »

So I did more testing and it seems that only the first half passes get correct parameters.

I thought it may be because I was setting the values before setting the indices, at light creation time, but in fact when using getCustomParameter I can print the correct values for each index...

Any ideas?
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Re: Using ACT_LIGHT_CUSTOM to set shadow parameters

Post by vincegdm »

To test further I created a scene with 7 lights (7 passes) and setup the custom parameter as (in pass order):

Code: Select all

  0: 1 0 0 1
  1: 0 1 0 1
  2: 1 1 0 1
  3: 0 0 1 1
  4: 1 0 1 1
  5: 0 1 1 1
  6: 1 1 1 1
but in the shader I actually get:

Code: Select all

  0: 0 0 1 1
  1: 0 1 1 1
  2: 1 0 0 1
  3: 1 1 0 1
  4: 0 0 0 0
  5: 0 0 0 0
  6: 0 0 0 0
I fail to see the link between the two and why the second half is lost, any help would be greatly appreciated :D
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Re: Using ACT_LIGHT_CUSTOM to set shadow parameters

Post by vincegdm »

Okay so I figured it out thanks to a post from Praetor: http://www.ogre3d.org/forums/viewtopic. ... er#p433533 who by the way created this feature.

The thing is, since I am doing per-light passes, for each pass the light index is 0, so instead of doing
vincegdm wrote:

Code: Select all

fragParams->setNamedAutoConstant("shadowParams", Ogre::GpuProgramParameters::ACT_LIGHT_CUSTOM, lightIndex, shadowParamsIndex);
where obviously the lightIndex was incremented for each pass, I should be doing

Code: Select all

fragParams->setNamedAutoConstant("shadowParams", Ogre::GpuProgramParameters::ACT_LIGHT_CUSTOM, 0, shadowParamsIndex);
So thanks Praetor! :D
Post Reply