Light inside transparent primitive

Software: Away3D 4.x

coffeetime, Newbie
Posted: 08 October 2011 07:01 PM   Total Posts: 3

I was hoping to create the effect of a cube being lit from the inside. So I applied the following approach:

1. Create a material with some alpha, eg.
  var red : ColorMaterial = new ColorMaterial(0xffffff, .5);

2. Create a light with some color, eg.
  var light : PointLight = new PointLight();
  light.color = 0xff0000;

3. Create a cube using the light
  red.lights = [light];
  var cube : Cube = new Cube(red);
 
4. Add both to scene
  scene.addChild(light);
  scene.addChild(cube);


Now we should have a basic white cube at (0,0,0) and a red light inside it at (0,0,0). When I render the scene I see only a grayish cube. If I move the light ouside of the cube I can see the red color hitting the applicable faces.

What am I doing wrong?

   

Richard Olsson, Administrator
Posted: 08 October 2011 10:40 PM   Total Posts: 1192   [ # 1 ]

Unfortunately this won’t work, because light is calculated using the normals of a mesh’s geometry, and can’t travel through it. You will likely want to fake this some other way, but also consider trying sub-surface scattering which will simulate translucency.

   

Avatar
TheSillyOne, Newbie
Posted: 31 October 2011 05:47 PM   Total Posts: 28   [ # 2 ]

You can “bend” the normals to point inward (do not change the winding order, though). It is also possible to invert the whole model and then render it with front-face culling.

Best regards.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X