Closed odil24 closed 1 year ago
Hi @odil24
You'll need to provide the position, lookat and fov for the camera in the .scene file (.json isn't supported)
camera
{
position .276 .275 -.75
lookat .276 .275 .10
fov 40
}
You can have a look at one of the sample scene files: https://github.com/knightcrawler25/GLSL-PathTracer/blob/master/assets/cornell_box_orig.scene
camera { position .276 .275 -.75 lookat .276 .275 .10 fov 40 }
How it would be in Blender if Blender Camera rotation positions are: X=90(eulers) Y=0(EULERS) Z=60(EULERS)????
Beacause, In Blender there are no has 0.0 like floated-rotation values, all are in Eulers.
If you're trying to get the camera parameters from Blender, you can run the following python script in the Blender text editor to get the position, lookat and fov in the console and copy-paste the values into the .scene file.
import bpy
from mathutils import Vector
from math import degrees
cam = bpy.context.scene.camera
m = cam.matrix_world
quat = m.to_quaternion()
pos = m.to_translation()
lookat = pos + quat @ Vector((0.0, 0.0, -1.0))
fov = degrees(cam.data.angle)
print( "position %f %f %f" % (pos.x, pos.z, -pos.y))
print( "lookat %f %f %f" % (lookat.x, lookat.z, -lookat.y))
print( "fov %f" % (fov))
One thing to note is that tilting the camera on the Y axis in blender wouldn't work as my code doesn't utilize the up vector for the camera.
If you're trying to get the camera parameters from Blender, you can run the following python script in the Blender text editor to get the position, lookat and fov in the console and copy-paste the values into the .scene file.
import bpy from mathutils import Vector from math import degrees cam = bpy.context.scene.camera m = cam.matrix_world quat = m.to_quaternion() pos = m.to_translation() lookat = pos + quat @ Vector((0.0, 0.0, -1.0)) fov = degrees(cam.data.angle) print( "position %f %f %f" % (pos.x, pos.z, -pos.y)) print( "lookat %f %f %f" % (lookat.x, lookat.z, -lookat.y)) print( "fov %f" % (fov))
One thing to note is that tilting the camera on the Y axis in blender wouldn't work as my code doesn't utilize the up vector for the camera.
I have done as you said but my camera is not ported as in Blender. Any solution?
Blender has a Z-up coordinate system whereas this project uses Y-up. Along with the camera, objects you export from blender should be exported with Y-up. Otherwise, the camera orientation from the script and the objects won't line up.
Blender has a Z-up coordinate system whereas this project uses Y-up. Along with the camera, objects you export from blender should be exported with Y-up. Otherwise, the camera orientation from the script and the objects won't line up.
It doesnt help me or I have done something wrong
It's difficult to tell what could be going wrong without looking at how the scene is setup in blender. Would you be able to share a sample .blend file?
Hi @knightcrawler25 I'm courious on how has been Camera position transforms are created? I meant when I write Camera position like for example: 0.25 0.25 0.25 It gives me wrong position. Is this wrote like XYZ or something else?