Hi Guys,
does anyone is familiar with CAMERA motion blur.
I was trying to set it up using Blender. But it looks that it does not set scene.camera.motion. I'm not able to make it working with blender.
So I'm trying to set it up using code.
I've checked two approaches.
1. I set static camera using position/target/up. Than I set motion matrices with relative values. So for camera.motion.0.transformation I set Identity matrix, and for camera.motion.1.transformation I set the diff between two camera locations. At the beginning it looked to be working. But I've found that if the camera is fur away from 0,0,0 the rotations are not correct. I've analyzed LuxCore code and came to second solution.
2. I've seen in code that the motion matrix is applied to current camera matrix. And there is a trick in code to set camera matrix to identity by setting position == target and than to override that value by motion matrix.
So I set position == target, and than set absolute values to camera.motion.
In that case, the camera is placed in a correct place but all geometry is completely black. Like it does not reflect any light.
Which approach is correct?
Can any one provide blender file with working CAMERA motion blur?
Camera Motion Blur
-
- Posts: 125
- Joined: Mon Oct 26, 2020 11:42 am
Re: Camera Motion Blur
It looks that I have found the bug. Generally the globalDir has infinite values if orig == target. In that case globalDir has to be taken from motionSystem.
I will write short manual how to make it working. I've used second approach from my previous post. So first of all set orig==target. I use (0,0,0).
Setting orig==target makes Luxcore asign identity matrix to trans->cameraToWorld in perspective camera. So camera transformation has to be set by camera.motion.*.
Than in camera parameters you have to set
scene.camera.shutteropen = 0
scene.camera.shutterclose = 0.02
In my case FPS = 25. Shutter speed is 1/50. In my case I assumed that shutter_speed < 1/FPS. I think it is possible to make shutter speed grater than 1/FPS, but it is not realistic and I found that approach easier for me.
Than you have to set camera motion. As in my code I already have camera position, target and up for each frame, so I have written a simple function that is generally identical to to Transform::LookAt
Than using this function I take camera position for current frame (position0, target0, up0) and next frame (position1, target1, up1):
It looks to be working. We are currently making more tests, but maybe somebody could add this functionality to Blender to make it available for everyone to test.
Code: Select all
@@ -258,8 +258,14 @@ void PerspectiveCamera::GetPDF(const Ray &eyeRay, const float eyeDistance,
const float filmX, const float filmY,
float *pdfW, float *fluxToRadianceFactor) const {
Vector globalDir = dir;
+
if (motionSystem)
+ {
+ if (orig == target)
+ globalDir = Vector(0, 0, 1);
globalDir *= motionSystem->Sample(eyeRay.time);
+ }
+
Code: Select all
scene.camera.lookat.orig = 0 0 0
scene.camera.lookat.target = 0 0 0
Than in camera parameters you have to set
scene.camera.shutteropen = 0
scene.camera.shutterclose = 0.02
In my case FPS = 25. Shutter speed is 1/50. In my case I assumed that shutter_speed < 1/FPS. I think it is possible to make shutter speed grater than 1/FPS, but it is not realistic and I found that approach easier for me.
Than you have to set camera motion. As in my code I already have camera position, target and up for each frame, so I have written a simple function that is generally identical to to Transform::LookAt
Code: Select all
public static float[] LookAtMatrix(Vector3 origin, Vector3 target, Vector3 up)
{
// Forward = target - origin
Vector3 dir = Vector3.Normalize(target - origin);
// Right = cross(forward, up)
Vector3 right = Vector3.Normalize(Vector3.Cross(dir, up));
// True up = cross(right, forward)
Vector3 u = Vector3.Cross(right, dir);
// Column-major storage for LuxCore
float[] m = new float[16];
m[0] = right.x; m[4] = u.x; m[8] = dir.x; m[12] = origin.x;
m[1] = right.y; m[5] = u.y; m[9] = dir.y; m[13] = origin.y;
m[2] = right.z; m[6] = u.z; m[10] = dir.z; m[14] = origin.z;
m[3] = 0f; m[7] = 0f; m[11] = 0f; m[15] = 1f;
return m;
}
Code: Select all
properties.Set(new Property("scene.camera.motion.0.time").AddValue(0));
properties.Set(new Property("scene.camera.motion.0.transformation").AddValuesArray(LookAtMatrix(position0, target0, up0)));
properties.Set(new Property("scene.camera.motion.1.time").AddValue(1f / (float)fxCamera.Fps)); //fime for next frame is 1 / fps
properties.Set(new Property("scene.camera.motion.1.transformation").AddValuesArray(LookAtMatrix(position1, target1, up1)));
Re: Camera Motion Blur
Indeed, camera blur isn't working.
Sadly, I don't know how to add/fix this functionality in BlendLuxCore.
So, for anyone able & willing to tackle this, here's a test scene and compared result to Cycles.
Also, found that emission color of Cycles Principled BSDF doesn't work.
Cycles (4.5.3)
BlendLuxCore (2.10.1)
Scene File:
PS
It appears to be something wrong with forum code, too
Sadly, I don't know how to add/fix this functionality in BlendLuxCore.
So, for anyone able & willing to tackle this, here's a test scene and compared result to Cycles.
Also, found that emission color of Cycles Principled BSDF doesn't work.
Cycles (4.5.3)
BlendLuxCore (2.10.1)
Scene File:
PS
It appears to be something wrong with forum code, too