Browse Source

More work

Panagiotis Christopoulos Charitos 7 years ago
parent
commit
42f79aa043

+ 2 - 254
samples/sponza/assets/scene.lua

@@ -5,15 +5,6 @@ local node
 local inst
 local inst
 local lcomp
 local lcomp
 
 
-node = scene:newSectorNode("Cube0", "assets/Cube.ankimesh")
-trf = Transform.new()
-trf:setOrigin(Vec4.new(0, 10.6707, 0, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
 node = scene:newParticleEmitterNode("particles0", "assets/fire.ankipart")
 node = scene:newParticleEmitterNode("particles0", "assets/fire.ankipart")
 trf = Transform.new()
 trf = Transform.new()
 trf:setOrigin(Vec4.new(-10.7851, 2.17929, 2.47133, 0))
 trf:setOrigin(Vec4.new(-10.7851, 2.17929, 2.47133, 0))
@@ -86,252 +77,9 @@ trf:setRotation(rot)
 trf:setScale(0.259678)
 trf:setScale(0.259678)
 node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
 node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
 
 
-node = scene:newReflectionProbeNode("reflprobe0", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(18.0683, 2.49039, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe1", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(8.05931, 2.49039, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe2", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-1.43904, 2.49039, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe3", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-11.1261, 2.49039, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe4", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-19.0274, 2.49039, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe5", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-19.0274, 2.49039, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe6", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-11.1261, 2.49039, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe7", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-1.43904, 2.49039, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe8", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(8.05931, 2.49039, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe9", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(18.0683, 2.49039, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe10", 7.13881)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(18.9426, 2.49039, -0.625299, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe11", 7.13881)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(8.47687, 2.49039, -0.625299, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe12", 7.13881)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-1.45483, 2.49039, -0.625299, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe13", 7.13881)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-11.5838, 2.49039, -0.625299, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe14", 7.13881)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-19.8456, 2.49039, -0.625299, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe15", 7.13881)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-19.8456, 11.1297, -0.625299, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe16", 7.13881)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(18.9426, 11.1297, -0.625299, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe17", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(18.0683, 11.1297, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe18", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(8.05931, 11.1297, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe19", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-1.43904, 11.1297, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe20", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-11.1261, 11.1297, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe21", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-19.0274, 11.1297, -8.62114, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe22", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-19.0274, 11.1297, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe23", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-11.1261, 11.1297, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe24", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(-1.43904, 11.1297, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe25", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(8.05931, 11.1297, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe26", 6.82732)
-trf = Transform.new()
-trf:setOrigin(Vec4.new(18.0683, 11.1297, 6.66315, 0))
-rot = Mat3x4.new()
-rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
-trf:setRotation(rot)
-trf:setScale(1)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-
-node = scene:newReflectionProbeNode("reflprobe27", 35.9169)
+node = scene:newReflectionProbeNode("reflprobe0", Vec4.new(-0.5, -0.5, -0.5, 0), Vec4.new(0.5, 0.5, 0.5, 0))
 trf = Transform.new()
 trf = Transform.new()
-trf:setOrigin(Vec4.new(0, 9.57409, -0.625299, 0))
+trf:setOrigin(Vec4.new(0.510497, 8.00824, -10.5717, 0))
 rot = Mat3x4.new()
 rot = Mat3x4.new()
 rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
 rot:setAll(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
 trf:setRotation(rot)
 trf:setRotation(rot)

+ 2 - 2
shaders/LightFunctions.glsl

@@ -205,7 +205,7 @@ void intersectProbe(Vec3 fragPos, // Ray origin
 {
 {
 	// Compute the intersection point
 	// Compute the intersection point
 	F32 intresectionDist = rayAabbIntersectionInside(fragPos, rayDir, probeAabbMin, probeAabbMax);
 	F32 intresectionDist = rayAabbIntersectionInside(fragPos, rayDir, probeAabbMin, probeAabbMax);
-	Vec3 intresectionPoint = fragPos + intresectionDist * rayDir;
+	Vec3 intersectionPoint = fragPos + intresectionDist * rayDir;
 
 
 	// Compute the cubemap vector
 	// Compute the cubemap vector
 	cubeTexCoord = intersectionPoint - probeOrigin;
 	cubeTexCoord = intersectionPoint - probeOrigin;
@@ -213,7 +213,7 @@ void intersectProbe(Vec3 fragPos, // Ray origin
 	// Calculate the weight
 	// Calculate the weight
 	{
 	{
 		// Distance between the frag and the AABB bounds
 		// Distance between the frag and the AABB bounds
-		F32 fragBoxDist = length(fragPos - intresectionPoint);
+		F32 fragBoxDist = length(fragPos - intersectionPoint);
 
 
 		// Cap the distance
 		// Cap the distance
 		fragBoxDist = min(fragBoxDist, fadeDistance);
 		fragBoxDist = min(fragBoxDist, fadeDistance);

+ 9 - 0
shaders/Reflections.ankiprog

@@ -180,6 +180,14 @@ void readReflectionsAndIrradianceFromProbes(
 	{
 	{
 		ReflectionProbe probe = u_reflectionProbes[u_lightIndices[idxOffset++]];
 		ReflectionProbe probe = u_reflectionProbes[u_lightIndices[idxOffset++]];
 
 
+		Vec3 cubeCoord;
+		F32 blendWeight;
+		intersectProbe(worldPos, reflDir, probe.m_aabbMinPad1.xyz, probe.m_aabbMinPad1.xyz, 
+			probe.m_positionCubemapIndex.xyz, 0.2, cubeCoord, blendWeight);
+
+		diffIndirect = Vec3(blendWeight);
+
+#if 0
 		F32 R2 = probe.m_positionRadiusSq.w;
 		F32 R2 = probe.m_positionRadiusSq.w;
 		Vec3 center = probe.m_positionRadiusSq.xyz;
 		Vec3 center = probe.m_positionRadiusSq.xyz;
 
 
@@ -203,6 +211,7 @@ void readReflectionsAndIrradianceFromProbes(
 		uv = computeCubemapVecAccurate(normal, R2, f);
 		uv = computeCubemapVecAccurate(normal, R2, f);
 		Vec3 id = textureLod(u_irradianceTex, Vec4(uv, cubemapIndex), 0.0).rgb;
 		Vec3 id = textureLod(u_irradianceTex, Vec4(uv, cubemapIndex), 0.0).rgb;
 		diffIndirect = mix(id, diffIndirect, factor);
 		diffIndirect = mix(id, diffIndirect, factor);
+#endif
 	}
 	}
 }
 }
 
 

+ 15 - 19
src/anki/renderer/LightBin.cpp

@@ -81,27 +81,22 @@ public:
 		m_index = i;
 		m_index = i;
 	}
 	}
 
 
-	F32 getProbeRadius() const
+	void setProbeVolume(F32 v)
 	{
 	{
-		return F32(m_probeRadius) / F32(MAX_U16) * F32(MAX_PROBE_RADIUS);
-	}
-
-	void setProbeRadius(F32 r)
-	{
-		ANKI_ASSERT(r < MAX_PROBE_RADIUS);
-		m_probeRadius = r / F32(MAX_PROBE_RADIUS) * F32(MAX_U16);
+		ANKI_ASSERT(v < MAX_PROBE_VOLUME);
+		m_probeVolume = v / F32(MAX_PROBE_VOLUME) * F32(MAX_U16);
 	}
 	}
 
 
 	Bool operator<(const ClusterProbeIndex& b) const
 	Bool operator<(const ClusterProbeIndex& b) const
 	{
 	{
-		ANKI_ASSERT(m_probeRadius > 0 && b.m_probeRadius > 0);
-		return (m_probeRadius != b.m_probeRadius) ? (m_probeRadius > b.m_probeRadius) : (m_index < b.m_index);
+		ANKI_ASSERT(m_probeVolume > 0 && b.m_probeVolume > 0);
+		return (m_probeVolume != b.m_probeVolume) ? (m_probeVolume > b.m_probeVolume) : (m_index < b.m_index);
 	}
 	}
 
 
 private:
 private:
-	static const U MAX_PROBE_RADIUS = 1000;
+	static const U MAX_PROBE_VOLUME = 1000;
 	U16 m_index;
 	U16 m_index;
-	U16 m_probeRadius;
+	U16 m_probeVolume;
 };
 };
 
 
 /// WARNING: Keep it as small as possible. The number of clusters is huge
 /// WARNING: Keep it as small as possible. The number of clusters is huge
@@ -716,17 +711,16 @@ void LightBin::writeAndBinProbe(
 {
 {
 	// Write it
 	// Write it
 	ReflectionProbe probe;
 	ReflectionProbe probe;
-	probe.m_positionRadiusSq = Vec4(probeEl.m_worldPosition, probeEl.m_radius * probeEl.m_radius);
-	probe.m_cubemapIndexPad3 = Vec4(probeEl.m_textureArrayIndex, 0.0f, 0.0f, 0.0f);
+	probe.m_positionCubemapIndex = Vec4(probeEl.m_worldPosition, probeEl.m_textureArrayIndex);
+	probe.m_aabbMinPad1 = probeEl.m_aabbMin.xyz0();
+	probe.m_aabbMaxPad1 = probeEl.m_aabbMax.xyz0();
 
 
 	U idx = ctx.m_probeCount.fetchAdd(1);
 	U idx = ctx.m_probeCount.fetchAdd(1);
 	ctx.m_probes[idx] = probe;
 	ctx.m_probes[idx] = probe;
 
 
 	// Bin it
 	// Bin it
-	Sphere sphere(probeEl.m_worldPosition.xyz0(), probeEl.m_radius);
-	Aabb box;
-	sphere.computeAabb(box);
-	m_clusterer.bin(sphere, box, testResult);
+	Aabb box(probeEl.m_aabbMin, probeEl.m_aabbMax);
+	m_clusterer.bin(box, box, testResult);
 
 
 	auto it = testResult.getClustersBegin();
 	auto it = testResult.getClustersBegin();
 	auto end = testResult.getClustersEnd();
 	auto end = testResult.getClustersEnd();
@@ -742,7 +736,9 @@ void LightBin::writeAndBinProbe(
 
 
 		i = cluster.m_probeCount.fetchAdd(1) % MAX_PROBES_PER_CLUSTER;
 		i = cluster.m_probeCount.fetchAdd(1) % MAX_PROBES_PER_CLUSTER;
 		cluster.m_probeIds[i].setIndex(idx);
 		cluster.m_probeIds[i].setIndex(idx);
-		cluster.m_probeIds[i].setProbeRadius(probeEl.m_radius);
+
+		Vec3 edges = probeEl.m_aabbMax - probeEl.m_aabbMin;
+		cluster.m_probeIds[i].setProbeVolume(edges.x() * edges.y() * edges.z());
 	}
 	}
 }
 }
 
 

+ 1 - 1
src/anki/scene/components/ReflectionProbeComponent.h

@@ -59,7 +59,7 @@ public:
 	void setupReflectionProbeQueueElement(ReflectionProbeQueueElement& el) const
 	void setupReflectionProbeQueueElement(ReflectionProbeQueueElement& el) const
 	{
 	{
 		ANKI_ASSERT(m_aabbMin < m_aabbMax);
 		ANKI_ASSERT(m_aabbMin < m_aabbMax);
-		ANKI_ASSERT(m_pos > m_aabbMin & m_pos < m_aabbMax);
+		ANKI_ASSERT(m_pos > m_aabbMin && m_pos < m_aabbMax);
 		el.m_feedbackCallback = reflectionProbeQueueElementFeedbackCallback;
 		el.m_feedbackCallback = reflectionProbeQueueElementFeedbackCallback;
 		el.m_userData = const_cast<ReflectionProbeComponent*>(this);
 		el.m_userData = const_cast<ReflectionProbeComponent*>(this);
 		el.m_uuid = getUuid();
 		el.m_uuid = getUuid();

+ 14 - 4
src/anki/script/Scene.cpp

@@ -3107,7 +3107,7 @@ static inline int pwrapSceneGraphnewReflectionProbeNode(lua_State* l)
 	PtrSize size;
 	PtrSize size;
 	(void)size;
 	(void)size;
 
 
-	LuaBinder::checkArgsCount(l, 3);
+	LuaBinder::checkArgsCount(l, 4);
 
 
 	// Get "this" as "self"
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameSceneGraph, -7754439619132389154, ud))
 	if(LuaBinder::checkUserData(l, 1, classnameSceneGraph, -7754439619132389154, ud))
@@ -3124,14 +3124,24 @@ static inline int pwrapSceneGraphnewReflectionProbeNode(lua_State* l)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	F32 arg1;
-	if(LuaBinder::checkNumber(l, 3, arg1))
+	if(LuaBinder::checkUserData(l, 3, "Vec4", 6804478823655046386, ud))
+	{
+		return -1;
+	}
+
+	Vec4* iarg1 = ud->getData<Vec4>();
+	const Vec4& arg1(*iarg1);
+
+	if(LuaBinder::checkUserData(l, 4, "Vec4", 6804478823655046386, ud))
 	{
 	{
 		return -1;
 		return -1;
 	}
 	}
 
 
+	Vec4* iarg2 = ud->getData<Vec4>();
+	const Vec4& arg2(*iarg2);
+
 	// Call the method
 	// Call the method
-	ReflectionProbeNode* ret = newSceneNode<ReflectionProbeNode>(self, arg0, arg1);
+	ReflectionProbeNode* ret = newSceneNode<ReflectionProbeNode>(self, arg0, arg1, arg2);
 
 
 	// Push return value
 	// Push return value
 	if(ANKI_UNLIKELY(ret == nullptr))
 	if(ANKI_UNLIKELY(ret == nullptr))

+ 3 - 2
src/anki/script/Scene.xml

@@ -369,10 +369,11 @@ static SceneGraph* getSceneGraph(lua_State* l)
 					<return>ParticleEmitterNode*</return>
 					<return>ParticleEmitterNode*</return>
 				</method>
 				</method>
 				<method name="newReflectionProbeNode">
 				<method name="newReflectionProbeNode">
-					<overrideCall><![CDATA[ReflectionProbeNode* ret = newSceneNode<ReflectionProbeNode>(self, arg0, arg1);]]></overrideCall>
+					<overrideCall><![CDATA[ReflectionProbeNode* ret = newSceneNode<ReflectionProbeNode>(self, arg0, arg1, arg2);]]></overrideCall>
 					<args>
 					<args>
 						<arg>const CString&amp;</arg>
 						<arg>const CString&amp;</arg>
-						<arg>F32</arg>
+						<arg>const Vec4&amp;</arg>
+						<arg>const Vec4&amp;</arg>
 					</args>
 					</args>
 					<return>ReflectionProbeNode*</return>
 					<return>ReflectionProbeNode*</return>
 				</method>
 				</method>

+ 9 - 4
tools/scene/Exporter.cpp

@@ -819,9 +819,12 @@ void Exporter::visitNode(const aiNode* ainode)
 				aiMatrix4x4 trf = toAnkiMatrix(ainode->mTransformation);
 				aiMatrix4x4 trf = toAnkiMatrix(ainode->mTransformation);
 				probe.m_position = aiVector3D(trf.a4, trf.b4, trf.c4);
 				probe.m_position = aiVector3D(trf.a4, trf.b4, trf.c4);
 
 
-				aiVector3D zAxis(trf.a3, trf.b3, trf.c3);
-				float scale = zAxis.Length();
-				probe.m_radius = scale;
+				aiVector3D scale(trf.a1, trf.b2, trf.c3);
+				assert(scale.x > 0.0f && scale.y > 0.0f && scale.z > 0.0f);
+
+				aiVector3D half = scale / aiVector3D(2.0f, 2.0f, 2.0f);
+				probe.m_aabbMin = probe.m_position - half - probe.m_position;
+				probe.m_aabbMax = probe.m_position + half - probe.m_position;
 
 
 				m_reflectionProbes.push_back(probe);
 				m_reflectionProbes.push_back(probe);
 
 
@@ -1049,7 +1052,9 @@ void Exporter::exportAll()
 	for(const ReflectionProbe& probe : m_reflectionProbes)
 	for(const ReflectionProbe& probe : m_reflectionProbes)
 	{
 	{
 		std::string name = "reflprobe" + std::to_string(i);
 		std::string name = "reflprobe" + std::to_string(i);
-		file << "\nnode = scene:newReflectionProbeNode(\"" << name << "\", " << probe.m_radius << ")\n";
+		file << "\nnode = scene:newReflectionProbeNode(\"" << name << "\", Vec4.new(" << probe.m_aabbMin.x << ", "
+			 << probe.m_aabbMin.y << ", " << probe.m_aabbMin.z << ", 0), Vec4.new(" << probe.m_aabbMax.x << ", "
+			 << probe.m_aabbMax.y << ", " << probe.m_aabbMax.z << ", 0))\n";
 
 
 		aiMatrix4x4 trf;
 		aiMatrix4x4 trf;
 		aiMatrix4x4::Translation(probe.m_position, trf);
 		aiMatrix4x4::Translation(probe.m_position, trf);

+ 2 - 1
tools/scene/Exporter.h

@@ -74,7 +74,8 @@ class ReflectionProbe
 {
 {
 public:
 public:
 	aiVector3D m_position;
 	aiVector3D m_position;
-	float m_radius;
+	aiVector3D m_aabbMin;
+	aiVector3D m_aabbMax;
 };
 };
 
 
 class ReflectionProxy
 class ReflectionProxy