Hi Roland,
we are working on a shadertree-concept and are interested in this submission,
but we are not sure what exactly the purpose of it is:
Should it just be a replacement of the FFP? Or should it be an open and
flexible shadersystem, that allows the combination of FFP-functionality with
own shadercode?
If only the FFP should be replaced, maybe a hardcoded statemachine would do the
trick?
In case of an open shadersystem, where you can put together own shadercode with
(through FFP-states) generated code, a more complex framework would be needed.
This is something we are working on at the moment, but it is at its very
beginning (more some kind of concept phase) :-)
Your submission seems to be between both ideas - it replaces the FFP and is
extensible, but in a limited way.
I can see, that somebody may write own shadermodes, but it is not clear, how
well these will work together with the existing modes (i.e. because of the
unclear order of linking and the possible circular linking).
Also you have to make sure, that you don't use variable names already
implemented in the existing code.
Two other questions:
1. How do you make sure, that your code-snippets get placed in the right order?
Some parts of the FFP may not be commutative and it seems to me, that your
shadergenerator works "first come, first served"?
2. It would be nice to use i.e. the vertexshader replacing the FFP together
with an own fragmentshader-implementation (as is possible with the FFP now).
Maybe the new shadertree-concept should take this into consideration. :-)
The last few days I looked into the code, run the testprogram and found a
problem in this concept.
If you run the testprogram and try to add 2 lights, the generated vertexshader
won't compile, because of missing declarations of the
Ambient/Diffuse/SpecularLightIntensity.
Please correct me, if I understood something wrong:
Example:
1 Light - Generated Shadertree:
FFVisualRoot
___FFLighting
_____FFLight1
_______FFBase
_____FFBase already traversed.
Generating the Code:
Visiting all nodes from root to leafs (depth first) - and setting "traversed =
true" before visiting the children.
Writing the code-snippets, if "traversed = false".
In our example the order of the codesnippets would be: FFBase, FFLight1,
FFLighting, FFVisualRoot.
At the Light1-node there are some unlinked input-variables
(Ambient/Diffuse/SpecularLightIntensity), which are written out with
default-values.
vec4 AmbientLightIntensity = vec4(0.0, 0.0, 0.0, 0.0);
// 2
vec4 DiffuseLightIntensity = vec4(0.0, 0.0, 0.0, 0.0);
// 3
vec4 SpecularLightIntensity = vec4(0.0, 0.0, 0.0, 0.0);
// 4
That's working well.
Now 2 Lights - Generated Shadertree:
FFVisualRoot
___FFLighting
_____FFLight1 <- LightIntensity-inputs set by Light0-outputs
_______FFBase
_______FFLight0 <- LightIntensity-inputs set by Light1-outputs
__________FFBase already traversed.
__________FFLight1 already traversed.
_____FFLight0 already traversed.
_____FFBase already traversed.
Now we have set the inputs Ambient/Diffuse/SpecularLightIntensity for Light1 by
Light0.
And we have set the inputs Ambient/Diffuse/SpecularLightIntensity for Light0 by
Light1 - at least in the Shadertree.
In this example the order of the codesnippets is: FFBase, FFLight0, FFLight1,
FFLighting, FFVisualRoot.
Now - writing out the code, there seem all inputs linked for the lights, but as
you may notice: Ambient/Diffuse/SpecularLightIntensity are never really set AND
they won't be written out as default either because of the Light1 -> Light0 ->
Light1 linking.
The generated vertex-shader won't compile, because of the missing lines:
vec4 AmbientLightIntensity = vec4(0.0, 0.0, 0.0, 0.0);
// 2
vec4 DiffuseLightIntensity = vec4(0.0, 0.0, 0.0, 0.0);
// 3
vec4 SpecularLightIntensity = vec4(0.0, 0.0, 0.0, 0.0);
// 4
... :-/
Cheers,
Johannes
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=27286#27286
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org