Skip to content

Commit

Permalink
Merge branch 'Development' into Release
Browse files Browse the repository at this point in the history
  • Loading branch information
pragma37 committed Sep 7, 2022
2 parents 2e66e2b + 864bf36 commit 2d07154
Show file tree
Hide file tree
Showing 33 changed files with 273 additions and 179 deletions.
32 changes: 27 additions & 5 deletions .github/workflows/BlenderMalt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,24 @@ jobs:

- uses: ncipollo/release-action@v1
id: create_release
if: ${{ github.ref_type == 'branch' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
tag: ${{ env.BRANCH_NAME }}-latest
commit: ${{ github.sha }}
prerelease: ${{ env.BRANCH_NAME != 'Release' }}
bodyFile: ".github/download.md"
if: ${{ github.ref_type == 'branch' }}
body: |
### Sponsored by
## <a href="https://www.creativeshrimp.com/"><img src="/docs/images/creativeshrimp_logo.png" height="65">Creative Shrimp<a>
## <a href="https://twitter.com/MatchaChoco010">オリトイツキ - Orito Itsuki<a>
---
[**BlenderMalt-Windows.zip**](https://github.com/${{github.repository}}/releases/download/${{env.BRANCH_NAME}}-latest/BlenderMalt-Windows.zip)
[**BlenderMalt-Linux.zip**](https://github.com/${{github.repository}}/releases/download/${{env.BRANCH_NAME}}-latest/BlenderMalt-Linux.zip)
*(Requires Blender 3.2)*
---
<a href="https://patreon.com/pragma37"><img src="/docs/images/become_a_patron.png" height="45"><a>
- name: Rollback Tagged Release
uses: author/action-rollback@stable
Expand All @@ -41,12 +52,23 @@ jobs:

- uses: ncipollo/release-action@v1
id: create_tagged_release
if: ${{ github.ref_type == 'tag' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit: ${{ github.sha }}
allowUpdates: true
prerelease: ${{ env.BRANCH_NAME != 'Release' }}
bodyFile: ".github/download.md"
if: ${{ github.ref_type == 'tag' }}
body: |
### Sponsored by
## <a href="https://www.creativeshrimp.com/"><img src="/docs/images/creativeshrimp_logo.png" height="65">Creative Shrimp<a>
## <a href="https://twitter.com/MatchaChoco010">オリトイツキ - Orito Itsuki<a>
---
[**BlenderMalt-Windows.zip**](https://github.com/${{github.repository}}/releases/download/${{github.ref_name}}/BlenderMalt-Windows.zip)
[**BlenderMalt-Linux.zip**](https://github.com/${{github.repository}}/releases/download/${{github.ref_name}}/BlenderMalt-Linux.zip)
*(Requires Blender 3.2)*
---
<a href="https://patreon.com/pragma37"><img src="/docs/images/become_a_patron.png" height="45"><a>
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
Expand All @@ -60,7 +82,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-18.04]
os: [windows-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v2
Expand Down
22 changes: 13 additions & 9 deletions BlenderMalt/MaltNodes/MaltNodeTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,23 @@ def get_generated_source(self, force_update=False):
output_nodes.append(node)
linked_nodes.append(node)

def add_node_inputs(node, list):
def add_node_inputs(node, list, io_type):
for input in node.inputs:
if input.get_linked():
new_node = input.get_linked().node
if new_node.bl_idname == 'MaltIONode' and new_node.io_type != io_type:
input.links[0].is_muted = True
continue
if new_node not in list:
add_node_inputs(new_node, list)
add_node_inputs(new_node, list, io_type)
list.append(new_node)
if new_node not in linked_nodes:
linked_nodes.append(new_node)

transpiler = self.get_transpiler()
def get_source(output):
nodes = []
add_node_inputs(output, nodes)
add_node_inputs(output, nodes, output.io_type)
code = ''
for node in nodes:
if isinstance(node, MaltNode):
Expand Down Expand Up @@ -219,11 +222,12 @@ def update_ext(self, force_track_shader_changes=True):
try:
for link in self.links:
try:
if (link.from_socket.array_size != link.to_socket.array_size or
(link.from_socket.data_type != link.to_socket.data_type and
self.cast(link.from_socket.data_type, link.to_socket.data_type) is None)):
#TODO: handle reroute nodes
self.links.remove(link)
b = link.to_socket
a = b.get_linked()
if (a.array_size != b.array_size or
(a.data_type != b.data_type and
self.cast(a.data_type, b.data_type) is None)):
link.is_muted = True
except:
pass

Expand Down Expand Up @@ -557,7 +561,7 @@ def node_header_ui(self, context):
if context.space_data.tree_type != 'MaltTree' or node_tree is None:
return
def duplicate():
node_tree = node_tree.copy()
context.space_data.node_tree = node_tree.copy()
self.layout.operator('wm.malt_callback', text='', icon='DUPLICATE').callback.set(duplicate, 'Duplicate')
def recompile():
node_tree.update()
Expand Down
12 changes: 10 additions & 2 deletions BlenderMalt/MaltNodes/MaltSocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def on_type_update(self, context):
default_initialization: bpy.props.StringProperty(default='',
options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})

show_in_material_panel: bpy.props.BoolProperty(default=True,
options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})
# Declared below, in register()
#show_in_material_panel: bpy.props.BoolProperty(default=True,
# options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})

active: bpy.props.BoolProperty(default=True,
options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})
Expand Down Expand Up @@ -80,6 +81,8 @@ def get_linked_internal(socket):
return None
else:
link = socket.links[0]
if link.is_muted == True:
return None
linked = link.to_socket if socket.is_output else link.from_socket
if isinstance(linked.node, bpy.types.NodeReroute):
sockets = linked.node.inputs if linked.is_output else linked.node.outputs
Expand Down Expand Up @@ -144,6 +147,11 @@ def draw_color(self, context, node):

def register():
for _class in classes: bpy.utils.register_class(_class)

#Declare MaltSocket.show_in_material_panel
preferences = bpy.context.preferences.addons['BlenderMalt'].preferences
preferences.update_show_sockets(None)


def unregister():
for _class in reversed(classes): bpy.utils.unregister_class(_class)
Expand Down
2 changes: 1 addition & 1 deletion BlenderMalt/MaltPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def update_pipeline_settings(self, context):
set=malt_path_setter('plugins_dir'), get=malt_path_getter('plugins_dir'),
options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})

viewport_bit_depth : bpy.props.EnumProperty(items=[('8', '8', ''),('32', '32', '')],
viewport_bit_depth : bpy.props.EnumProperty(items=[('8', '8', ''),('16', '16', ''),('32', '32', '')],
name="Bit Depth (Viewport)", update=update_pipeline_settings,
options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})
graph_types : bpy.props.CollectionProperty(type=bpy.types.PropertyGroup,
Expand Down
6 changes: 5 additions & 1 deletion BlenderMalt/MaltRenderEngine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ctypes, time, platform
import xxhash
import bpy
from mathutils import Vector, Matrix, Quaternion
from Malt import Scene
Expand Down Expand Up @@ -187,7 +188,7 @@ def add_object(obj, matrix, id):

for obj in depsgraph.objects:
if is_f12 or obj.visible_in_viewport_get(context.space_data):
id = abs(hash(obj.name_full)) % (2**16)
id = xxhash.xxh3_64_intdigest(obj.name_full.encode()) % (2**16)
add_object(obj, obj.matrix_world, id)

for instance in depsgraph.object_instances:
Expand Down Expand Up @@ -354,6 +355,9 @@ def view_draw(self, context, depsgraph):
texture_format = GL.GL_RGBA8
if GL.glGetInternalformativ(GL.GL_TEXTURE_2D, texture_format, GL.GL_READ_PIXELS, 1) != GL.GL_ZERO:
data_format = GL.glGetInternalformativ(GL.GL_TEXTURE_2D, texture_format, GL.GL_TEXTURE_IMAGE_TYPE, 1)
elif self.bridge.viewport_bit_depth == 16:
data_format = GL.GL_HALF_FLOAT
texture_format = GL.GL_RGBA16F

render_texture = Texture(resolution, texture_format, data_format, pixels.buffer(), mag_filter=mag_filter)

Expand Down
2 changes: 1 addition & 1 deletion BlenderMalt/MaltTextures.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __load_texture(texture):
w,h = texture.size
channels = int(texture.channels)
size = w*h*channels
sRGB = texture.colorspace_settings.name == 'sRGB' and texture.use_generated_float == False
sRGB = texture.colorspace_settings.name == 'sRGB' and texture.is_float == False
if size == 0:
return True

Expand Down
19 changes: 15 additions & 4 deletions BlenderMalt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "BlenderMalt",
"description" : "Extensible Python Render Engine",
"author" : "Miguel Pozo",
"version": (1,0,0,'beta.2','Release'),
"version": (1,0,0,'beta.3','Release'),
"blender" : (3, 2, 0),
"doc_url": "https://malt3d.com",
"tracker_url": "https://github.com/bnpr/Malt/issues/new/choose",
Expand Down Expand Up @@ -34,7 +34,8 @@ class Preferences(bpy.types.AddonPreferences):
# this must match the addon name
bl_idname = __package__

setup_vs_code : bpy.props.BoolProperty(name="Auto setup VSCode", default=True, description="Setups a VSCode project on your .blend file folder")
setup_vs_code : bpy.props.BoolProperty(name="Auto setup VSCode", default=True,
description="Setups a VSCode project on your .blend file folder")

renderdoc_path : bpy.props.StringProperty(name="RenderDoc Path", subtype='FILE_PATH',
set=malt_path_setter('renderdoc_path'), get=malt_path_getter('renderdoc_path'))
Expand All @@ -47,11 +48,20 @@ class Preferences(bpy.types.AddonPreferences):

render_fps_cap : bpy.props.IntProperty(name="Max Viewport Render Framerate", default=30)

def update_show_sockets(self, context):
from BlenderMalt.MaltNodes.MaltSocket import MaltSocket
MaltSocket.show_in_material_panel = bpy.props.BoolProperty(default=self.show_sockets,
options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})

show_sockets : bpy.props.BoolProperty(name="Show sockets in Material Panel", default=True,
update=update_show_sockets, description="Show node socket properties in the Material Panel by default")

def update_debug_mode(self, context):
if context.scene.render.engine == 'MALT':
context.scene.world.malt.update_pipeline(context)

debug_mode : bpy.props.BoolProperty(name="Debug Mode", default=False, update=update_debug_mode, description="Developers only. Do not touch !!!")
debug_mode : bpy.props.BoolProperty(name="Debug Mode", default=False, update=update_debug_mode,
description="Developers only. Do not touch !!!")

def draw(self, context):
layout = self.layout
Expand All @@ -68,9 +78,10 @@ def draw(self, context):
row.operator('wm.path_open', text="Open Session Log")

layout.prop(self, "plugins_dir")
layout.prop(self, "show_sockets")
layout.prop(self, "render_fps_cap")
layout.prop(self, "setup_vs_code")
layout.prop(self, "renderdoc_path")
layout.prop(self, "render_fps_cap")
layout.label(text='Developer Settings :')
layout.prop(self, "debug_mode")
layout.prop(self, "docs_path")
Expand Down
7 changes: 5 additions & 2 deletions Bridge/Client_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,11 @@ def render(self, viewport_id, resolution, scene, scene_update, renderdoc_capture
from itertools import chain
for key, texture_format in chain(self.render_outputs.items(), AOVs.items()):
buffer_type = ctypes.c_float
if viewport_id != 0 and self.viewport_bit_depth == 8:
buffer_type = ctypes.c_byte
if viewport_id != 0:
if self.viewport_bit_depth == 8:
buffer_type = ctypes.c_byte
elif self.viewport_bit_depth == 16:
buffer_type = ctypes.c_ushort
w,h = resolution
self.render_buffers[viewport_id][key] = self.get_shared_buffer(buffer_type, w*h*4)
if viewport_id != 0: #viewport render
Expand Down
8 changes: 7 additions & 1 deletion Bridge/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ def setup(self, new_buffers, resolution, scene, scene_update, renderdoc_capture)
self.final_texture = Texture(resolution, GL_RGBA8, GL_UNSIGNED_BYTE, pixel_format=GL_RGBA)
self.final_texture.channel_size = 1
self.final_target = RenderTarget([self.final_texture])
elif self.bit_depth == 16:
self.final_texture = Texture(resolution, GL_RGBA16F)
self.final_target = RenderTarget([self.final_texture])
elif self.bit_depth == 32:
self.final_texture = Texture(resolution, GL_RGBA32F)
self.final_target = RenderTarget([self.final_texture])

if new_buffers:
self.buffers = new_buffers
Expand Down Expand Up @@ -202,7 +208,7 @@ def render(self):

if self.needs_more_samples:
result = self.pipeline.render(self.resolution, self.scene, self.is_final_render, self.is_new_frame)
if self.final_texture:
if self.final_texture.internal_format != result['COLOR'].internal_format:
self.pipeline.copy_textures(self.final_target, [result['COLOR']])
result = { 'COLOR' : self.final_texture }
self.is_new_frame = False
Expand Down
15 changes: 13 additions & 2 deletions Malt/GL/GL.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@
#For some reason PyOpenGL doesnt support the most common depth/stencil buffer by default ???
#https://sourceforge.net/p/pyopengl/bugs/223/
from OpenGL import images
images.TYPE_TO_ARRAYTYPE[ GL_UNSIGNED_INT_24_8 ] = GL_UNSIGNED_INT
images.TIGHT_PACK_FORMATS[ GL_UNSIGNED_INT_24_8 ] = 4
images.TYPE_TO_ARRAYTYPE[GL_UNSIGNED_INT_24_8] = GL_UNSIGNED_INT
images.TIGHT_PACK_FORMATS[GL_UNSIGNED_INT_24_8] = 4
images.TYPE_TO_ARRAYTYPE[GL_HALF_FLOAT] = GL_HALF_FLOAT
from OpenGL import arrays
if arrays.ADT:
arrays.GL_CONSTANT_TO_ARRAY_TYPE[GL_HALF_FLOAT] = arrays.ADT(GL_HALF_FLOAT, GLhalfARB)
else:
class GLhalfFloatArray(ArrayDatatype, ctypes.POINTER(GLhalfARB)):
baseType = GLhalfARB
typeConstant = GL_HALF_FLOAT
arrays.GL_CONSTANT_TO_ARRAY_TYPE[GL_HALF_FLOAT] = GLhalfFloatArray

NULL = None
GL_ENUMS = {}
Expand Down Expand Up @@ -56,6 +65,8 @@ def gl_buffer(type, size, data=None):
GL_UNSIGNED_SHORT : GLushort,
GL_INT : GLint,
GL_UNSIGNED_INT : GLuint,
#GL_HALF_FLOAT : GLhalfARB,
GL_HALF_FLOAT : GLfloat,
GL_FLOAT : GLfloat,
GL_DOUBLE : GLdouble,
GL_BOOL : GLboolean,
Expand Down
1 change: 1 addition & 0 deletions Malt/GL/RenderTarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def clear(self, colors=[], depth=None, stencil=None):
GL_INT : glClearBufferiv,
GL_UNSIGNED_INT : glClearBufferuiv,
GL_FLOAT : glClearBufferfv,
GL_HALF_FLOAT : glClearBufferfv,
GL_UNSIGNED_BYTE : glClearBufferfv,
}
target = self.targets[i]
Expand Down
9 changes: 6 additions & 3 deletions Malt/GL/Shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,12 @@ def glsl_reflection(code, root_paths=[]):
except:
pass

def fix_paths(dic):
def handle_paths(dic):
for e in dic.values():
path = e['file']
if '.internal.' in path or '__internal__' in path:
if 'internal' not in e['meta'].keys():
e['meta']['internal'] = True
path = os.path.normpath(path)
for root_path in root_paths:
try:
Expand All @@ -538,8 +541,8 @@ def fix_paths(dic):
except: pass
e['file'] = path.replace('\\','/')

fix_paths(reflection['structs'])
fix_paths(reflection['functions'])
handle_paths(reflection['structs'])
handle_paths(reflection['functions'])

functions = {}
for key, function in reflection['functions'].items():
Expand Down
4 changes: 3 additions & 1 deletion Malt/GL/Texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def __del__(self):
def internal_format_to_data_format(internal_format):
name = GL_ENUMS[internal_format]
table = {
'F' : GL_FLOAT,
'32F' : GL_FLOAT,
'16F' : GL_HALF_FLOAT,
'UI' : GL_UNSIGNED_INT,
'I' : GL_INT,
}
Expand All @@ -197,6 +198,7 @@ def internal_format_to_sampler_type(internal_format):
table = {
GL_UNSIGNED_BYTE : 'sampler2D',
GL_FLOAT : 'sampler2D',
GL_HALF_FLOAT : 'sampler2D',
GL_INT : 'isampler2D',
GL_UNSIGNED_INT : 'usampler2D'
}
Expand Down
Loading

0 comments on commit 2d07154

Please sign in to comment.