Material GetMetallicMaterial(MetallicShaderFeatures metallicShaderFeatures) { bool doubleSided = (metallicShaderFeatures & MetallicShaderFeatures.DoubleSided) != 0; if (!metallicShaders.TryGetValue(metallicShaderFeatures, value: out var shader)) { ShaderMode mode = (ShaderMode)(metallicShaderFeatures & MetallicShaderFeatures.ModeMask); // TODO: add ClearCoat support bool coat = false; // (metallicShaderFeatures & MetallicShaderFeatures.ClearCoat) != 0; // TODO: add sheen support bool sheen = false; // (metallicShaderFeatures & MetallicShaderFeatures.Sheen) != 0; var shaderName = string.Format( "Shader Graphs/glTF-metallic-{0}{1}{2}{3}", mode, coat ? "-coat" : "", sheen ? "-sheen" : "", doubleSided ? "-double" : "" ); shader = FindShader(shaderName); metallicShaders[metallicShaderFeatures] = shader; } if (shader == null) { return(null); } var mat = new Material(shader); #if UNITY_EDITOR mat.doubleSidedGI = doubleSided; #endif return(mat); }
Material GetMetallicMaterial(MetallicShaderFeatures metallicShaderFeatures) { Shader shader; #if UNITY_SHADER_GRAPH_12_OR_NEWER if (s_MetallicShader == null) { s_MetallicShader = FindShader(SHADER_METALLIC); } shader = s_MetallicShader; #else if (!metallicShaders.TryGetValue(metallicShaderFeatures, value: out shader)) { var shaderName = GetMetallicShaderName(metallicShaderFeatures); shader = FindShader(shaderName); metallicShaders[metallicShaderFeatures] = shader; } #endif if (shader == null) { return(null); } var mat = new Material(shader); #if UNITY_EDITOR mat.doubleSidedGI = (metallicShaderFeatures & MetallicShaderFeatures.DoubleSided) != 0; #endif return(mat); }
protected virtual string GetMetallicShaderName(MetallicShaderFeatures metallicShaderFeatures) { var doubleSided = (metallicShaderFeatures & MetallicShaderFeatures.DoubleSided) != 0; var mode = (ShaderMode)(metallicShaderFeatures & MetallicShaderFeatures.ModeMask); return($"{SHADER_METALLIC}-{mode}{(doubleSided ? "-double" : "")}"); }
protected virtual string GetMetallicShaderName(MetallicShaderFeatures metallicShaderFeatures) { var doubleSided = (metallicShaderFeatures & MetallicShaderFeatures.DoubleSided) != 0; var mode = (ShaderMode)(metallicShaderFeatures & MetallicShaderFeatures.ModeMask); return(string.Format( "{0}-{1}{2}" , SHADER_METALLIC , mode , doubleSided ? "-double" : "" )); }
Material GetMetallicMaterial(MetallicShaderFeatures metallicShaderFeatures) { Shader shader = GetMetallicShader(metallicShaderFeatures); if (shader == null) { return(null); } var mat = new Material(shader); #if UNITY_EDITOR mat.doubleSidedGI = (metallicShaderFeatures & MetallicShaderFeatures.DoubleSided) != 0; #endif return(mat); }
Shader GetMetallicShader(MetallicShaderFeatures metallicShaderFeatures) { Shader shader; #if UNITY_SHADER_GRAPH_12_OR_NEWER if (s_MetallicShader == null) { s_MetallicShader = LoadShaderByName(SHADER_METALLIC); } shader = s_MetallicShader; #else if (!metallicShaders.TryGetValue(metallicShaderFeatures, value: out shader) || shader == null) { shader = LoadShaderByName(GetMetallicShaderName(metallicShaderFeatures)); metallicShaders[metallicShaderFeatures] = shader; } #endif return(shader); }
protected override string GetMetallicShaderName(MetallicShaderFeatures metallicShaderFeatures) { return(SHADER_METALLIC); }