Skip to content

Commit

Permalink
lib+blender: Pass alpha channel from c-ray
Browse files Browse the repository at this point in the history
Blender expects the render buffer to have alpha, so just supply it
instead of patching it in.
  • Loading branch information
vkoskiv committed Dec 20, 2023
1 parent f0619c0 commit 046439b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bindings/blender_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ def display_bitmap(self, bm):
float_count = bm.width * bm.height * bm.stride
floats = array('f', bm.data.float_ptr[:float_count])
rect = []
for i in range(0, len(floats), 3):
for i in range(0, len(floats), 4):
temp = []
temp.append(floats[i + 0])
temp.append(floats[i + 1])
temp.append(floats[i + 2])
temp.append(1.0)
temp.append(floats[i + 3])
rect.append(temp)
result = self.begin_result(0, 0, bm.width, bm.height)
layer = result.layers[0].passes["Combined"]
Expand Down
2 changes: 2 additions & 0 deletions bindings/blender_ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import bpy
from bpy.types import Panel

# Most of this is just a carbon-copy of the Cycles UI boilerplate

class CrayButtonsPanel:
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
Expand Down
4 changes: 2 additions & 2 deletions src/lib/renderer/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ void renderer_render(struct renderer *r) {
// Render buffer is used to store accurate color values for the renderers' internal use
if (!r->state.result_buf) {
// Allocate
r->state.result_buf = newTexture(float_p, camera.width, camera.height, 3);
r->state.result_buf = newTexture(float_p, camera.width, camera.height, 4);
} else if (r->state.result_buf->width != (size_t)camera.width || r->state.result_buf->height != (size_t)camera.height) {
// Resize
if (r->state.result_buf) destroyTexture(r->state.result_buf);
r->state.result_buf = newTexture(float_p, camera.width, camera.height, 3);
r->state.result_buf = newTexture(float_p, camera.width, camera.height, 4);
} else {
// Clear
tex_clear(r->state.result_buf);
Expand Down

0 comments on commit 046439b

Please sign in to comment.