Layered Diffuse Shader?

Software: Away3D 4.x

Gene, Newbie
Posted: 09 August 2011 12:40 AM   Total Posts: 1

I have been experimenting with a number of the materials but can’t seem to find exactly what I’m looking for. I’m new to Away3D, but have used other 3D engines before.

I’d like to have two layers of texture on the diffuse color of the shader with different tiling. For example a 1x1 texture on the background with a 10 x 10 tiled texture on top with Blendmode.MULTIPLY or OVERLAY to fill in fine details. Something like that could either done with two UV sets or some sort of UV offset on one of the layers would be fine.

So it’s a basic layered diffuse shader.

The BitmapMaterial has one diffuse texture. I was able to get sort of close by using the TerrainDiffuseMethod (it has the tiling) but the textures blend evenly and wash each other out if I attempt to use it as a layered shader.

Couldn’t find another method that might be appropriate.

Thanks.

   

Avatar
Alexander Seifert, Moderator
Posted: 09 August 2011 07:31 PM   Total Posts: 129   [ # 1 ]

When I started with Away3D I wrote a diffuse shader program that takes two textures as inputs and combines them on a single mesh. However, I didn’t go as far as providing two sets of uv coordinates.

The shader is as easy as extending class DiffuseProgramWrapper (or whatever exactly it’s called, in the material package). The double uv index buffer, don’t know at the.moment. I jyst realize my smart phone sucks raspberry

I’ll be back..

 

 Signature 
signature_image

http://www.deltastrike.org

   

Avatar
Alexander Seifert, Moderator
Posted: 10 August 2011 07:30 AM   Total Posts: 129   [ # 2 ]

Just got my hands back to my keyboard.

Back then, I did ...
* extend away3d.materials.methods.WrapDiffuseMethod
* call regCache.getFreeTextureReg() twice and stored the returned registers in member variables in method getFragmentPostLightingCode
* add two calls to Context3D.setTextureAt in the override activate method, using the indices of stored registers
* use stored registers in method getFragmentPostLightingCode to read texture samples and applied manually implemented blend operation in AGAL

I did not ...
* try to get additional UV-sets
* try to accurately implement OVERLAY or MULTIPLY

Cheers!
Alex

 

 Signature 
signature_image

http://www.deltastrike.org

   

Jean Carlo Deconto, Newbie
Posted: 24 August 2012 10:36 AM   Total Posts: 29   [ # 3 ]

Hi!

In progress SEA3D created a very interesting class that can help game developers in the composition of texture at runtime.

You can mix up to 4 layers using transparent textures and masks. It also has 26 blending modes, add, softlight, multiply, overlay and others.

The scale and position of the layers can be set at runtime which helps a lot to create visual effects.

Example

import away3d.materials.methods.LayeredDiffuseMethod;
import away3d.materials.methods.LayeredTexture;

var 
layer1:LayeredTexture = new LayeredTexture(texture);
layer1.offsetU .5;
layer1.scaleV 4;

var 
layer2:LayeredTexture = new LayeredTexture(texturemask);
layer2.blendMode LayeredTexture.COLORBURN;

var 
diffuse:LayeredDiffuseMethod = new LayeredDiffuseMethod();
diffuse.addLayer(layer1);
diffuse.addLayer(layer2);
yourMaterial.diffuseMethod diffuse

 

File Attachments
LayeredTextureClass.zip  (File Size: 6KB - Downloads: 299)
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X