Friday, September 23, 2011

Depth and stencil testing in Flash 3D


Do scissor test – if fail discard output fragment and stop, else continue
Do depth test
If depth test passes
{
                If depthMask == true, then update depth buffer = source depth;
                Do stencil test
                if stencil test passes
                {
                                Update stencil buffer, according to actionOnBothPass  parameter, stencil reference setting
                                Send output color to blend function
                }
                else (stencil test fails)
                {
                                Update stencil buffer, according to actionOnDepthPassStencilFail parameter, stencil reference setting
                                Discard output color
                }
}
else //depth test fails
{
                Update stencil buffer, according to actionOnDepthFail parameter, stencil reference setting
                Discard output color
}

Thursday, September 22, 2011

Wednesday, September 21, 2011

3D graphics in an HTML-based AIR application

You can use the Stage3D and Context3D classes to render graphics in an HTML-based AIR app. One issue, though, is that the rendering viewport is drawn below the Flash Display list. Well, the HTML display is part of that display list, so by default, your HTML display will obscure your rendering viewport.

There are a couple of solutions:
You can set the background of the HTML object to be transparent. This allows the rendered stuff to peek out from behind any text or other items on the page. See AIR docs.

The other thing you can do is to create a new NativeWindow to display the rendered content. Don't use HTMLLoader.createRootWindow(), since this will create a window that has an HTMLLoader in it. instead, use:
var renderwindow = new air.NativeWindow( new air.NativeWindowInitOptions() );

(Of course, you will want to set non-default window options in many cases.)