Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chain vdb_view to vdb_render #1790

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrisflesher
Copy link

@chrisflesher chrisflesher commented Apr 15, 2024

I was interested when using vdb_view to render a color image using vdb_render. The changes in this PR cause vdb_view to print the camera transformation matrix when the user hits the 'p' key. This allows the user the option of connecting the two programs together.

Previous discussion on this subject:
#1715

Copy link

linux-foundation-easycla bot commented Apr 15, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

@chrisflesher
Copy link
Author

@danrbailey I had talked to you a few months ago about chaining vdb_view and vdb_print. Here is a proposed PR for the discussion here, what do you think?

#1715

@chrisflesher chrisflesher changed the title Allow vdb_view to print camera transformation matrix vdb_view print camera matrix Apr 15, 2024
@chrisflesher
Copy link
Author

chrisflesher commented Apr 16, 2024

I am chaining vdb_view to vdb_render using the following script:

import subprocess

import numpy as onp
import pathlib
from scipy.spatial.transform import Rotation


vdb_path = pathlib.Path.home() / 'model.vdb'

# Run vdb_view process
vdb_view_command = f'vdb_view {str(vdb_path)}'
vdb_view_stream = subprocess.Popen(vdb_view_command.split(' '), stdout=subprocess.PIPE)

# When user presses the 'p' key show a rendered image
lines = []
for line in vdb_view_stream.stdout:
    lines.append(line[:-1].decode('utf-8'))
    if len(lines) >= 4:
        matrix = onp.array(eval(''.join(lines)))
        lines = []
        rotation = Rotation.from_matrix(matrix[:3, :3])
        translation = rotation.apply(-matrix[3, :3])
        rph_degrees = rotation.as_euler('xyz', degrees=True)
        exr_path = vdb_path.with_suffix('.exr')
        command = (
            f'vdb_render {str(vdb_path)} {str(exr_path)} '
            f'-res 1920x1080 '
            f'-color color '
            f'-rotate {rph_degrees[0]},{rph_degrees[1]},{rph_degrees[2]} '
            f'-translate {translation[0]},{translation[1]},{translation[2]} '
        )[:-1]
        subprocess.run(command.split(' '))
        command = f'exrdisplay {str(exr_path)}'
        subprocess.run(command.split(' '))

@chrisflesher chrisflesher changed the title vdb_view print camera matrix Chain vdb_view to vdb_render Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant