Hi all,
I am currently trying to get our landscape (a flat, plane, tiled map) to sit on top of the water.
I first create the water -> then create a 3d object container to hold the landscape -> inside of 3d container I create planes and put the images on the planes.
The images I am using on the planes are ‘.png’.
Here’s the problem. When I turn on alpha blending on the textures on the plane, the water appears ABOVE the land no matter what height it’s at in the code.
Please view the attached image.
Can anyone help with this? The code is below.Any help is appreciated.
Fyi, I reordered the way objects appear on stage, just to make sure that wasnt the issue. The land is broken up in an 11 tile x 11 tile landscape, with each tile at 512x512 size, so that isnt the issue.
I placed changed the order of the objects being added to the stage, adding the water first, and everything else later, but that didn’t help at all.
-Adam
The code for the water:
//prepare water
waterMethod = new SimpleWaterNormalMethod(new BitmapTexture(new WaterNormals().bitmapData), new BitmapTexture(new WaterNormals().bitmapData));
fresnelMethod = new FresnelSpecularMethod();
fresnelMethod.normalReflectance = .3;
waterMaterial = new TextureMaterial(new BitmapTexture(new BitmapData(512, 512, true, 0xaa071113)));
waterMaterial.alphaBlending = true;
waterMaterial.lightPicker = lightPicker;
waterMaterial.repeat = true;
waterMaterial.normalMethod = waterMethod
waterMaterial.addMethod(new EnvMapMethod(skyTexture));
waterMaterial.addMethod(fogMethod);
waterMaterial.specularMethod = fresnelMethod;
waterMaterial.gloss = 100;
waterMaterial.specular = 1;
//create water
plane = new Mesh(new PlaneGeometry(5632, 5632), waterMaterial);
plane.geometry.scaleUV(50, 50);
plane.y = 0;
scene.addChild(plane);
The code for each plane:
function testLoaderCompleted(evt:Event):void
{
var testLoaderContent = testLoader.content;
terrainMaterial = new TextureMaterial(new BitmapTexture(Bitmap(testLoaderContent).bitmapData));
//terrainMaterial.diffuseMethod = terrainMethod;
//terrainMaterial.normalMap = new BitmapTexture(new Normals().bitmapData);
//terrainMaterial.lightPicker = lightPicker;
//terrainMaterial.ambientColor = 0x303040;
terrainMaterial.ambient = 5;
terrainMaterial.specular = .2;
terrainMaterial.alphaBlending = true;
//terrainMaterial.addMethod(fogMethod);
//leContainer.addChild(terrainMaterial);
//create a ground plane
var ground:Mesh = new Mesh(new PlaneGeometry(512, 512, 1, 1), terrainMaterial);
ground.castsShadows = false;
ground.y = 200;
leContainer.addChild(ground);
}