david850067064 / away3d

Automatically exported from code.google.com/p/away3d
0 stars 0 forks source link

Back side shading incorrect for primitives with bothsides=true #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a Plane object with ShadingColorMaterial and bothsides = true.
2. Add a DirectionalLight3D
3. Rotate the Plane so that the back side is facing the light. 

What is the expected output? What do you see instead?
Shading should be the same brightness as when the front side faces the
light, but the surface of the plane remains dark when the back side faces
the light.  The Diffuse and Specular parameters seem to be not used when
rendering the back side.

What version of the product are you using? On what operating system?
Away3D, tag 2.3.0.  Flash CS3.  Windows XP.

Please provide any additional information below.
Problem is exhibited in attached .fla ans .swf file.  AS3 timeline script
follows:

// Test of incorrect back side shading of a Plane object when bothsides = true

import away3d.cameras.*;
import away3d.containers.*;
import away3d.core.base.*;
import away3d.core.*;
import away3d.core.math.*;
import away3d.core.render.*;
import away3d.core.utils.*;
import away3d.events.*;
import away3d.lights.*;
import away3d.loaders.*;
import away3d.materials.*;
import away3d.primitives.*;

var view:View3D = new View3D({x:300, y:400});
addChild(view);

var trident:Trident = new Trident();

var mat = new ShadingColorMaterial(color = 0xFF0000);

// plane1 rotates to show how shading varies with object orientation
var plane1:Plane = new Plane({material:mat, height:600, width:500 });
plane1.bothsides = true;
plane1.x = -600;

// plane2 has its front side towards the light and is correctly shaded.
var plane2:Plane = new Plane({material:mat, height:600, width:500 });
plane2.bothsides = true;
plane2.x = 0;

// plane3 has its back side towards the light and is incorrectly shaded.
var plane3:Plane = new Plane({material:mat, height:600, width:500 });
plane3.bothsides = true;
plane3.x = 600;
plane3.rotationX = 180;

view.scene.addChildren(trident, plane1, plane2, plane3 );

var light:DirectionalLight3D;
light = new DirectionalLight3D({color:0xFFFFFF, ambient:0.2, diffuse:.5,
specular:0.25});
light.x = 6000; light.z = -6000; light.y = 9000; 
view.scene.addChild(light);

view.camera.moveTo(2000, 2000, 2000);
view.camera.lookAt(new Number3D(0, 0, 0));

view.renderer = Renderer.BASIC; //CORRECT_Z_ORDER;
view.render();

addEventListener(Event.ENTER_FRAME, onEnterFrame);

stop();

function onEnterFrame(event:Event):void {
    plane1.rotationX += 2;
    view.render();
}

Original issue reported on code.google.com by ralph%sa...@gtempaccount.com on 26 Feb 2009 at 4:14

Attachments:

GoogleCodeExporter commented 9 years ago
will be fixed in next major version upgrade

Original comment by rob.bate...@gmail.com on 4 May 2009 at 4:20