Jump to content

how to handle this kind of billboard atlas?


photo

Recommended Posts

As you guys already know we use speedtree for vegetation system, after I researched the valley demo, I decided to integrate the billboard with ObjectBillboards, I've successfully done with each trees size and position, but I'm stuck with the texture coordinate.

 

post-49-0-87367800-1337158864_thumb.jpg

 

This is a standard speedtree billboard atlas texture, it rotated some billboards' orientation to save the image space. and of course with speedtree sdk, we can easily get the billboards bottom-left uv coordinate and size of billboard, which means geting the billboard dimension and position is easy, but how can I use it with unigine's ObjectBillboards?

 

ObjectBillboards seems need the atlas texture have exact same number of atlas on each row of texture just like grass texture. but with speedtree, it's not possible to get this kind of atlas texture.

Link to comment

Additional info, this atlas have 8 billboard for each tree, the speedtree compiler can control the number of billboard for each tree from 1-20. but it will still have some billboard rotated, of course all uv info can be accessed. but the compiler can not assure each tree's billboard the same size, because the billboard size is controlled by the actual tree size.

Link to comment

Approach A

 

Do some atlas image pre-processing by extraction/rotation/rescaling SpeedTree atlas subimages and insert them into fixed-size/no-rotation image atlas usable with ObjectBillboards. This will waste texture image space, but at least might be a work-around.

 

If you do not use the rotated per-tree subimages for aspect-angle-specific texture blending you could drop these unused subimages during pre-processing and most probably reduce texture consumption significantly.

 

Approach B

 

Inherit Unigine provides billoards_base material and modify vertex shader code to support subimage texture atlas with different sizes/rotation. Re-code vertex-shader to use billboard-specific Angle parameter for texture-space subimage uv-rotation insted of billboard vertex rotation and TexCoords vec4-parameter for subimage uv-rect specification.

 

I used a similar approach for re-using angle parameter for per-billboard timestamp attribute for real-time dynamic timespan visualization with ObjectBillboards where only billboards with timestamps within specified timespan will be rendered.

 

<?xml version="1.0" encoding="utf-8"?>
<materials version="1.09"  editable="0">

   <material name="billboards_timespan_base" parent="billboards_base" editable="0">

       <!-- ambient shaders -->
       <shader pass="ambient" object="billboards"
           defines="BASE_AMBIENT,AMBIENT"
           alpha_test_defines=",ALPHA_TEST"
           alpha_fade_defines=",ALPHA_FADE"
           ambient_defines="0,OPACITY,TRANSPARENT"
           axis_x_defines=",AXIS_X"
           axis_z_defines=",AXIS_Z"
           screen_defines=",SCREEN"
           angular_defines=",ANGULAR"
           emission_defines=",EMISSION"
           vertex="rde/shaders/billboards/vertex_timespan_base.shader"
           fragment="core/shaders/default/billboards/fragment_base_ambient.shader"/>

   	.........
   	.........
       <!-- parameters -->
       <parameter name="timespan" type="color" shared="1">0.0f,1000000.0f,0.0f,0.0f</parameter>

   </material>

</materials>

Link to comment

I don't think you approach a would be a option for us, because we often need to recompile the trees for slight modification. that would be wasting a loot of our time.

 

I'll try to modify the source and billboards shader, the current ObjectBillboards seems totally useless to us if it won't support this kind of billboard atlas.

Link to comment

OK, I've successfully modified the Billboards.cpp to adapt the speedtree billboard atlas, But another problem came up, that's because the surface lod works on entire object not like ObjectGrass. :)

 

And another problem came up, the atlas billboards of speedtree has normal map, if I apply the normal, without the automatically select of billboard texture, the lighting are totally wrong at some view angle.

Link to comment
OK, I've successfully modified the Billboards.cpp to adapt the speedtree billboard atlas, But another problem came up, that's because the surface lod works on entire object not like ObjectGrass. :(

Yes, Billboards are rendered all at once, in one DIP call (and consequently fade all at once).

 

And another problem came up, the atlas billboards of speedtree has normal map, if I apply the normal, without the automatically select of billboard texture, the lighting are totally wrong at some view angle.

Normal-based lighting of billboards is a bit tricky as they always face the camera. Can you send us a normal map (a test scene with a billboard and its textures) so we can test it?

Link to comment

here you are, this billboard contains 2 trees, each tree with 3 different angle of billboards, and the normal texture, You might need to manually offset this texture to use it directly with current unigine's ObjectBillboards. these two textures are directly generated with Speedtree Compiler.

 

trees.rar

Link to comment

Yes, I know ATI2 normal map, but the speedtree compiler won't give me a chance to select the dds format. I've already asked them to add this option, but it seems speedtree guys won't add this option, all dds format from speedtree compiler are DXT5.

Link to comment
×
×
  • Create New...