Hi David, and thanks for the great explanation! It has been very helpful

I will try to modify or instruct the import plugins of the file
formats I need forcing the association between the maps and the
texture unit meaning then.

Thanks again,
Davide
>
> ---------- Forwarded message ----------
> From: David Spilling <david.spill...@gmail.com>
> To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
> Date: Tue, 12 Jan 2010 12:35:34 +0000
> Subject: Re: [osg-users] 3d file formats supporting bump map
> Hi Davide,
>
> Certainly the obj loader supports bump maps, but let me be clear about what 
> it actually does. Apologies if this comes over as patronising; I have no idea 
> of your level of expertise.
>
> In OSG/OpenGL land, textures (diffuse, bump map, specular map, etc.) are all 
> attached to a particular geometry via a texture ID - this is an integer index 
> ranging from 0 upwards. Shaders are then applied to this geometry that will 
> colour the pixel based on a particular understanding of what each texture ID 
> actually is. So for example, I can write a shader that assumes that texture 
> unit 0 is the diffuse colour, texture unit 1 is some sort of specularity map, 
> texture unit 2 is a bump map, etc. Or I can assume (for example as osgShadow 
> tends to) that texture unit 0 is the diffuser colour, texture unit 1 is the 
> shadow map.
>
> However - and this is the key - there is nothing that enforces this mapping 
> between texture unit and "meaning".
>
> 3DS, and the obj format, both explicitly include entries in the model for 
> "diffuse texture" and "specular map" and "bump map" and so on. However the 
> 3DS or obj format loader doesn't know what shader you are going to apply to 
> this model, so has no idea which texture ID/unit to assign a loaded "bump 
> map" texture to. Should it be 1? 2? etc.
>
> Some formats (e.g. .osg) allow you to save an objects shader within the 
> object definition itself, thereby guaranteeing that the textures that the 
> object loads are assigned to the right texture unit, and used in the right 
> way. 3DS and .obj don't.
>
> AFAIK, there is currently no OSG-wide method for enforcing any consistency.
>
> All that being said, the OBJ loader allows you to specify what texture units 
> you want which maps to go to when you load the model, via an options string. 
> The options are all listed in the first few lines of ReaderWriterOBJ.cpp. The 
> mapping between the flags in the .obj file and the name of the texture is in 
> lines 434 onwards of obj.cpp. (It's useful to have a look at that, because 
> the OBJ spec is not rigourously followed by all modelling tools - e.g. you 
> see map_opacity in some obj files, even though it should be map_d according 
> to the spec).
>
> I'm not amazingly familiar with osgFX, but reading the source for the 
> BumpMapping technique, I notice that
> a) you can define which texture units should be used for diffuse and normal 
> (note : not bump) textures, and
> b) by default these are 0=normal, 1=diffuse.
>
> I also don't know what Blender exports in terms of maps. When you say that 
> the blender export isn't exporting the bump map, have you looked in the OBJ 
> file to actually see whether there is a "map_bump" (or "map_Bump", or just 
> "bump") in it? Has it been called something else by the exporter?
>
> Hope that helps,
>
> David
>
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to