Hi Sebastian,
you are replacing the original material with your own shader material.
replace this line:
mg->setMaterial(createSimpleShaderMaterial());
with something like this:
ChunkMaterialPtr mat = ChunkMaterialPtr::dcast(mg->getMaterial());
if(mat != NullFC)
{
beginEditCP(mat);
mat->addChunk(_shl);
endEditCP(mat);
}
Andreas
> Hi there,
>
> I'm using different glsl shader (phong, etc.) to create different
> visualizations of my models in my scene.
> In my shaders I would like to use the original material properties resp.
> textures that belong to the model and were loaded with the geometry from
> file.
>
> When I load the tie fighter model I would like to use the original
> material colors in my shader.
> I tried to do so by using the built-in gl_FrontColor.diffuse in the
> Vertex Shader and pass it through to the Fragment Shader.
> But the gl_FrontColor (diffuse/ambient/specular) is all the time
> (0.0,0.0,0.0,0.0)/black, meaning that its not available.
> It seems that the OpenGL material isn't anymore valid for any reason
> when I use a shader.
>
> Afterwards I tried to use the textures of the model in my shader. In
> Performer the corresponding texture of the currently rendered geometry
> was bind to texture unit 0. Thus it was easy to use the textures in the
> shader. It seams that OpenSG binds the textures to different textures
> units. Because when I used texture unit 0 in my shader, the wrong
> textures were visualized with wrong parts of my model.
> So my question is how to acces the textures in my shader, which were
> loaded with the model? Because I don't know the exact texture units
> OpenSG binds them to.
>
> Perhaps I don't set up the shader corrctly and the OpenGL State isn't
> anymore available.
>
> I attached an example to show the problem.
>
> thanks for any comment.
>
> Sebastian Knödel
--
VREC
Robert-Bosch-Straße 7
D-64293 Darmstadt
Tel. 06151-4921035
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users