TerrainDiffuseMethod

Software: Away3D 4.x

inSertCodE, Sr. Member
Posted: 23 February 2012 10:26 PM   Total Posts: 105

I’m pretty lousy with shaders and don’t know how to rework the TerrainDiffuseMethod. The 3 layers limit doesn’t work for me for a little more complex terrain I have in mind for which I will need at least 6 layers.

Currently TerrainDiffuseMethod is limited to 3 layers because for blending it uses 1 texture and its 3 RGB channels as 3 layers blending data.

My question is how to make instead of texture, the TerrainDiffuseMethod uses for blending array of BiteArray data for each layer blending which will make the layers unlimited (well limited by GPU only).
...or any other solution to my problem of course.

   

inSertCodE, Sr. Member
Posted: 23 February 2012 10:45 PM   Total Posts: 105   [ # 1 ]

I’ve looked in the TerrainDiffuseMethod code again and from what I can understand the blending texture is used in the GPU calculation directly so “...instead of texture, the TerrainDiffuseMethod uses for blending array of BiteArray data for each layer blending…” I guess is out of the question without serious rework.

So my next idea is that you make it so that if there are more than 3 layers you enter 2 blending textures. So for layer 1,2,3 it uses blending texture 1; for layers 4,5,6 it uses blending texture 2 and so on…
How can I make this.

 

   

inSertCodE, Sr. Member
Posted: 25 February 2012 12:31 AM   Total Posts: 105   [ # 2 ]

*Bump*  Anyone?

...If not this then I have another question. Can more than 1 diffuseMethod be used on one texture?

 

   

Avatar
kurono, Sr. Member
Posted: 20 March 2012 02:07 PM   Total Posts: 103   [ # 3 ]

Sorry, but I can’t get it work for Away3d beta due to “Register overflow”.

var mtl:TextureMaterial = new TextureMaterial(new BitmapTexture(new _diffusemapAsset().bitmapData));
mtl.diffuseMethod = new TerrainDiffuseMethod(new BitmapTexture(new _splat1Asset().bitmapData),
            new 
BitmapTexture(new _splat2Asset().bitmapData),
            new 
BitmapTexture(new _splat3Asset().bitmapData)]
           new 
BitmapTexture(new _splatrgbAsset().bitmapData), 
           
[1505050]); 

What is wrong?

 

   

Avatar
Baush, Sr. Member
Posted: 20 March 2012 05:18 PM   Total Posts: 135   [ # 4 ]

Kurono, from what I understand, the TerrainDiffuseMethod is limited to 3 bitmaps each representing the R, G, B channels of the reference “splat” bitmap. It is not possible to add more layers at the moment.

Loved Gantz btw wink

 

   

Avatar
kurono, Sr. Member
Posted: 20 March 2012 05:54 PM   Total Posts: 103   [ # 5 ]

Baush, thank for reply, but that’s what I actualy did (see my code closely).
_splat1Asset, _splat2Asset and _splat3Asset are detailed tiled splatting layers. I put them to static array: [_splat1Asset, _splat2Asset, _splat3Asset]
_splatrgbAsset is a splatting mask (RGB channels represents splatting areas)
and last parameter is tiling factor.

 

   

Avatar
Baush, Sr. Member
Posted: 20 March 2012 06:02 PM   Total Posts: 135   [ # 6 ]

Oh sorry about that, I misread and though you wanted to add a 4th layer.

I got mine to work fine, perhaps you could make sure to use a RGB image instead of RGBA (no transparency) for the splat bitmap and 256x256 pixels for all images. Perhaps that’s the problem.. Here’s my code if it helps:

var terrainMethod:TerrainDiffuseMethod = new TerrainDiffuseMethod(
[new BitmapTexture(TextureAsset.stone), new BitmapTexture(TextureAsset.grass), new BitmapTexture(TextureAsset.cliff)],
new BitmapTexture(splats), [1, 20, 10, 10]);

 

   

Avatar
kurono, Sr. Member
Posted: 20 March 2012 06:14 PM   Total Posts: 103   [ # 7 ]

256x256 <- ahh, that’s what I lose!
I thought, image’s dimention can be arbitrary (power of 2 and don’t exceed 2048).
Thanks a lot, Baush! You made my day smile

 

   

Avatar
Baush, Sr. Member
Posted: 20 March 2012 06:17 PM   Total Posts: 135   [ # 8 ]

Glad it solved it.

Technically you should be able to put any image size to the power of 2, but my guess is that they need to all be the same size.

I use mostly 128x128, 256x256 and 512x512 for all textures or bitmaps, for standard’s sake.

 

   

Avatar
kurono, Sr. Member
Posted: 20 March 2012 06:38 PM   Total Posts: 103   [ # 9 ]

Finally I got a REAL reason why my code didn’t work! Hope, this experiment will be helpful for others.

“Register overflow” occurs after setting

mtl.specularMap = new BitmapTexture(new _specularmapAsset().bitmapData); 

for current TerrainDiffuse material. If specular map is homogeneus (default), everything works!

 

   

Radiosatch2000, Newbie
Posted: 29 May 2015 09:21 PM   Total Posts: 6   [ # 10 ]

You can now create terrain with unlimited terrain layers by using the SandCastle API: https://github.com/Radiosatch2000/sandcastle

The API includes two new multipass materials called TerrainMaterial and ColorTerrainMaterial.  It also offers some nice water methods.

There is an accompanying program which allows you to sculpt the terrain and view it in the Away3D environment before exporting the code from the program.  It requires a subscription, but it is pretty reasonable for the amount of time it saves for projects with terrain.  More info is at http://www.theyellowthorn.com

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X