flatten strong behavior

Hi.

I encounter this strange behaviour after flattening my whole scene. ( I know I should do it but,…)

anyway I use a shaderInput which is the light direction for my shader.

In this case, I load the scene
apply a shaderInput on render. ( shader input apply, no problem)
I flattenStrong render.
I add a sky_mesh, parented to render.
then I change the shaderInput on render.

The shader input is correct for the sky, but hasn’t changed for all the other mesh.

Is it normal ?

Yes, it’s normal. Normally you shouldn’t actually call flattenStrong() on the whole scene; it’s a very destructive function. You should call it only on those objects that you don’t intend to modify again, or at least when you understand the consequences of calling it and are willing to work around those consequences.

In this case, when you called flattenStrong() the first time, you pushed the ShaderAttrib down onto all of the geometry in the scene. That means each of your GeomNodes now has a ShaderAttrib on it that contains the original shaderInput you specified. When you then apply a new shaderInput to render, it doesn’t override the original shaderInput you now have on the GeomNodes.

For the record, you could force it to override by using:

render.setShaderInput(blah, blah, 1)

That is, by specifying the optional priority parameter of anything nonzero, just like you need to do when overriding an existing texture on a model.

David

perfect, as soon as I can override it…