HackerPoet / PySpace

GLSL Fractal Ray Marcher in Python
MIT License
1.15k stars 147 forks source link

Totally black rendered images #19

Open andreascip98 opened 3 years ago

andreascip98 commented 3 years ago

The recording functionality (r key) should produce the rendered frames as images, to ./Playback folder. The problem is that i'm getting totally black images, even changing fps or resolution or any settings inside "camera.py".

Any guess?

Qwerter49 commented 3 years ago

I just started using this program and I'm having the same issue.

jookovjook commented 3 years ago

Found solution, works perfectly:

Inside ray_marcher_demo.py

from PIL import Image
from PIL import ImageOps

# REPLACE THIS:
pygame.image.save(window, 'playback/frame' + ix_str + '.png')

# WITH THIS:
glPixelStorei(GL_PACK_ALIGNMENT, 1)
data = glReadPixels(0, 0, window.get_width(), window.get_height(), GL_RGB, GL_UNSIGNED_BYTE)
image = Image.frombytes("RGB", (window.get_width(), window.get_height()), data)
image = ImageOps.flip(image)
image.save('playback/frame' + ix_str + '.png', 'PNG')
# Do the same for:
pygame.image.save(window, 'screenshot.png')
harperawl commented 3 years ago

when i replace it, it says there's an error with an "unexpected indent." i'm new to stuff like this, can someone help?

Ayers-Kendall commented 3 years ago

when i replace it, it says there's an error with an "unexpected indent." i'm new to stuff like this, can someone help?

Python 3 does not allow the mixing of spaces and tabs. Delete the tabs at the start of each line you added and try adding spaces instead, or vice versa. It would be a good idea to download an IDE like VS Code which will autodetect which is being used in the current file and format it correctly (convert tabs to spaces if necessary)

Ayers-Kendall commented 3 years ago

I have fixed this issue in my fork of the repo, and plan to expand this project quite a bit when I have the time. Everyone feel free to check it out, and also contribute if desired