Browse Source

Add a sphere in sponza

Panagiotis Christopoulos Charitos 1 year ago
parent
commit
7d9397b2d5

+ 26 - 1
AnKi/Importer/GltfImporterMaterial.cpp

@@ -13,7 +13,7 @@
 namespace anki {
 
 inline constexpr const Char* kMaterialTemplate = R"(<!-- This file is auto generated by ImporterMaterial.cpp -->
-<material shadows="1">
+<material shadows="%shadowEnabled%">
 	<shaderProgram name="GBufferGeneric">
 		<mutation>
 			<mutator name="DIFFUSE_TEX" value="%diffTexMutator%"/>
@@ -242,6 +242,31 @@ Error GltfImporter::writeMaterialInternal(const cgltf_material& mtl, Bool writeR
 		xml.replaceAll("%specTexMutator%", "0");
 	}
 
+	// Shadow
+	{
+		Bool shadow = true;
+		auto it = extras.find("shadow");
+		if(it != extras.getEnd())
+		{
+			const ImporterString val = *it;
+			if(val == "false" || val == "0")
+			{
+				shadow = false;
+			}
+			else if(val == "true" || val == "1")
+			{
+				shadow = true;
+			}
+			else
+			{
+				ANKI_IMPORTER_LOGE("Wrong value for extra named shadow: %s", val.cstr());
+				return Error::kUserData;
+			}
+		}
+
+		xml.replaceAll("%shadowEnabled%", (shadow) ? "1" : "0");
+	}
+
 	// Identify metallic/roughness texture
 	F32 constantMetaliness = -1.0f, constantRoughness = -1.0f;
 	if(mtl.pbr_metallic_roughness.metallic_roughness_texture.texture)

+ 27 - 0
Samples/Sponza/Assets/MTL_sphere_f75b7f396643f2d.ankimtl

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- This file is auto generated by ImporterMaterial.cpp -->
+<material shadows="0">
+	<shaderProgram name="GBufferGeneric">
+		<mutation>
+			<mutator name="DIFFUSE_TEX" value="0"/>
+			<mutator name="SPECULAR_TEX" value="0"/>
+			<mutator name="ROUGHNESS_METALNESS_TEX" value="0"/>
+			<mutator name="NORMAL_TEX" value="0"/>
+			<mutator name="PARALLAX" value="0"/>
+			<mutator name="EMISSIVE_TEX" value="0"/>
+			<mutator name="ALPHA_TEST" value="0"/>
+		</mutation>
+	</shaderProgram>
+
+	<inputs>
+		
+		<input name="m_diffuseScale" value="1.000000 1.000000 1.000000 1.000000"/>
+		<input name="m_specularScale" value="0.040000 0.040000 0.040000"/>
+		<input name="m_roughnessScale" value="0.000000"/>
+		<input name="m_metalnessScale" value="1.000000"/>
+		
+		<input name="m_emissionScale" value="0.000000 0.000000 0.000000"/>
+		<input name="m_subsurface" value="0.000000"/>
+		
+	</inputs>
+</material>

+ 10 - 0
Samples/Sponza/Assets/Scene.lua

@@ -16,6 +16,16 @@ trf:setRotation(rot)
 trf:setScale(Vec4.new(1.000000, 1.000000, 1.000000, 0))
 node:setLocalTransform(trf)
 
+node = scene:newSceneNode("Sphere")
+node:newModelComponent():loadModelResource("Assets/Sphere_MTL_sphere_8df61cca01d9efcc.ankimdl")
+trf = Transform.new()
+trf:setOrigin(Vec4.new(0.718041, 1.838787, 0.000000, 0))
+rot = Mat3x4.new()
+rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000)
+trf:setRotation(rot)
+trf:setScale(Vec4.new(1.000000, 1.000000, 1.000000, 0))
+node:setLocalTransform(trf)
+
 node = scene:newSceneNode("Cube.011")
 comp = node:newGlobalIlluminationProbeComponent()
 comp:setBoxVolumeSize(Vec3.new(48.094303, 25.484703, 21.568947))

+ 8 - 0
Samples/Sponza/Assets/Sphere_MTL_sphere_8df61cca01d9efcc.ankimdl

@@ -0,0 +1,8 @@
+<model>
+	<modelPatches>
+		<modelPatch>
+			<mesh>Assets/Sphere_b335c223b7f61071.ankimesh</mesh>
+			<material>Assets/MTL_sphere_f75b7f396643f2d.ankimtl</material>
+		</modelPatch>
+	</modelPatches>
+</model>

BIN
Samples/Sponza/Assets/Sphere_b335c223b7f61071.ankimesh