Revision 53de4437
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/examples/stencil/StencilRenderer.java | ||
---|---|---|
54 | 54 |
private DistortedTexture mCubeTex, mFloorTex; |
55 | 55 |
private DistortedEffects mCube1Effects, mCube2Effects, mFloorEffects; |
56 | 56 |
private MeshObject mCubeMesh, mFloorMesh; |
57 |
private DistortedNode mCube1Node, mCube2Node, mFloorNode; |
|
58 | 57 |
|
59 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 59 |
|
... | ... | |
74 | 73 |
|
75 | 74 |
mCube2Effects.brightness(new Static1D(0.5f)); |
76 | 75 |
|
77 |
mCube1Node = new DistortedNode(mCubeTex ,mCube1Effects,mCubeMesh );
|
|
78 |
mCube2Node = new DistortedNode(mCubeTex ,mCube2Effects,mCubeMesh );
|
|
79 |
mFloorNode = new DistortedNode(mFloorTex,mFloorEffects,mFloorMesh);
|
|
76 |
DistortedNode cube1Node = new DistortedNode(mCubeTex ,mCube1Effects,mCubeMesh );
|
|
77 |
DistortedNode cube2Node = new DistortedNode(mCubeTex ,mCube2Effects,mCubeMesh );
|
|
78 |
DistortedNode floorNode = new DistortedNode(mFloorTex,mFloorEffects,mFloorMesh);
|
|
80 | 79 |
|
81 |
mFloorNode.glEnable(GLES30.GL_STENCIL_TEST); // Enable Stencil when rendering this Node
|
|
82 |
mFloorNode.glStencilFunc(GLES30.GL_ALWAYS, 1, 0xFF); // Set any stencil to 1
|
|
83 |
mFloorNode.glStencilOp(GLES30.GL_KEEP, GLES30.GL_KEEP, GLES30.GL_REPLACE); // replace with 1 when we fail Depth test
|
|
84 |
mFloorNode.glStencilMask(0xFF); // Write to stencil buffer
|
|
85 |
mFloorNode.glDepthMask(false); // Don't write to depth buffer
|
|
86 |
mFloorNode.glClear(GLES30.GL_STENCIL_BUFFER_BIT); // Clear stencil buffer (0 by default)
|
|
80 |
floorNode.glEnable(GLES30.GL_STENCIL_TEST); // Enable Stencil when rendering this Node
|
|
81 |
floorNode.glStencilFunc(GLES30.GL_ALWAYS, 1, 0xFF); // Set any stencil to 1
|
|
82 |
floorNode.glStencilOp(GLES30.GL_KEEP, GLES30.GL_KEEP, GLES30.GL_REPLACE); // replace with 1 when we fail Depth test
|
|
83 |
floorNode.glStencilMask(0xFF); // Write to stencil buffer
|
|
84 |
floorNode.glDepthMask(false); // Don't write to depth buffer
|
|
85 |
floorNode.glClear(GLES30.GL_STENCIL_BUFFER_BIT); // Clear stencil buffer (0 by default)
|
|
87 | 86 |
|
88 |
mCube2Node.glEnable(GLES30.GL_STENCIL_TEST); // Enable Stencil when rendering this Node
|
|
89 |
mCube2Node.glStencilFunc(GLES30.GL_EQUAL, 1, 0xFF); // Pass test if stencil value is 1
|
|
90 |
mCube2Node.glStencilMask(0x00); // Don't write anything to stencil buffer
|
|
91 |
mCube2Node.glDepthMask(true); // Write to depth buffer
|
|
87 |
cube2Node.glEnable(GLES30.GL_STENCIL_TEST); // Enable Stencil when rendering this Node
|
|
88 |
cube2Node.glStencilFunc(GLES30.GL_EQUAL, 1, 0xFF); // Pass test if stencil value is 1
|
|
89 |
cube2Node.glStencilMask(0x00); // Don't write anything to stencil buffer
|
|
90 |
cube2Node.glDepthMask(true); // Write to depth buffer
|
|
92 | 91 |
|
93 | 92 |
mScreen = new DistortedScreen(); |
94 |
mScreen.attach(mCube1Node);
|
|
95 |
mScreen.attach(mFloorNode);
|
|
96 |
mScreen.attach(mCube2Node);
|
|
93 |
mScreen.attach(cube1Node);
|
|
94 |
mScreen.attach(floorNode);
|
|
95 |
mScreen.attach(cube2Node);
|
|
97 | 96 |
mScreen.glClearColor(1.0f,1.0f,1.0f,1.0f); |
98 | 97 |
} |
99 | 98 |
|
Also available in: Unified diff
1. Correct some bugs in DistortedRenderState
2. Thus make the Stencil App work
3. New icon for it