From b0cd02d68eadabcc194c79845a1914ddbfbce88c Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sun, 10 May 2020 10:46:12 +0200 Subject: [PATCH] Allow multiple color attachment formats --- Shaders/clear_pass/clear_pass.json | 2 +- Shaders/deferred_light/deferred_light.json | 2 +- .../deferred_light_mobile/deferred_light_mobile.json | 2 +- Shaders/deferred_light_solid/deferred_light_solid.json | 2 +- Shaders/world_pass/world_pass.json | 2 +- blender/arm/lib/make_datas.py | 10 +++++----- blender/arm/material/make_mesh.py | 9 ++++----- blender/arm/material/shader.py | 6 ++---- 8 files changed, 16 insertions(+), 19 deletions(-) diff --git a/Shaders/clear_pass/clear_pass.json b/Shaders/clear_pass/clear_pass.json index 1abd20d6..c2165846 100644 --- a/Shaders/clear_pass/clear_pass.json +++ b/Shaders/clear_pass/clear_pass.json @@ -9,7 +9,7 @@ "texture_params": [], "vertex_shader": "../include/pass.vert.glsl", "fragment_shader": "clear_pass.frag.glsl", - "color_attachment": "_HDR" + "color_attachments": ["_HDR"] } ] } diff --git a/Shaders/deferred_light/deferred_light.json b/Shaders/deferred_light/deferred_light.json index 197aaf04..06d5a80f 100755 --- a/Shaders/deferred_light/deferred_light.json +++ b/Shaders/deferred_light/deferred_light.json @@ -241,7 +241,7 @@ ], "vertex_shader": "../include/pass_viewray.vert.glsl", "fragment_shader": "deferred_light.frag.glsl", - "color_attachment": "RGBA64" + "color_attachments": ["RGBA64"] } ] } diff --git a/Shaders/deferred_light_mobile/deferred_light_mobile.json b/Shaders/deferred_light_mobile/deferred_light_mobile.json index 2641b43d..118bcdf3 100644 --- a/Shaders/deferred_light_mobile/deferred_light_mobile.json +++ b/Shaders/deferred_light_mobile/deferred_light_mobile.json @@ -160,7 +160,7 @@ ], "vertex_shader": "../include/pass_viewray.vert.glsl", "fragment_shader": "deferred_light.frag.glsl", - "color_attachment": "RGBA64" + "color_attachments": ["RGBA64"] } ] } diff --git a/Shaders/deferred_light_solid/deferred_light_solid.json b/Shaders/deferred_light_solid/deferred_light_solid.json index e718b313..04997ba0 100644 --- a/Shaders/deferred_light_solid/deferred_light_solid.json +++ b/Shaders/deferred_light_solid/deferred_light_solid.json @@ -8,7 +8,7 @@ "links": [], "vertex_shader": "../include/pass.vert.glsl", "fragment_shader": "deferred_light.frag.glsl", - "color_attachment": "RGBA64" + "color_attachments": ["RGBA64"] } ] } diff --git a/Shaders/world_pass/world_pass.json b/Shaders/world_pass/world_pass.json index 2515f6b2..4be4597a 100644 --- a/Shaders/world_pass/world_pass.json +++ b/Shaders/world_pass/world_pass.json @@ -109,7 +109,7 @@ "texture_params": [], "vertex_shader": "world_pass.vert.glsl", "fragment_shader": "world_pass.frag.glsl", - "color_attachment": "_HDR" + "color_attachments": ["_HDR"] } ] } diff --git a/blender/arm/lib/make_datas.py b/blender/arm/lib/make_datas.py index 44d8fbbb..7a4618ad 100644 --- a/blender/arm/lib/make_datas.py +++ b/blender/arm/lib/make_datas.py @@ -34,17 +34,17 @@ def parse_context(c, sres, asset, defs, vert=None, frag=None): if con['tesseval_shader'] not in asset: asset.append(con['tesseval_shader']) - if 'color_attachment' in c: - con['color_attachment'] = c['color_attachment'] - if con['color_attachment'] == '_HDR': - con['color_attachment'] = 'RGBA32' if '_LDR' in defs else 'RGBA64' + if 'color_attachments' in c: + con['color_attachments'] = c['color_attachments'] + for i in range(len(con['color_attachments'])): + if con['color_attachments'][i] == '_HDR': + con['color_attachments'][i] = 'RGBA32' if '_LDR' in defs else 'RGBA64' # Params params = ['depth_write', 'compare_mode', 'cull_mode', \ 'blend_source', 'blend_destination', 'blend_operation', \ 'alpha_blend_source', 'alpha_blend_destination', 'alpha_blend_operation' \ 'color_writes_red', 'color_writes_green', 'color_writes_blue', 'color_writes_alpha', \ - 'color_attachment_count', \ 'conservative_raster'] for p in params: diff --git a/blender/arm/material/make_mesh.py b/blender/arm/material/make_mesh.py index 8ac5f1be..bd7899c4 100644 --- a/blender/arm/material/make_mesh.py +++ b/blender/arm/material/make_mesh.py @@ -43,11 +43,10 @@ def make(context_id, rpasses): con['depth_write'] = False con['compare_mode'] = 'equal' - if '_LDR' not in wrd.world_defs: - con['color_attachment'] = 'RGBA64' - - if rid == 'Deferred': - con['color_attachment_count'] = 3 if '_gbuffer2' in wrd.world_defs else 2 + attachment_format = 'RGBA32' if '_LDR' in wrd.world_defs else 'RGBA64' + con['color_attachments'] = [attachment_format, attachment_format] + if '_gbuffer2' in wrd.world_defs: + con['color_attachments'].append(attachment_format) con_mesh = mat_state.data.add_context(con) mat_state.con_mesh = con_mesh diff --git a/blender/arm/material/shader.py b/blender/arm/material/shader.py index 5d77dcc0..aa0a2f07 100644 --- a/blender/arm/material/shader.py +++ b/blender/arm/material/shader.py @@ -65,10 +65,8 @@ class ShaderContext: self.data['color_writes_blue'] = props['color_writes_blue'] if 'color_writes_alpha' in props: self.data['color_writes_alpha'] = props['color_writes_alpha'] - if 'color_attachment_count' in props: - self.data['color_attachment_count'] = props['color_attachment_count'] - if 'color_attachment' in props: - self.data['color_attachment'] = props['color_attachment'] + if 'color_attachments' in props: + self.data['color_attachments'] = props['color_attachments'] self.data['texture_units'] = [] self.tunits = self.data['texture_units']