public void ModifyCompilationEnvironment(H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment outEnvironment) { String vertexfactoryIncludeString = String.Format("#include \"{0}\"", m_ShaderFileName); outEnvironment.SetIncludeFileContent("VertexFactory.hlsl", vertexfactoryIncludeString); // call delegate ModifyCompilationEnvironmentRef m_ModifyCompilationEnvironmentRef(material, outEnvironment); }
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); } } }
public void BeginCompileShader() { // process shared/single environment H1ShaderCompileHelper.H1ShaderCompilerEnvironment environment = new H1ShaderCompileHelper.H1ShaderCompilerEnvironment(); H1ShaderCompileHelper.H1ShaderCompilerEnvironment sharedEnvironment = new H1ShaderCompileHelper.H1ShaderCompilerEnvironment(); SetupEnvironment(sharedEnvironment); // create shader compile input H1ShaderCompileHelper.H1ShaderCompileInput input = new H1ShaderCompileHelper.H1ShaderCompileInput(); input.SourceFileName = SourceFileName; input.EntryPointName = FunctionName; input.Environment = environment; input.SharedEnvironment = sharedEnvironment; input.Target = ShaderTarget; // compile H1Global <H1ManagedRenderer> .Instance.ShaderManager.CompileShader(m_GlobalName, null, this, input); }
public H1Shader BeginCompileShader(int shaderMapId, H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment materialEnvironment) { H1ShaderCompileHelper.H1ShaderCompilerEnvironment environment = new H1ShaderCompileHelper.H1ShaderCompilerEnvironment(); H1ShaderCompileHelper.H1ShaderCompilerEnvironment sharedEnvironment = materialEnvironment; // set input environment SetupEnvironment(material, sharedEnvironment); // create shader compile input H1ShaderCompileHelper.H1ShaderCompileInput input = new H1ShaderCompileHelper.H1ShaderCompileInput(); input.SourceFileName = SourceFileName; input.EntryPointName = FunctionName; input.Environment = environment; input.SharedEnvironment = sharedEnvironment; input.Target = ShaderTarget; // begin compile shader without vertex factory type return(H1Global <H1ManagedRenderer> .Instance.ShaderManager.CompileShader(material.FriendlyName, null, this, input)); }
public H1Shader BeginCompileShader(uint shaderMapId, H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment materialEnvironment, H1VertexFactoryType vertexFactoryType) { H1ShaderCompileHelper.H1ShaderCompilerEnvironment environment = new H1ShaderCompileHelper.H1ShaderCompilerEnvironment(); H1ShaderCompileHelper.H1ShaderCompilerEnvironment sharedEnvironment = H1ObjectCopier.Clone(materialEnvironment); // set the environment by 'vertex factory type' vertexFactoryType.ModifyCompilationEnvironment(material, sharedEnvironment); // modify the shader type by the current compile environment SetupEnvironment(material, sharedEnvironment); // create shader compile input H1ShaderCompileHelper.H1ShaderCompileInput input = new H1ShaderCompileHelper.H1ShaderCompileInput(); input.SourceFileName = SourceFileName; input.EntryPointName = FunctionName; input.Environment = environment; input.SharedEnvironment = sharedEnvironment; input.Target = ShaderTarget; // compile shader return(H1Global <H1ManagedRenderer> .Instance.ShaderManager.CompileShader(material.FriendlyName, null, this, input)); }
// 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); } } }
public bool BeginCompileShaderMap() { H1MaterialShaderMap newMaterialShaderMap = new H1MaterialShaderMap(); // generate the material shader code // @TODO - H1HLSLMaterialTranslator // create a shader compiler environment for the material H1ShaderCompileHelper.H1ShaderCompilerEnvironment materialEnvironment = new H1ShaderCompileHelper.H1ShaderCompilerEnvironment(); // H1HLSLMaterialTranslator get environment and shader code String materialShaderCode = ""; // @TODO - material shader code materialEnvironment.SetIncludeFileContent("Material.hlsl", materialShaderCode); // compile shader map newMaterialShaderMap.Compile(this, materialEnvironment); m_MaterialShaderMap = newMaterialShaderMap; return(m_MaterialShaderMap != null ? true : false); }
public static new void ModifyCompilationEnvironment(H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment outEnvironment) { // mark gpu skin vertex factory outEnvironment.SetDefine("H1_GPUVERTEXFACTORY", 1); // set number of texture coordinate space outEnvironment.SetDefine("H1_NUM_TEXCOORD2D", 1); if (material.DrawWithColor) { outEnvironment.SetDefine("H1_COLOR", 1); } else { outEnvironment.SetDefine("H1_COLOR", 0); } }
public static void ModifyCompilationEnvironment(H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment outEnvironment) { }
public void SetupEnvironment(H1ShaderCompileHelper.H1ShaderCompilerEnvironment outEnvironment) { m_ModifyCompilationEnvironmentRef(outEnvironment); }
public void SetupEnvironment(H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment outEnvironment) { m_ModifyCompilationEnvironmentRef(material, outEnvironment); }
public static new void ModifyCompilationEnvironment(H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment outEnvironment) { // set number of texture coordinate space outEnvironment.SetDefine("H1_NUM_TEXCOORD2D", 1); outEnvironment.SetDefine("H1_NUM_TEXCOORD3D", 0); // currently disable TEXCOORD3D if (material.DrawWithColor) // depending on material type enabling drawing with color { outEnvironment.SetDefine("H1_COLOR", 1); } else { outEnvironment.SetDefine("H1_COLOR", 0); } }