question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Repeat assignments to same scene variable make rendered graphic upside down

See original GitHub issue

This is a weird bug, and I can’t figure out why it is happening. If I want to loop over a few brain areas and create videos from each one, in theory I should be able to do this:

from BrainRender.scene import Scene
from BrainRender.Utils.videomaker import VideoMaker

regions = ['PRT', 'SCm', 'SCs']
for region in regions:
    scene = Scene()
    scene.add_brain_regions([region], colors='white', alpha=0.5)
    vm = VideoMaker(scene, savefile=f"Output/Videos/{region}.mp4", niters=120)
    vm.make_video(azimuth=3)

Indeed, this does create videos of these brain regions. However the second and third (and further videos if there are more regions) are rendered as upside down. I thought perhaps there is an object inside one of the imported files that is being manipulated at some point, but this wouldn’t explain the observation that this script does work:

from BrainRender.scene import Scene
from BrainRender.Utils.videomaker import VideoMaker

scene1 = Scene()
scene1.add_brain_regions(['PRT'], colors='white', alpha=0.5)
vm1 = VideoMaker(scene1, savefile=f"Output/Videos/PRT.mp4", niters=120)
vm1.make_video(azimuth=3)

scene2 = Scene()
scene2.add_brain_regions(['SCm'], colors='white', alpha=0.5)
vm2 = VideoMaker(scene1, savefile=f"Output/Videos/SCm.mp4", niters=120)
vm2.make_video(azimuth=3)

scene3 = Scene()
scene3.add_brain_regions(['SCs'], colors='white', alpha=0.5)
vm3 = VideoMaker(scene1, savefile=f"Output/Videos/SCs.mp4", niters=120)
vm3.make_video(azimuth=3)

Ain’t that weird? Are these two scripts not functionally equivalent? Am I being an idiot and missing something obvious?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
FedeClaudicommented, Jan 8, 2020

Hi Marco,

I’ve update vtkplotter but the problem is still there. Running this minimal example reproduces the bug:

from brainrender.scene import Scene

regions = ['PRT', 'SCm', 'SCs']
for region in regions:
    scene = Scene()
    scene.add_brain_regions([region], colors='white', alpha=0.5)
    scene.render()

The only way to avoid this is to add to scene.render() this:

if len(vtkplotter.settings.plotter_instances) > 1:
    self._rotate_actors()

to rotate all actors in the scene if there are other plotter_instances.

0reactions
FedeClaudicommented, Jan 13, 2020

Hi,

thanks for looking into this.

As far as I can tell vtkplotter is still inverting the actors for the second and third scene. To correct for this, in brainrender I rotate the actors before rendering the scene. Within the Scene.render() I check if other plotter instances exist, and if they do I rotate the actors (thus correcting the rotation due to vtkplotter:

if len(vtkplotter.settings.plotter_instances) > 1:
    self._rotate_actors()

This is why the output of your test looked okay. Sorry I should’ve explained that better. If you clone the brainrender repo and comment out these lines from Scene.render() you’ll find that the bug Is still there.

As far as I am concerned this solution is okay for brainrender. It might slow rendering for complicated scenes, but I don’t think that it’s an issue that is going to come up frequently. I thought I’d let you know anyways so that you can look into what in vtkplotter is causing this if you want to.

Cheers, Federico

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lecture 3 - CS50's Introduction to Game Development 2018
0:32:54AUDIENCE: The variable and the graphics [INAUDIBLE] ... 0:42:15Just give this transition alpha 255 down in the actual render function.
Read more >
Transformations, Time-sampled Animation, and Layer Offsets
We create the scene by starting with a USD file with static geometry, referencing it into another USD file, overlaying animation, and then...
Read more >
An introduction on OpenGL with 2D Graphics - OpenGL Tutorial
Modern computers have dedicated GPU (Graphics Processing Unit) with its own memory to speed up graphics rendering. OpenGL is the software interface to ......
Read more >
Chapter 5. Behind the scene graph - JavaFX in Action
Defining a scene graph; Animating stuff on screen, with ease; Transforming graphics and playing with color; Responding to mouse events;
Read more >
Drawing graphics - Learn web development | MDN
This article will focus mainly on 2D canvas, as raw WebGL code is very complex. We will however show how to use a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found