[osg-users] bug report, reproduced in osgviewer based app Re: 'loosing' textures? = How to create a proper .osg file with multi-texturing?

Raymond de Vries reedev at xs4all.nl
Tue Oct 23 09:37:43 PDT 2007


Hi Robert,

It's been 3 weeks since we had contact. I'm back at the 'loosing 
textures' problem after a vacation (honeymoon actually ;) )

I've reproduced the described problem in a osgviewer based app, see the 
attached images with right and wrong rendering. Please find the code and 
models in the attachment.

In the source code there is a define which lets you switch between the 
right and wrong situation. The crucial thing is that the multitextured 
object Box_separate_planes_front.osg is in the frustum of the second 
frustum or not.

This is my situation:
* laptop Dell Inspiron 8600, graphics card GeForce FX Go5650, latest 
driver available (from laptopvideo2go), version 165.01, date 27-4-2007
* Windows XP SP2
* Visual Studio 2005 SP1
* osg 2.2.0, built myself
* model "model1_grass_3dsmax8.osg" created in 3dsmax8, exported with 
exporter OSGExp 0.9.3 prerelease 4
* model "multitextured_plane.osg" created by hand, based on model 
exported from 3dsmax
* application is osgviewer only, it makes no difference whether or not 
shared contexts are used

When debugging with gDEBugger it seems that when rendering the 2nd 
frustum (second window), the texture unit 0 is not activated. So the 
state of the multitextured plane (1 texture has transparency) is still 
active, and so texture unit 1 is still active. This would mean that the 
texture coordinates of texture unit 1 of this model are used, these are 
not available, imho. This results in a solid textured surface, as can be 
seen in the screen shots.

Could this be the case?

Thanks a lot
Raymond



