Hello Sebastian,
Sebastian Knödel wrote:
> Thanks for the fast reply.
> But this doesn't work.
> The materialgroup contains no material at that point.
> So if I use mg->getMaterial() I receive always a NullFC.
> But I unerstand the problem.
> Somehow I have to add the shaderchunk to the OSGMaterial that holds the
> original materialdata.
exactly.
> But how can I access the Material of any loaded geometry and add my
> shader chunk???
that depends a bit on what type of file your model is stored in. AFAIK
the vrml loader uses material groups, but other loaders probably add the
material directly to the geometry, i.e. you can get it by:
GeometryPtr geo = Geometry::dcast(model->getCore());
MaterialPtr mat = geo->getMaterial();
> I tried something like
>
> if(model->getCore()->getType().isDerivedFrom(
> ChunkMaterial::getClassType())){
> mat = model->getCore();
mat = ChunkMaterial::dcast(model->getCore());
> mat->addChunk(shaderchunk);
> }
>
> any comment?
Material and hence ChunkMaterial is not derived from NodeCore, so the
above test is always false.
Hope it helps,
Carsten
> thanks
>
> Andreas Zieringer wrote:
>> 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
>>>
>>
>>
>
>
> -------------------------------------------------------------------------
> 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
>
-------------------------------------------------------------------------
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