Color attachment format

This commit is contained in:
Lubos Lenco 2020-05-06 18:11:02 +02:00
parent 9a71b5b664
commit 967f69b24a
5 changed files with 25 additions and 9 deletions

View file

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

View file

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

View file

@ -34,11 +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'
# 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:
@ -65,7 +71,7 @@ def parse_context(c, sres, asset, defs, vert=None, frag=None):
with open(c['tesscontrol_shader']) as f:
tesc = f.read().splitlines()
parse_shader(sres, c, con, defs, tesc, False)
if 'tesseval_shader' in c:
with open(c['tesseval_shader']) as f:
tese = f.read().splitlines()
@ -76,12 +82,12 @@ def parse_shader(sres, c, con, defs, lines, parse_attributes):
skip_else = False
vertex_elements_parsed = False
vertex_elements_parsing = False
stack = []
if parse_attributes == False:
vertex_elements_parsed = True
for line in lines:
line = line.lstrip()

View file

@ -16,11 +16,12 @@ write_material_attribs_post = None
write_vertex_attribs = None
def make(context_id, rpasses):
wrd = bpy.data.worlds['Arm']
rpdat = arm.utils.get_rp()
rid = rpdat.rp_renderer
con = { 'name': context_id, 'depth_write': True, 'compare_mode': 'less', 'cull_mode': 'clockwise' }
# Blend context
mat = mat_state.material
blend = mat.arm_blending
@ -42,6 +43,9 @@ def make(context_id, rpasses):
con['depth_write'] = False
con['compare_mode'] = 'equal'
if '_LDR' not in wrd.world_defs:
con['color_attachment'] = 'RGBA64'
con_mesh = mat_state.data.add_context(con)
mat_state.con_mesh = con_mesh
@ -243,7 +247,7 @@ def make_deferred(con_mesh, rpasses):
frag.write('n /= (abs(n.x) + abs(n.y) + abs(n.z));')
frag.write('n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);')
if '_Emission' in wrd.world_defs or '_SSS' in wrd.world_defs or '_Hair' in wrd.world_defs:
frag.write('uint matid = 0;')
if '_Emission' in wrd.world_defs:
@ -393,7 +397,7 @@ def make_forward_mobile(con_mesh):
if '_Spot' in wrd.world_defs:
vert.add_out('vec4 spotPosition')
vert.add_uniform('mat4 LWVPSpot0', link='_biasLightWorldViewProjectionMatrixSpot0')
vert.write('spotPosition = LWVPSpot0 * spos;')
vert.write('spotPosition = LWVPSpot0 * spos;')
frag.add_uniform('sampler2DShadow shadowMapSpot[1]')
frag.write('if (spotPosition.w > 0.0) {')
frag.write(' vec3 lPos = spotPosition.xyz / spotPosition.w;')
@ -469,7 +473,7 @@ def make_forward_solid(con_mesh):
parse_opacity = (blend and is_transluc) or arm_discard
if parse_opacity:
frag.write('float opacity;')
cycles.parse(mat_state.nodes, con_mesh, vert, frag, geom, tesc, tese, parse_opacity=parse_opacity, parse_displacement=False, basecol_only=True)
if arm_discard:

View file

@ -65,6 +65,10 @@ 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']
self.data['texture_units'] = []
self.tunits = self.data['texture_units']