protected override void LoadContent() { Window.Title = "Render Queue Sample"; toggleRenderQueue = false; toggleTwoPass = false; transpNode = new Node("TransparentNode"); transpNode.SceneHints.TransparencyType = TransparencyType.OneSided; RootNode.AddChild(transpNode); orthos = new Node("OrthoNode"); orthoCam = new Camera(new Viewport()); orthoCam.SetFrame(new Vector3(-.5f, -.5f, 0), Matrix.Identity); quad1 = new Quad("Quad1", 100, 70); quad1.Material = ContentManager.Load <Material>("BasicColor.tem").Clone(); quad1.Material.SetParameter("DiffuseColor", Color.Blue); quad1.Translation = new Vector3(Window.ClientBounds.Width / 2, Window.ClientBounds.Height / 2, 0); quad1.RenderBucketType = RenderBucketType.Skip; quad1.SceneHints.CullHint = CullHint.Never; quad1.OrthoOrder = 5; quad1.SetRenderState(DepthStencilState.None); quad1.SetRenderState(RasterizerState.CullNone); orthos.AddChild(quad1); quad2 = new Quad("Quad2", 50, 70); quad2.Material = ContentManager.Load <Material>("BasicColor.tem").Clone(); quad2.Material.SetParameter("DiffuseColor", Color.Red); quad2.Translation = new Vector3(Window.ClientBounds.Width / 2 + 50, Window.ClientBounds.Height / 2 + 50, 0); quad2.RenderBucketType = RenderBucketType.Skip; quad2.SceneHints.CullHint = CullHint.Never; quad2.OrthoOrder = 1; //Setting the ortho order less than quad1 means this will be drawn first when in the ortho render bucket quad2.SetRenderState(DepthStencilState.None); quad2.SetRenderState(RasterizerState.CullNone); orthos.AddChild(quad2); transparentTorus = new Torus("TransparentSphere", 30, 30, 8, 16); transparentTorus.Material = ContentManager.Load <Material>("LitBasicColor.tem").Clone(); transparentTorus.Material.SetParameter("MatDiffuse", Color.Green.ToVector3()); transparentTorus.Material.SetParameter("Alpha", .75f); transparentTorus.SetRenderState(BlendState.AlphaBlendNonPremultiplied); transparentTorus.RenderBucketType = RenderBucketType.Skip; transparentTorus.Translation = new Vector3(30, 10, 80); transpNode.AddChild(transparentTorus); transparentBox = new Box("TransparentBox", 10, 10, 10); transparentBox.Material = ContentManager.Load <Material>("LitBasicColor.tem").Clone(); transparentBox.Material.SetParameter("MatDiffuse", Color.DarkRed.ToVector3()); transparentBox.Material.SetParameter("Alpha", .5f); transparentBox.SetRenderState(BlendState.AlphaBlendNonPremultiplied); transparentBox.RenderBucketType = RenderBucketType.Skip; transparentBox.Translation = new Vector3(0, 10, 50); transpNode.AddChild(transparentBox); transparentTeapot = new Teapot("TransparentTeapot"); transparentTeapot.Material = ContentManager.Load <Material>("LitBasicColor.tem").Clone(); transparentTeapot.Material.SetParameter("MatDiffuse", Color.LightGreen.ToVector3()); transparentTeapot.Material.SetParameter("Alpha", .35f); transparentTeapot.SetRenderState(BlendState.AlphaBlendNonPremultiplied); transparentTeapot.RenderBucketType = RenderBucketType.Skip; transparentTeapot.Translation = new Vector3(-10, 40, 40); transparentTeapot.SetScale(7.0f); transpNode.AddChild(transparentTeapot); opaqueBox1 = new Box("OpaqueBox", 10, 10, 10); opaqueBox1.Material = ContentManager.Load <Material>("LitBasicTexture.tem").Clone(); opaqueBox1.Material.SetParameter("DiffuseMap", ContentManager.Load <Texture2D>("Textures//bricks_diff.dds")); opaqueBox1.RenderBucketType = RenderBucketType.Skip; opaqueBox1.Translation = new Vector3(0, -10, -20); RootNode.AddChild(opaqueBox1); opaqueBox2 = new Box("OpaqueBox", 10, 10, 10); opaqueBox2.Material = ContentManager.Load <Material>("LitBasicTexture.tem").Clone(); opaqueBox2.Material.SetParameter("DiffuseMap", ContentManager.Load <Texture2D>("Textures//bricks_diff.dds")); opaqueBox2.RenderBucketType = RenderBucketType.Skip; opaqueBox2.Translation = new Vector3(0, 20, -20); RootNode.AddChild(opaqueBox2); opaqueBox3 = new Box("OpaqueBox", 10, 10, 10); opaqueBox3.Material = ContentManager.Load <Material>("LitBasicTexture.tem").Clone(); opaqueBox3.Material.SetParameter("DiffuseMap", ContentManager.Load <Texture2D>("Textures//bricks_diff.dds")); opaqueBox3.RenderBucketType = RenderBucketType.Skip; opaqueBox3.Translation = new Vector3(0, 50, -20); RootNode.AddChild(opaqueBox3); RootNode.SetModelBound(new BoundingBox()); InputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.R, false), new InputAction( delegate(GameTime time) { toggleRenderQueue = !toggleRenderQueue; Toggle(toggleRenderQueue, toggleTwoPass); } ))); InputLayer.RegisterTrigger(new InputTrigger(new KeyPressedCondition(Keys.T, false), new InputAction( delegate(GameTime time) { toggleTwoPass = !toggleTwoPass; Toggle(toggleRenderQueue, toggleTwoPass); } ))); //Set up some text rendering batch = new SpriteBatch(); font = ContentManager.Load <SpriteFont>("Fonts//comicsans.fnt"); }