|
@@ -11,7 +11,7 @@ namespace anki
|
|
|
|
|
|
|
|
const char* MATERIAL_TEMPLATE = R"(<!-- This file is auto generated by ImporterMaterial.cpp -->
|
|
const char* MATERIAL_TEMPLATE = R"(<!-- This file is auto generated by ImporterMaterial.cpp -->
|
|
|
<material shaderProgram="shaders/GBufferGeneric.glslp">
|
|
<material shaderProgram="shaders/GBufferGeneric.glslp">
|
|
|
- <mutators>
|
|
|
|
|
|
|
+ <mutation>
|
|
|
<mutator name="DIFFUSE_TEX" value="%diffTexMutator%"/>
|
|
<mutator name="DIFFUSE_TEX" value="%diffTexMutator%"/>
|
|
|
<mutator name="SPECULAR_TEX" value="%specTexMutator%"/>
|
|
<mutator name="SPECULAR_TEX" value="%specTexMutator%"/>
|
|
|
<mutator name="ROUGHNESS_TEX" value="%roughnessTexMutator%"/>
|
|
<mutator name="ROUGHNESS_TEX" value="%roughnessTexMutator%"/>
|
|
@@ -19,13 +19,9 @@ const char* MATERIAL_TEMPLATE = R"(<!-- This file is auto generated by ImporterM
|
|
|
<mutator name="NORMAL_TEX" value="%normalTexMutator%"/>
|
|
<mutator name="NORMAL_TEX" value="%normalTexMutator%"/>
|
|
|
<mutator name="PARALLAX" value="%parallaxMutator%"/>
|
|
<mutator name="PARALLAX" value="%parallaxMutator%"/>
|
|
|
<mutator name="EMISSIVE_TEX" value="%emissiveTexMutator%"/>
|
|
<mutator name="EMISSIVE_TEX" value="%emissiveTexMutator%"/>
|
|
|
- </mutators>
|
|
|
|
|
|
|
+ </mutation>
|
|
|
|
|
|
|
|
<inputs>
|
|
<inputs>
|
|
|
- <input shaderInput="mvp" builtin="MODEL_VIEW_PROJECTION_MATRIX"/>
|
|
|
|
|
- <input shaderInput="prevMvp" builtin="PREVIOUS_MODEL_VIEW_PROJECTION_MATRIX"/>
|
|
|
|
|
- <input shaderInput="rotationMat" builtin="ROTATION_MATRIX"/>
|
|
|
|
|
- <input shaderInput="globalSampler" builtin="GLOBAL_SAMPLER"/>
|
|
|
|
|
%parallaxInput%
|
|
%parallaxInput%
|
|
|
|
|
|
|
|
%diff%
|
|
%diff%
|
|
@@ -119,7 +115,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.base_color_texture).cstr());
|
|
uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.base_color_texture).cstr());
|
|
|
|
|
|
|
|
xml.replaceAll(
|
|
xml.replaceAll(
|
|
|
- "%diff%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"diffTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
+ "%diff%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_diffTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
xml.replaceAll("%diffTexMutator%", "1");
|
|
xml.replaceAll("%diffTexMutator%", "1");
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -128,7 +124,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
|
|
|
|
|
xml.replaceAll("%diff%",
|
|
xml.replaceAll("%diff%",
|
|
|
StringAuto{m_alloc}.sprintf(
|
|
StringAuto{m_alloc}.sprintf(
|
|
|
- "<input shaderInput=\"diffColor\" value=\"%f %f %f\"/>", diffCol[0], diffCol[1], diffCol[2]));
|
|
|
|
|
|
|
+ "<input shaderVar=\"m_diffColor\" value=\"%f %f %f\"/>", diffCol[0], diffCol[1], diffCol[2]));
|
|
|
|
|
|
|
|
xml.replaceAll("%diffTexMutator%", "0");
|
|
xml.replaceAll("%diffTexMutator%", "0");
|
|
|
}
|
|
}
|
|
@@ -161,7 +157,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
|
|
|
|
|
xml.replaceAll("%spec%",
|
|
xml.replaceAll("%spec%",
|
|
|
StringAuto{m_alloc}.sprintf(
|
|
StringAuto{m_alloc}.sprintf(
|
|
|
- "<input shaderInput=\"specColor\" value=\"%f %f %f\"/>", specular.x(), specular.y(), specular.z()));
|
|
|
|
|
|
|
+ "<input shaderVar=\"m_specColor\" value=\"%f %f %f\"/>", specular.x(), specular.y(), specular.z()));
|
|
|
|
|
|
|
|
xml.replaceAll("%specTexMutator%", "0");
|
|
xml.replaceAll("%specTexMutator%", "0");
|
|
|
}
|
|
}
|
|
@@ -183,7 +179,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
|
|
"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
|
|
|
|
|
|
|
|
xml.replaceAll("%roughness%",
|
|
xml.replaceAll("%roughness%",
|
|
|
- StringAuto{m_alloc}.sprintf("<input shaderInput=\"roughnessTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
+ StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_roughnessTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
|
xml.replaceAll("%roughnessTexMutator%", "1");
|
|
xml.replaceAll("%roughnessTexMutator%", "1");
|
|
|
}
|
|
}
|
|
@@ -194,7 +190,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
: mtl.pbr_metallic_roughness.roughness_factor;
|
|
: mtl.pbr_metallic_roughness.roughness_factor;
|
|
|
|
|
|
|
|
xml.replaceAll(
|
|
xml.replaceAll(
|
|
|
- "%roughness%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"roughness\" value=\"%f\"/>", roughness));
|
|
|
|
|
|
|
+ "%roughness%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_roughness\" value=\"%f\"/>", roughness));
|
|
|
|
|
|
|
|
xml.replaceAll("%roughnessTexMutator%", "0");
|
|
xml.replaceAll("%roughnessTexMutator%", "0");
|
|
|
}
|
|
}
|
|
@@ -207,7 +203,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
|
|
"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
|
|
|
|
|
|
|
|
xml.replaceAll(
|
|
xml.replaceAll(
|
|
|
- "%metallic%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"metallicTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
+ "%metallic%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_metallicTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
|
xml.replaceAll("%metalTexMutator%", "1");
|
|
xml.replaceAll("%metalTexMutator%", "1");
|
|
|
}
|
|
}
|
|
@@ -218,7 +214,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
: mtl.pbr_metallic_roughness.metallic_factor;
|
|
: mtl.pbr_metallic_roughness.metallic_factor;
|
|
|
|
|
|
|
|
xml.replaceAll(
|
|
xml.replaceAll(
|
|
|
- "%metallic%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"metallic\" value=\"%f\"/>", metalines));
|
|
|
|
|
|
|
+ "%metallic%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_metallic\" value=\"%f\"/>", metalines));
|
|
|
|
|
|
|
|
xml.replaceAll("%metalTexMutator%", "0");
|
|
xml.replaceAll("%metalTexMutator%", "0");
|
|
|
}
|
|
}
|
|
@@ -230,7 +226,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.normal_texture).cstr());
|
|
uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.normal_texture).cstr());
|
|
|
|
|
|
|
|
xml.replaceAll(
|
|
xml.replaceAll(
|
|
|
- "%normal%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"normalTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
+ "%normal%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_normalTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
|
xml.replaceAll("%normalTexMutator%", "1");
|
|
xml.replaceAll("%normalTexMutator%", "1");
|
|
|
}
|
|
}
|
|
@@ -247,7 +243,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.emissive_texture).cstr());
|
|
uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.emissive_texture).cstr());
|
|
|
|
|
|
|
|
xml.replaceAll(
|
|
xml.replaceAll(
|
|
|
- "%emission%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"emissiveTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
+ "%emission%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_emissiveTex\" value=\"%s\"/>", uri.cstr()));
|
|
|
|
|
|
|
|
xml.replaceAll("%emissiveTexMutator%", "1");
|
|
xml.replaceAll("%emissiveTexMutator%", "1");
|
|
|
}
|
|
}
|
|
@@ -256,7 +252,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
const F32* emissionCol = &mtl.emissive_factor[0];
|
|
const F32* emissionCol = &mtl.emissive_factor[0];
|
|
|
|
|
|
|
|
xml.replaceAll("%emission%",
|
|
xml.replaceAll("%emission%",
|
|
|
- StringAuto{m_alloc}.sprintf("<input shaderInput=\"emission\" value=\"%f %f %f\"/>",
|
|
|
|
|
|
|
+ StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_emission\" value=\"%f %f %f\"/>",
|
|
|
emissionCol[0],
|
|
emissionCol[0],
|
|
|
emissionCol[1],
|
|
emissionCol[1],
|
|
|
emissionCol[2]));
|
|
emissionCol[2]));
|
|
@@ -278,7 +274,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
xml.replaceAll("%subsurface%",
|
|
xml.replaceAll("%subsurface%",
|
|
|
- StringAuto{m_alloc}.sprintf("<input shaderInput=\"subsurface\" value=\"%f\"/>", subsurface));
|
|
|
|
|
|
|
+ StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_subsurface\" value=\"%f\"/>", subsurface));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Height texture
|
|
// Height texture
|
|
@@ -289,12 +285,10 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
|
|
|
uri.sprintf("%s%s", m_texrpath.cstr(), it->cstr());
|
|
uri.sprintf("%s%s", m_texrpath.cstr(), it->cstr());
|
|
|
|
|
|
|
|
xml.replaceAll("%height%",
|
|
xml.replaceAll("%height%",
|
|
|
- StringAuto{m_alloc}.sprintf("<input shaderInput=\"heightTex\" value=\"%s\" \"/>\n"
|
|
|
|
|
- "\t\t<input shaderInput=\"heightMapScale\" value=\"0.05\"/>",
|
|
|
|
|
|
|
+ StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_heightTex\" value=\"%s\" \"/>\n"
|
|
|
|
|
+ "\t\t<input shaderVar=\"m_heightmapScale\" value=\"0.05\"/>",
|
|
|
uri.cstr()));
|
|
uri.cstr()));
|
|
|
|
|
|
|
|
- xml.replaceAll("%parallaxInput%", "<input shaderInput=\"modelViewMat\" builtin=\"MODEL_VIEW_MATRIX\"/>");
|
|
|
|
|
-
|
|
|
|
|
xml.replaceAll("%parallaxMutator%", "1");
|
|
xml.replaceAll("%parallaxMutator%", "1");
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|