MRT Index #143
@ -977,7 +977,7 @@ class RenderPathDeferred {
|
|||||||
path.bindTarget("tex", "tex");
|
path.bindTarget("tex", "tex");
|
||||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||||
|
|
||||||
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer_refraction"]);
|
setTargetMeshes();
|
||||||
|
|
||||||
#if (rp_voxels != "Off")
|
#if (rp_voxels != "Off")
|
||||||
path.bindTarget("voxelsOut", "voxels");
|
path.bindTarget("voxelsOut", "voxels");
|
||||||
@ -997,7 +997,7 @@ class RenderPathDeferred {
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
#if rp_ssrs
|
#if rp_ssrs
|
||||||
path.bindTarget("_main", "gbufferD");
|
path.bindTarget("gbufferD1", "gbufferD");
|
||||||
#end
|
#end
|
||||||
|
|
||||||
path.drawMeshes("refraction");
|
path.drawMeshes("refraction");
|
||||||
|
|||||||
@ -570,9 +570,10 @@ def get_num_gbuffer_rts_deferred()-> int:
|
|||||||
|
|
||||||
for flag in ('_gbuffer2', '_EmissionShaded', '_SSRefraction', '_VoxelRefract', '_ClearCoat'):
|
for flag in ('_gbuffer2', '_EmissionShaded', '_SSRefraction', '_VoxelRefract', '_ClearCoat'):
|
||||||
if flag in wrd.world_defs:
|
if flag in wrd.world_defs:
|
||||||
if flag in refraction_flags and not found_refraction_flag:
|
if flag in refraction_flags:
|
||||||
num += 1
|
if not found_refraction_flag:
|
||||||
found_refraction_flag = True
|
num += 1
|
||||||
|
found_refraction_flag = True
|
||||||
else:
|
else:
|
||||||
num += 1
|
num += 1
|
||||||
|
|
||||||
|
|||||||
@ -33,10 +33,28 @@ def make(context_id):
|
|||||||
frag = con_refract.frag
|
frag = con_refract.frag
|
||||||
tese = con_refract.tese
|
tese = con_refract.tese
|
||||||
frag.add_include('std/gbuffer.glsl')
|
frag.add_include('std/gbuffer.glsl')
|
||||||
frag.add_out('vec4 fragColor[3]')
|
|
||||||
|
|
||||||
rpdat = lnx.utils.get_rp()
|
rpdat = lnx.utils.get_rp()
|
||||||
|
|
||||||
|
is_deferred = rpdat.rp_renderer == 'Deferred'
|
||||||
|
wrd = bpy.data.worlds['Lnx']
|
||||||
|
|
||||||
|
idx_2 = idx_emission = idx_coat = -1
|
||||||
|
idx = 2
|
||||||
|
if '_gbuffer2' in wrd.world_defs:
|
||||||
|
idx_2 = idx
|
||||||
|
idx += 1
|
||||||
|
if '_EmissionShaded' in wrd.world_defs:
|
||||||
|
idx_emission = idx
|
||||||
|
idx += 1
|
||||||
|
idx_refraction = idx
|
||||||
|
idx += 1
|
||||||
|
if '_ClearCoat' in wrd.world_defs:
|
||||||
|
idx_coat = idx
|
||||||
|
idx += 1
|
||||||
|
|
||||||
|
frag.add_out(f'vec4 fragColor[{idx}]' if is_deferred else 'vec4 fragColor[3]')
|
||||||
|
|
||||||
# Remove fragColor = ...;
|
# Remove fragColor = ...;
|
||||||
frag.main = frag.main[:frag.main.rfind('fragColor')]
|
frag.main = frag.main[:frag.main.rfind('fragColor')]
|
||||||
frag.write('\n')
|
frag.write('\n')
|
||||||
@ -53,16 +71,22 @@ def make(context_id):
|
|||||||
else:
|
else:
|
||||||
frag.write('const uint matid = 0;')
|
frag.write('const uint matid = 0;')
|
||||||
|
|
||||||
if rpdat.rp_renderer == 'Deferred':
|
if is_deferred:
|
||||||
frag.write('fragColor[0] = vec4(n.xy, roughness, 1.0);')
|
frag.write('fragColor[0] = vec4(n.xy, roughness, 1.0);')
|
||||||
frag.write('vec3 finalColor = direct + indirect;')
|
frag.write('vec3 finalColor = direct + indirect;')
|
||||||
frag.write('fragColor[1] = vec4(finalColor * opacity, 1.0);')
|
frag.write('fragColor[1] = vec4(finalColor * opacity, 1.0);')
|
||||||
|
frag.write(f'fragColor[{idx_refraction}] = vec4(packIOR(ior), 1.0 - opacity, gl_FragCoord.z, 1.0);')
|
||||||
|
if idx_2 >= 0:
|
||||||
|
frag.write(f'fragColor[{idx_2}] = vec4(0.0);')
|
||||||
|
if idx_emission >= 0:
|
||||||
|
frag.write(f'fragColor[{idx_emission}] = vec4(0.0);')
|
||||||
|
if idx_coat >= 0:
|
||||||
|
frag.write(f'fragColor[{idx_coat}] = vec4(0.0);')
|
||||||
else:
|
else:
|
||||||
frag.write('vec3 finalColor = direct + indirect;')
|
frag.write('vec3 finalColor = direct + indirect;')
|
||||||
frag.write('fragColor[0] = vec4(finalColor * opacity, 1.0);')
|
frag.write('fragColor[0] = vec4(finalColor * opacity, 1.0);')
|
||||||
frag.write('fragColor[1] = vec4(n.xy, roughness, 1.0);')
|
frag.write('fragColor[1] = vec4(n.xy, roughness, 1.0);')
|
||||||
|
frag.write('fragColor[2] = vec4(packIOR(ior), 1.0 - opacity, gl_FragCoord.z, 1.0);')
|
||||||
frag.write('fragColor[2] = vec4(packIOR(ior), 1.0 - opacity, gl_FragCoord.z, 1.0);')
|
|
||||||
# frag.write('fragColor[2] = vec4(ior, 1.0 - opacity, packFloat2(basecol.r, basecol.g), basecol.b);')
|
# frag.write('fragColor[2] = vec4(ior, 1.0 - opacity, packFloat2(basecol.r, basecol.g), basecol.b);')
|
||||||
|
|
||||||
make_finalize.make(con_refract)
|
make_finalize.make(con_refract)
|
||||||
|
|||||||
Reference in New Issue
Block a user