public ShaderSample() { this.layeredBlendingEntity = null; Metadata[ "Title" ] = "Shader System"; Metadata[ "Description" ] = "Demonstrate the capabilities of the RT Shader System component." + "1. Fixed Function Pipeline emulation." + "2. On the fly shader generation based on existing material." + "3. On the fly shader synchronization with scene state (Lights, Fog)." + "4. Built in lighting models: Per vertex, Per pixel, Normal map tangent and object space." + "5. Pluggable custom shaders extensions." + "6. Built in material script parsing that includes extended attributes." + "7. Built in material script serialization."; Metadata[ "Thumbnail" ] = "thumb_shadersystem.png"; Metadata[ "Category" ] = "Lighting"; Metadata[ "Help" ] = "F2 Toggle Shader System globally. " + "F3 Toggles Global Lighting Model. " + "Modify target model attributes and scene settings and observe the generated shaders count. " + "Press the export button in order to export current target model material. " + "The model above the target will import this material next time the sample reloads. " + "Right click on object to see the shaders it currently uses. "; this.pointLightNode = null; this.reflectionMapFactory = null; this.instancedViewportsEnable = false; this.instancedViewportsSubRenderState = null; this.instancedViewportsFactory = null; this.bbsFlare = null; this.addedLotsOfModels = false; this.numberOfModelsAdded = 0; }
private void DestroyInstancedViewportsFactory() { if ( this.instancedViewportsFactory != null ) { this.instancedViewportsFactory.DestroyAllInstances(); ShaderGenerator.Instance.RemoveSubRenderStateFactory( this.instancedViewportsFactory ); this.instancedViewportsFactory = null; } }
protected override void UnloadResources() { DestroyPrivateResourceGroup(); ShaderGenerator.Instance.RemoveAllShaderBasedTechniques( "Panels" ); ShaderGenerator.Instance.RemoveAllShaderBasedTechniques( "Panels_RTSS_Export" ); if ( this.reflectionMapFactory != null ) { ShaderGenerator.Instance.RemoveSubRenderStateFactory( this.reflectionMapFactory ); this.reflectionMapFactory = null; } }
private void CreateInstancedViewports() { if ( this.instancedViewportsFactory == null ) { this.instancedViewportsFactory = null; // = new ShaderExInStancedViewportsFactory(); ShaderGenerator.Instance.AddSubRenderStateFactory( this.instancedViewportsFactory ); } var monitorCount = new Vector2( 2.0f, 2.0f ); this.instancedViewportsSubRenderState = ShaderGenerator.Instance.CreateSubRenderState( InstancedViewports.SGXType ); var shaderExInstancedViewports = this.instancedViewportsSubRenderState as InstancedViewports; shaderExInstancedViewports.MonitorsCount = monitorCount; RenderState renderState = ShaderGenerator.Instance.GetRenderState( ShaderGenerator.DefaultSchemeName ); renderState.AddTemplateSubRenderState( this.instancedViewportsSubRenderState ); VertexDeclaration vertexDeclaration = HardwareBufferManager.Instance.CreateVertexDeclaration(); int offset = 0; offset = vertexDeclaration.GetVertexSize( 0 ); vertexDeclaration.AddElement( 0, offset, VertexElementType.Float4, VertexElementSemantic.TexCoords, 3 ); offset = vertexDeclaration.GetVertexSize( 0 ); vertexDeclaration.AddElement( 0, offset, VertexElementType.Float4, VertexElementSemantic.TexCoords, 4 ); offset = vertexDeclaration.GetVertexSize( 0 ); vertexDeclaration.AddElement( 0, offset, VertexElementType.Float4, VertexElementSemantic.TexCoords, 5 ); offset = vertexDeclaration.GetVertexSize( 0 ); vertexDeclaration.AddElement( 0, offset, VertexElementType.Float4, VertexElementSemantic.TexCoords, 6 ); offset = vertexDeclaration.GetVertexSize( 0 ); vertexDeclaration.AddElement( 0, offset, VertexElementType.Float4, VertexElementSemantic.TexCoords, 7 ); //todo // vbuf.Unlock(); // Root.RenderSystem.GlobalInstanceVertexBuffer = vbuf; Root.RenderSystem.GlobalInstanceVertexBufferVertexDeclaration = vertexDeclaration; Root.RenderSystem.GlobalNumberOfInstances = (int)( monitorCount.x*monitorCount.y ); //Invalidate the scheme ShaderGenerator.Instance.InvalidateScheme( ShaderGenerator.DefaultSchemeName ); ShaderGenerator.Instance.ValidateScheme( ShaderGenerator.DefaultSchemeName ); }
protected override void LoadResources() { //Create and add the custom refledcdtion map shader extension factory to the shader generator. this.reflectionMapFactory = new ReflectionMapFactory(); ShaderGenerator.Instance.AddSubRenderStateFactory( this.reflectionMapFactory ); CreatePrivateResourceGroup(); }