[osg-users] different materials for a geometry and highlight

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Tue Sep 27 05:12:44 PDT 2016


Hi Gianni,
> Trajce Nikolov NICK wrote:
>> Maybe better idea then these email iterations is to write us what is your goal with this code since I see no smart logic in there (sorry :-) )
>>
> OK, I try to explain in detail.
>
> The object I visualize on 3D is a road. A road can have different "materials": asphalt, curbs, oil, puddles, obsacles ... The road surface including materials is defined in a core road structure. I drow the 3D road base on the data stored in the core road structure. There each road element (=triangle) is associated to a "material" object. For that reason I thought to use different colors, one for each material. So, asphalt = dark grey, curbs = red/white, oil = dark green, puddle = brown ...
> The user, after loading a road, can change the "material" definition. So picking on the road surface he can add a puddle in the middle of the road. So the picked triangles must be shown in brown then.
> In addition I have to update the core road structure accordingly.
Basically this is something I wouldn't approach by using 
color-materials. I'd use multiple textures per geometry-element and sort 
of blend them based on a per-face value. Do you need to place the curbs 
etc. also dynamically?
If you only need to add puddles etc. you might be better of using 
decals, or even drawing on top of the original road-geometry.
The problem with the multiple primitive sets is, that you will have to 
recompile the data every time some triangle is changed.
If your geometry doesn't have to look nice, you indeed can simply use 
flat shading and set the vertex colors, but one problem with this is 
that with shared vertices you will affect neighboring triangles as well. 
Are there any restrictions to how the road is represented?

Another approach might be to use a geometry shader and determine the 
color of your triangle there (I believe this would work for shared 
indices as well). The determination of the color could be based on the 
vertices texture coordinate which point into an image which holds the 
"color" information. This way you wouldn't need to modify the geometry 
at all, but upload a modified texture if needed. I can try to make a 
minimal example, if you give me some time (I can do this after work).

Cheers
Sebastian


Cheers
Sebastian
> This is the scenario. Hope this is clearer now.
>
> Thanks Nick and Sebastian for the time spent, really!
> Gianni
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68780#68780
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




More information about the osg-users mailing list