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); } } }
// note that - for this 'BeginCompile' call is called by H1MaterialMap usually! public void BeginCompile(uint shaderMapId, H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment materialEnvironment) { // iterating shader type var shaderTypes = H1ShaderType.GetTypeList(); foreach (var shaderType in shaderTypes) { H1MeshMaterialShaderType meshMaterialShaderType = shaderType.GetMeshMaterialShaderType(); if (meshMaterialShaderType != null && m_VertexFactoryTypeRef != null && meshMaterialShaderType.ShouldCache(material, m_VertexFactoryTypeRef) && material.ShouldCache(meshMaterialShaderType, m_VertexFactoryTypeRef) && m_VertexFactoryTypeRef.ShouldCache(material, meshMaterialShaderType)) { // compile mesh material shader type (ex. vertex shader) H1Shader shader = meshMaterialShaderType.BeginCompileShader(shaderMapId, material, materialEnvironment, m_VertexFactoryTypeRef); // add shader to shader map AddShader(meshMaterialShaderType, shader); } } }