git.s-ol.nu ~forks/DiligentFX / 0546cc5
GLTF PBR Renderer: updated alpha mode shader paramter assiduous 6 months ago
5 changed file(s) with 36 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
256256 Macros.AddShaderMacro("USE_TEXTURE_ATLAS", m_Settings.UseTextureAtals);
257257 Macros.AddShaderMacro("PBR_WORKFLOW_METALLIC_ROUGHNESS", GLTF::Material::PBR_WORKFLOW_METALL_ROUGH);
258258 Macros.AddShaderMacro("PBR_WORKFLOW_SPECULAR_GLOSINESS", GLTF::Material::PBR_WORKFLOW_SPEC_GLOSS);
259 Macros.AddShaderMacro("GLTF_ALPHA_MODE_OPAQUE", GLTF::Material::ALPHA_MODE_OPAQUE);
260 Macros.AddShaderMacro("GLTF_ALPHA_MODE_MASK", GLTF::Material::ALPHA_MODE_MASK);
261 Macros.AddShaderMacro("GLTF_ALPHA_MODE_BLEND", GLTF::Material::ALPHA_MODE_BLEND);
259262 ShaderCI.Macros = Macros;
260263 RefCntAutoPtr<IShader> pVS;
261264 {
903906 for (const auto& primitive : Mesh.Primitives)
904907 {
905908 const auto& material = GLTFModel.Materials[primitive.MaterialId];
906 if (material.AlphaMode != AlphaMode)
909 if (material.Attribs.AlphaMode != AlphaMode)
907910 continue;
908911
909912 const PSOKey Key{AlphaMode, material.DoubleSided};
112112 }
113113 #endif
114114
115 if (g_MaterialInfo.UseAlphaMask != 0 && BaseColor.a < g_MaterialInfo.AlphaMaskCutoff)
115 if (g_MaterialInfo.AlphaMode == GLTF_ALPHA_MODE_MASK && BaseColor.a < g_MaterialInfo.AlphaMaskCutoff)
116116 {
117117 discard;
118118 }
1818 #ifndef PBR_WORKFLOW_SPECULAR_GLOSINESS
1919 # define PBR_WORKFLOW_SPECULAR_GLOSINESS 1
2020 #endif
21
22
23 #ifndef GLTF_ALPHA_MODE_OPAQUE
24 # define GLTF_ALPHA_MODE_OPAQUE 0
25 #endif
26
27 #ifndef GLTF_ALPHA_MODE_MASK
28 # define GLTF_ALPHA_MODE_MASK 1
29 #endif
30
31 #ifndef GLTF_ALPHA_MODE_BLEND
32 # define GLTF_ALPHA_MODE_BLEND 2
33 #endif
34
2135
2236 struct GLTFNodeShaderTransforms
2337 {
7185 float MetallicFactor;
7286
7387 float RoughnessFactor;
74 int UseAlphaMask;
88 int AlphaMode;
7589 float AlphaMaskCutoff;
7690 float Dummy0;
7791
1818 "#ifndef PBR_WORKFLOW_SPECULAR_GLOSINESS\n"
1919 "# define PBR_WORKFLOW_SPECULAR_GLOSINESS 1\n"
2020 "#endif\n"
21 "\n"
22 "\n"
23 "#ifndef GLTF_ALPHA_MODE_OPAQUE\n"
24 "# define GLTF_ALPHA_MODE_OPAQUE 0\n"
25 "#endif\n"
26 "\n"
27 "#ifndef GLTF_ALPHA_MODE_MASK\n"
28 "# define GLTF_ALPHA_MODE_MASK 1\n"
29 "#endif\n"
30 "\n"
31 "#ifndef GLTF_ALPHA_MODE_BLEND\n"
32 "# define GLTF_ALPHA_MODE_BLEND 2\n"
33 "#endif\n"
34 "\n"
2135 "\n"
2236 "struct GLTFNodeShaderTransforms\n"
2337 "{\n"
7185 " float MetallicFactor;\n"
7286 "\n"
7387 " float RoughnessFactor;\n"
74 " int UseAlphaMask; \n"
88 " int AlphaMode; \n"
7589 " float AlphaMaskCutoff;\n"
7690 " float Dummy0;\n"
7791 "\n"
112112 " }\n"
113113 "#endif\n"
114114 "\n"
115 " if (g_MaterialInfo.UseAlphaMask != 0 && BaseColor.a < g_MaterialInfo.AlphaMaskCutoff)\n"
115 " if (g_MaterialInfo.AlphaMode == GLTF_ALPHA_MODE_MASK && BaseColor.a < g_MaterialInfo.AlphaMaskCutoff)\n"
116116 " {\n"
117117 " discard;\n"
118118 " }\n"