I’m sure I’m doing something wrong here.
I’m trying to access the auto shader text created in Panda3D. I have different models with the shader effects coded on model as I showed here: discourse.panda3d.org/viewtopic … t=cookbook
The manual talks about retrieving the autoshader result here: panda3d.org/manual/index.php/T … _Generator
Here is my code to retrieve the autoshader result:
sg = ShaderGenerator.getDefault()
shader = sg.synthesizeShader(self.model.getState()).getShader()
text = shader.getText()
The problem is that no matter what model I look at I get this:
float4 vtx_position : POSITION,
out float4 l_position : POSITION,
uniform float4x4 mat_modelproj
l_position = mul(mat_modelproj, vtx_position);
out float4 o_color : COLOR0,
uniform float4 attr_color
// Fetch all textures.
result = float4(1,1,1,1);
float4 primary_color = result;
float4 last_saved_result = result;
o_color = result * 1.000001;
I have a similar question asked before:
And you can look into demomaster “Scene Graph” function. It allows you to navigate the scene graph and look into the autoshader text generated:
“Shaders - Show Models with various effects” is the demo you are looking into.
self.model.getState() doesn’t necessarily return the render state of self.model; it just returns the render attribs applied directly to that particular node. The full render state is actually the composition of all render attribs applied from the root of the scene graph down to each particular Geom within self.model.
Most of the actual state that you see on a renderable model is actually stored on each particular Geom, but for the record, you can get the complete state for each Geom with something like this:
for gnode in self.model.findAllMatches("**/+GeomNode"):
# Net state from render to gnode
nstate = gnode.getNetState()
for gstate in gnode.node().getGeomStates():
# Net state to geom x
state = nstate.compose(gstate)
shader = sg.synthesizeShader(state).getShader()
text = shader.getText()
For the record, I don’t recommend using that code for retrieving the generated shader, as 1.7.0 breaks it.
Any ideas on how to do this in 1.7.0?
Uh, oh. I don’t think it is possible in 1.7.0, besides through the use of the “dump-generated-shaders” config variable.
It’s because the fundamental design of the Shader Generator has changed. It no longer generates a shader for every render state, but for every combination of graphics state guardian and render state. This is to allow for example shadow mapping.
That’s what I figured going through the API. Thanks for the response though.