2019-02-12 12:39:16 +01:00
|
|
|
import bpy
|
2017-03-15 12:30:14 +01:00
|
|
|
import arm.material.cycles as cycles
|
|
|
|
import arm.material.mat_state as mat_state
|
|
|
|
import arm.material.make_mesh as make_mesh
|
2018-12-14 15:27:43 +01:00
|
|
|
import arm.material.make_finalize as make_finalize
|
2018-05-21 17:55:26 +02:00
|
|
|
import arm.assets as assets
|
2016-12-19 01:25:22 +01:00
|
|
|
|
|
|
|
def make(context_id):
|
|
|
|
con_transluc = mat_state.data.add_context({ 'name': context_id, 'depth_write': False, 'compare_mode': 'less', 'cull_mode': 'clockwise', \
|
|
|
|
'blend_source': 'blend_one', 'blend_destination': 'blend_one', 'blend_operation': 'add', \
|
|
|
|
'alpha_blend_source': 'blend_zero', 'alpha_blend_destination': 'inverse_source_alpha', 'alpha_blend_operation': 'add' })
|
|
|
|
|
2019-01-27 15:01:39 +01:00
|
|
|
make_mesh.make_forward_base(con_transluc, parse_opacity=True, transluc_pass=True)
|
2016-12-19 01:25:22 +01:00
|
|
|
|
|
|
|
vert = con_transluc.vert
|
|
|
|
frag = con_transluc.frag
|
2016-12-20 00:39:18 +01:00
|
|
|
tese = con_transluc.tese
|
2016-12-19 01:25:22 +01:00
|
|
|
|
2019-01-30 17:45:54 +01:00
|
|
|
frag.add_out('vec4 fragColor[2]')
|
2016-12-21 00:51:04 +01:00
|
|
|
|
2016-12-19 01:25:22 +01:00
|
|
|
# Remove fragColor = ...;
|
|
|
|
frag.main = frag.main[:frag.main.rfind('fragColor')]
|
2017-11-10 15:18:44 +01:00
|
|
|
frag.write('\n')
|
2019-02-12 12:39:16 +01:00
|
|
|
|
|
|
|
wrd = bpy.data.worlds['Arm']
|
2019-04-06 18:52:21 +02:00
|
|
|
if '_VoxelAOvar' in wrd.world_defs:
|
2019-02-12 12:39:16 +01:00
|
|
|
frag.write('indirect *= 0.25;')
|
|
|
|
frag.write('vec4 premultipliedReflect = vec4(vec3(direct + indirect * 0.5) * opacity, opacity);')
|
2016-12-19 01:25:22 +01:00
|
|
|
|
2019-02-01 17:33:22 +01:00
|
|
|
frag.write('float w = clamp(pow(min(1.0, premultipliedReflect.a * 10.0) + 0.01, 3.0) * 1e8 * pow(1.0 - (gl_FragCoord.z) * 0.9, 3.0), 1e-2, 3e3);')
|
2016-12-19 01:25:22 +01:00
|
|
|
frag.write('fragColor[0] = vec4(premultipliedReflect.rgb * w, premultipliedReflect.a);')
|
|
|
|
frag.write('fragColor[1] = vec4(premultipliedReflect.a * w, 0.0, 0.0, 1.0);')
|
|
|
|
|
2018-12-14 15:27:43 +01:00
|
|
|
make_finalize.make(con_transluc)
|
2018-05-21 17:55:26 +02:00
|
|
|
|
|
|
|
# assets.vs_equal(con_transluc, assets.shader_cons['transluc_vert']) # shader_cons has no transluc yet
|
|
|
|
# assets.fs_equal(con_transluc, assets.shader_cons['transluc_frag'])
|
|
|
|
|
2016-12-19 01:25:22 +01:00
|
|
|
return con_transluc
|