Raymond de Vries wrote:
> Hi Robert,
>
>   
>> State the leaks out of one subgraph into the next is typically down to
>> some geometry not having color or normal arrays attached to them when
>> they need it, or in your case it could be that your are enabling the
>> second texture unit for all the scene, but only defining tex coords
>> for that texture unit for a small proportion of the scene.
>>     
>
> Agreed, this makes sense, I had come up with this myself too. In the
> scene, it looks as loosing textures, which is not really the case.
>
> I assume that osg disables the texture units when no texture and/or
> texture coordinates are set for these units, right? At the moment it seems
> that there is a dependancy whether or not models are in the same frustum.
>
>   
>> BTW, if you want other people to try out your models its best to zip
>> them all up together as copying and pasting text files is really error
>> prone.
>>     
>
> Ok.
>
> I will dive into this deeper.
>
> thanks again,
> Raymond
>
>   
>> Robert.
>>
>> On 9/21/07, Raymond de Vries <reedev at xs4all.nl> wrote:
>>     
>>> Hi Robert, good morning,
>>>
>>> I fully understand your point of view about the osgViewer, and I support
>>> that. Actually, I've set up a test project to give it a try.
>>>
>>> It seems that my problem has to do with my (hand-made) multi-textured
>>> models! So it seems that I am not handling the statesets properly... I
>>> created a multi-textured .osg file by hand, and I suspect that I forgot
>>> to set/change something. It looks ok when I load it in osgviewer and I
>>> don't see any errors reported by osgviewer (env var set to DEBUG_FP).
>>> Other models then this multi-textured plane loose their texture in this
>>> situation:
>>> - 2 windows, each has its own sceneview
>>> - sceneview's frustums are set so that the multi-textured plane is only
>>> visible in 1 sceneview
>>> - it doesn't matter if the other models are in the viewing frustum of
>>> each window
>>>
>>> This is how I created the multi-textured plane in .osg file format:
>>> 1) export a textured plane from 3dsmax
>>> 2) added the "textureUnit 1" section by copying from the "textureUnit 0"
>>> section
>>> 3) added the "TexCoordArray 1" section by copying from the
>>> "TexCoordArray 0" section
>>> 3) added "TexEnv" section
>>> I tried to change the renderbin but it does not change anything.
>>>
>>> Can someone please take a look at the attached model? Or point me to a
>>> properly multi-textured model in .osg format?
>>>
>>> pfew, it's driving me nuts.
>>>
>>> Thanks a lot for your time!
>>> Raymond
>>>
>>> Btw I'm now using osg 2.1.11 on WindowsXP, Visual Studio 2005 SP1
>>>
>>>
>>> Robert Osfield wrote:
>>>       
>>>> On 9/20/07, Raymond de Vries <reedev at xs4all.nl> wrote:
>>>>
>>>>         
>>>>> I know, it sounds that I'm doing strange things. But the opposite is
>>>>> true. Well, I am stripping everything and see where it is. Eventually
>>>>>           
>>> it
>>>       
>>>>> will be something small & stupid, as always ;-)
>>>>>
>>>>>           
>>>> I'm afraid your set up is novel enough that others will only be clutch
>>>> at straws at what the issue.  One of the reasons for the new osgViewer
>>>> library is to pull a whole range of disparate usage models together
>>>> under one family of classes to avoid the issues of users rolling a lot
>>>> of functionality on their own as its almost impossible to remotely
>>>> support such bespoke configurations.
>>>>
>>>> The OSG does support multiple graphics context just fine, but your
>>>> have to be careful about management of threads, contextIDs.  In the
>>>> case of 2.x it is more robust than ever in multi-threaded
>>>> multi-context role, and with osgViewer the vast majority of the
>>>> complexity of supporting these configurations is wrapped for you.
>>>>
>>>> Robert.
>>>> _______________________________________________
>>>> osg-users mailing list
>>>> osg-users at lists.openscenegraph.org
>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>>
>>>>
>>>>
>>>>         
>>> MatrixTransform {
>>>   DataVariance STATIC
>>>   name "Scene Root"
>>>   nodeMask 0xff
>>>   cullingActive TRUE
>>>   StateSet {
>>>     UniqueID StateSet_0
>>>     DataVariance STATIC
>>>     rendering_hint DEFAULT_BIN
>>>     renderBinMode INHERIT
>>>     GL_LIGHTING ON
>>>   }
>>>   referenceFrame RELATIVE
>>>   Matrix {
>>>     1 0 0 0
>>>     0 1 0 0
>>>     0 0 1 0
>>>     0 0 0 1
>>>   }
>>>   num_children 1
>>>   MatrixTransform {
>>>     DataVariance STATIC
>>>     name "Front"
>>>     nodeMask 0xff
>>>     cullingActive TRUE
>>>     referenceFrame RELATIVE
>>>     Matrix {
>>>       1 0 0 0
>>>       0 1 0 0
>>>       0 0 1 0
>>>       0 0 0 1
>>>     }
>>>     num_children 1
>>>     Geode {
>>>       UniqueID Geode_1
>>>       DataVariance STATIC
>>>       nodeMask 0xff
>>>       cullingActive TRUE
>>>       num_drawables 1
>>>       Geometry {
>>>         DataVariance DYNAMIC
>>>         StateSet {
>>>           UniqueID StateSet_2
>>>           DataVariance STATIC
>>>           rendering_hint DEFAULT_BIN
>>>           renderBinMode INHERIT
>>>           GL_CULL_FACE ON
>>>           GL_LIGHTING ON
>>>           0xba1 ON
>>>           Material {
>>>             DataVariance STATIC
>>>             ColorMode OFF
>>>             ambientColor 0.588235 0.588235 0.588235 1
>>>             diffuseColor 1 1 1 1
>>>             specularColor 0 0 0 1
>>>             emissionColor 0 0 0 1
>>>             shininess 0
>>>           }
>>>           textureUnit 0 {
>>>             GL_TEXTURE_2D ON
>>>             Texture2D {
>>>               DataVariance STATIC
>>>               file "LIMESTO1.jpg"
>>>               wrap_s CLAMP_TO_EDGE
>>>               wrap_t CLAMP_TO_EDGE
>>>               wrap_r CLAMP_TO_EDGE
>>>               min_filter LINEAR_MIPMAP_LINEAR
>>>               mag_filter LINEAR
>>>               maxAnisotropy 1
>>>               borderColor 0 0 0 0
>>>               borderWidth 0
>>>               useHardwareMipMapGeneration TRUE
>>>               unRefImageDataAfterApply FALSE
>>>               internalFormatMode USE_IMAGE_DATA_FORMAT
>>>               resizeNonPowerOfTwo TRUE
>>>             }
>>>           }
>>>                                         textureUnit 1 {
>>>                                                 GL_TEXTURE_2D ON
>>>                                                 Texture2D {
>>>                                                         DataVariance
>>> STATIC
>>>                                                         file
>>> "checkerboard.png"
>>>                                                         wrap_s
>>> CLAMP_TO_EDGE
>>>                                                         wrap_t
>>> CLAMP_TO_EDGE
>>>                                                         wrap_r
>>> CLAMP_TO_EDGE
>>>                                                         min_filter
>>> LINEAR_MIPMAP_LINEAR
>>>                                                         mag_filter
>>> LINEAR
>>>                                                         maxAnisotropy 1
>>>                                                         borderColor 0 0
>>> 0 0
>>>                                                         borderWidth 0
>>>                                                         useHardwareMipMapGeneration
>>> TRUE
>>>                                                         unRefImageDataAfterApply
>>> FALSE
>>>                                                         internalFormatMode
>>> USE_IMAGE_DATA_FORMAT
>>>                                                         resizeNonPowerOfTwo
>>> TRUE
>>>                                                 }
>>>                                         }
>>>                                 TexEnv {
>>>                                                 DataVariance STATIC
>>>                                                 mode MODULATE
>>>                                         }
>>>         }
>>>         useDisplayList TRUE
>>>         useVertexBufferObjects FALSE
>>>         PrimitiveSets 1
>>>         {
>>>           DrawArrays TRIANGLES 0 6
>>>         }
>>>         VertexArray Vec3Array 6
>>>         {
>>>           -1 -0.5 0
>>>           1 -0.5 0
>>>           1 -0.5 3
>>>           1 -0.5 3
>>>           -1 -0.5 3
>>>           -1 -0.5 0
>>>         }
>>>         NormalBinding PER_VERTEX
>>>         NormalArray Vec3Array 6
>>>         {
>>>           0 -1 0
>>>           0 -1 0
>>>           0 -1 0
>>>           0 -1 0
>>>           0 -1 0
>>>           0 -1 0
>>>         }
>>>         TexCoordArray 0 Vec2Array 6
>>>         {
>>>           0 0
>>>           1 0
>>>           1 1
>>>           1 1
>>>           0 1
>>>           0 0
>>>         }
>>>         TexCoordArray 1 Vec2Array 6
>>>         {
>>>           0 0
>>>           1 0
>>>           1 1
>>>           1 1
>>>           0 1
>>>           0 0
>>>         }
>>>       }
>>>     }
>>>   }
>>> }
>>>
>>> _______________________________________________
>>> osg-users mailing list
>>> osg-users at lists.openscenegraph.org
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>
>>>
>>>
>>>       
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>     
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: multitexture_bug_rendering_wrong.jpg
Type: image/jpeg
Size: 20856 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071023/ce523ac1/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multitexture_bug_rendering_ok.jpg
Type: image/jpeg
Size: 18436 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071023/ce523ac1/attachment-0005.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: osg_multitexture_bug-20071023.rar
Type: application/octet-stream
Size: 76480 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071023/ce523ac1/attachment-0002.obj>


More information about the osg-users mailing list