Allow multiple color attachment formats

This commit is contained in:
luboslenco 2020-05-10 10:46:12 +02:00
parent df6346c1d1
commit b0cd02d68e
8 changed files with 16 additions and 19 deletions

View File

@ -9,7 +9,7 @@
"texture_params": [],
"vertex_shader": "../include/pass.vert.glsl",
"fragment_shader": "clear_pass.frag.glsl",
"color_attachment": "_HDR"
"color_attachments": ["_HDR"]
}
]
}

View File

@ -241,7 +241,7 @@
],
"vertex_shader": "../include/pass_viewray.vert.glsl",
"fragment_shader": "deferred_light.frag.glsl",
"color_attachment": "RGBA64"
"color_attachments": ["RGBA64"]
}
]
}

View File

@ -160,7 +160,7 @@
],
"vertex_shader": "../include/pass_viewray.vert.glsl",
"fragment_shader": "deferred_light.frag.glsl",
"color_attachment": "RGBA64"
"color_attachments": ["RGBA64"]
}
]
}

View File

@ -8,7 +8,7 @@
"links": [],
"vertex_shader": "../include/pass.vert.glsl",
"fragment_shader": "deferred_light.frag.glsl",
"color_attachment": "RGBA64"
"color_attachments": ["RGBA64"]
}
]
}

View File

@ -109,7 +109,7 @@
"texture_params": [],
"vertex_shader": "world_pass.vert.glsl",
"fragment_shader": "world_pass.frag.glsl",
"color_attachment": "_HDR"
"color_attachments": ["_HDR"]
}
]
}

View File

@ -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:

View File

@ -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

View File

@ -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']