예제 #1
0
        public H1Shader GetShader(String shaderTypeName, H1VertexFactoryType vertexFactoryType)
        {
            H1MeshMaterialShaderType shaderType = H1Global <H1ManagedRenderer> .Instance.ShaderManager.GetShaderType(shaderTypeName) as H1MeshMaterialShaderType;

            if (shaderType != null)
            {
                H1MeshMaterialShaderMap meshShaderMap = m_MaterialShaderMap.GetMeshShaderMap(vertexFactoryType);
                H1Shader shader = meshShaderMap != null ? meshShaderMap.Shaders[shaderType] : null;
                return(shader);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public void Compile(H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment materialEnvironment)
        {
            // iterate over all vertex factory types
            var vertexFactoryTypes = H1VertexFactoryType.GetTypeList();

            foreach (var vertexFactoryType in vertexFactoryTypes)
            {
                H1MeshMaterialShaderMap meshMaterialMap = null;

                // look for existing map for this vertex factory map
                foreach (var shaderMap in m_MeshMaterialMaps)
                {
                    if (shaderMap.VertexFactoryType == vertexFactoryType)
                    {
                        meshMaterialMap = shaderMap;
                        break;
                    }
                }

                if (meshMaterialMap == null)
                {
                    // create a new mesh material shader map
                    meshMaterialMap = new H1MeshMaterialShaderMap(vertexFactoryType);
                    m_MeshMaterialMaps.Add(meshMaterialMap);
                }

                // compile mesh material map
                meshMaterialMap.BeginCompile(0, // @TODO - I need to change this appropriately!
                                             material, materialEnvironment);
            }

            // iterate over all material shader types
            var shaderTypes = H1ShaderType.GetTypeList();

            foreach (var shaderType in shaderTypes)
            {
                H1MaterialShaderType materialShaderType = shaderType.GetMaterialShaderType();
                if (materialShaderType != null &&
                    materialShaderType.ShouldCache(material) &&
                    material.ShouldCache(materialShaderType, null))
                {
                    materialShaderType.BeginCompileShader(0, // @TODO - I need to change this appropriately!
                                                          material, materialEnvironment);
                }
            }
        }