Hi all,
I've recently ported from OSG1.8 to 2.0 and I got little problem using two
textures simultaneously. The problem is possibly related to some stack
overflow / underflow as OSG itself report to me:
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack underflow (0x504)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack overflow (0x503)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack overflow (0x503)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack overflow (0x503)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack overflow (0x503)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack overflow (0x503)
WARNING:
(/usr/local/sdk/OpenSG-2.0-src/Source/System/State/Base/OSGMaterialChunk.cpp,355):
material:changed:precheck failed: stack overflow (0x503)
... then 'overflow'message keep coming forever...
The code Im using is:
OSG::ImageRecPtr image = OSG::Image::create();
if( !image->read( ( oceanTextureFile ).data() ) )
{
// error....
}
_alphaTexel = new uint8[4];
_alphaTexel[0] = 6;
_alphaTexel[1] = 99;
_alphaTexel[2] = 196;
_alphaTexel[3] = 0;
_alphaImage = OSG::Image::create();
_alphaImage->set( GL_RGBA, 1, 1, 1, 1, 1, 0.0, _alphaTexel );
OSG::TextureObjChunkRecPtr oceanTextureChunk =
OSG::TextureObjChunk::create();
oceanTextureChunk->setImage( image );
// set env chunk for the ocean texture
OSG::TextureEnvChunkRecPtr oceanEnvChunk =
OSG::TextureEnvChunk::create();
oceanEnvChunk->setEnvMode( GL_REPLACE );
_alphaTextureChunk = OSG::TextureObjChunk::create();
_alphaTextureChunk->setImage( _alphaImage );
// set env mode for the alpha texel (which controls the ocean texture
transparency)
OSG::TextureEnvChunkRecPtr alphaEnvChunk =
OSG::TextureEnvChunk::create();
alphaEnvChunk->setEnvMode( GL_DECAL );
// ocean material
OSG::TwoSidedLightingChunkRecPtr twoSidedLightChunk =
OSG::TwoSidedLightingChunk::create();
OSG::SimpleMaterialRecPtr material = OSG::SimpleMaterial::create();
material->addChunk( oceanTextureChunk );
material->addChunk( oceanEnvChunk );
material->addChunk( _alphaTextureChunk ); // <<<<<<<<<<<<<<<<<<---
material->addChunk( alphaEnvChunk ); // <<<<<<<<<<<<<<<<<<---
material->setColorMaterial( GL_AMBIENT_AND_DIFFUSE );
material->setDiffuse( OSG::Color3f( 1, 1, 1 ) );
material->setAmbient( OSG::Color3f( 1, 1, 1 ) );
material->setLit( true );
material->setTransparency( 0.25 );
material->addChunk( twoSidedLightChunk );
geo->setMaterial( material );
The visual effect of the problem is that some other textures in the scene (
which are drawn using OpenSG directly inside a custom OSG node created by
myself ) get wrong.
If I remove the two marked lines, everything works....
I've checked the tutorials and the textures are set exactly like this (text
obj followed by its env chunk).
The alpha texture shown in the code above is used only to perform some blend
of a alpha texel and the ocean texture and then set the visibility of the
ocean texture from 0 (not visible) to 1 (full).
This used to work on OSG 1.8 just fine, but the env object was not necessary
as the Env mode (GL_REPLACE, etc ...) could be set in the texture chunk
itself.
And clue?
Thanks in advance.
Pablo
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users