Giter Site home page Giter Site logo

Comments (7)

knightcrawler25 avatar knightcrawler25 commented on June 2, 2024

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

from glsl-pathtracer.

odil24 avatar odil24 commented on June 2, 2024
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.

from glsl-pathtracer.

knightcrawler25 avatar knightcrawler25 commented on June 2, 2024

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.

from glsl-pathtracer.

odil24 avatar odil24 commented on June 2, 2024

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?

from glsl-pathtracer.

knightcrawler25 avatar knightcrawler25 commented on June 2, 2024

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.

from glsl-pathtracer.

odil24 avatar odil24 commented on June 2, 2024

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.

0
It doesnt help me or I have done something wrong

from glsl-pathtracer.

knightcrawler25 avatar knightcrawler25 commented on June 2, 2024

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?

from glsl-pathtracer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.