Stage3D supports stencil tests. How do I use stencils in ActionScript to create a reflection?
Use the same way as in OpenGL or DirectX - you will need Context3D.setRenderToTexture()
This function is typically used to render the scene for dynamic reflections.
Below I`ve described the very general approach to solving this problem but in my opinion it is better to use in some custom< materials
function render(): void {
//1. Clear buffers
_myContext3d.clear(/*clear colors*/);
//2. remember current state of projection matrix (Matrix3D) and
//transformation of your camera (view)
_cameraCurrentPosition = _myCamera.position.clone();
_cameraCurrentDirection = _myCamera.direction.clone();
//3. change camera settings
//it should "look" from the other side of reflective surface
_myCamera.position = newCalculatedPosition;
_myCamera.lookAt(inverseDirection);
//4. set rendering to texture
if(!_reflectTexture){
_myReflectTexture = _myContext3d.createTexture(SIZE, SIZE,
Context3DTextureFormat.BGRA, true);
_reflectSurface.texture = _ReflectTexture;
}
_myContext3d.setRenrerToTexture(_myReflectTexture, true, 2);
//5. render your scene
renderScene();
//6. return previous settings
_myCamera.position = _cameraCurrentPosition;
_myCamera.direction = _cameraCurrentDirection;
_myContext3D.setRenderToBackBuffer();
//7. Now you can render reflective surface and scene in original way
renderReflectSurface();
renderScene();
_myContext3D.present();
}
+