forked from LeenkxTeam/LNXSDK
Reflections / Refractions
This commit is contained in:
@ -936,6 +936,80 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssrefr
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssrefr != false)
|
||||
{
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("gbuffer0", "gbuffer1"); // Unbind depth so we can read it
|
||||
path.depthToRenderTarget.set("main", path.renderTargets.get("tex"));
|
||||
#end
|
||||
|
||||
//save depth
|
||||
path.setTarget("gbufferD1");
|
||||
path.bindTarget("_main", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("gbuffer0", "tex"); // Re-bind depth
|
||||
path.depthToRenderTarget.set("main", path.renderTargets.get("gbuffer0"));
|
||||
#end
|
||||
|
||||
//save background color
|
||||
path.setTarget("refr");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer_refraction"]);
|
||||
|
||||
#if (rp_voxels != "Off")
|
||||
path.bindTarget("voxelsOut", "voxels");
|
||||
#if (rp_voxels == "Voxel GI" || lnx_voxelgi_shadows)
|
||||
path.bindTarget("voxelsSDF", "voxelsSDF");
|
||||
#end
|
||||
#end
|
||||
|
||||
#if rp_shadowmap
|
||||
{
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.bindShadowMapAtlas();
|
||||
#else
|
||||
Inc.bindShadowMap();
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssrs
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
|
||||
path.drawMeshes("refraction");
|
||||
|
||||
path.setTarget("buf");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.bindTarget("gbufferD1", "gbufferD1");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.bindTarget("gbuffer1", "gbuffer1");
|
||||
path.bindTarget("refr", "tex1");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbuffer_refraction", "gbuffer_refraction");
|
||||
|
||||
path.drawShader("shader_datas/ssrefr_pass/ssrefr_pass");
|
||||
|
||||
path.setTarget("tex");
|
||||
path.bindTarget("buf", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_translucency && !rp_ssrefr && rp_ssr)
|
||||
{
|
||||
path.setTarget("tex");
|
||||
path.drawMeshes("depth");
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssr
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssr != false) {
|
||||
@ -1016,73 +1090,6 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssrefr
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssrefr != false)
|
||||
{
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("gbuffer0", "gbuffer1"); // Unbind depth so we can read it
|
||||
path.depthToRenderTarget.set("main", path.renderTargets.get("tex"));
|
||||
#end
|
||||
|
||||
//save depth
|
||||
path.setTarget("gbufferD1");
|
||||
path.bindTarget("_main", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("gbuffer0", "tex"); // Re-bind depth
|
||||
path.depthToRenderTarget.set("main", path.renderTargets.get("gbuffer0"));
|
||||
#end
|
||||
|
||||
//save background color
|
||||
path.setTarget("refr");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer_refraction"]);
|
||||
|
||||
#if (rp_voxels != "Off")
|
||||
path.bindTarget("voxelsOut", "voxels");
|
||||
#if (rp_voxels == "Voxel GI" || lnx_voxelgi_shadows)
|
||||
path.bindTarget("voxelsSDF", "voxelsSDF");
|
||||
#end
|
||||
#end
|
||||
|
||||
#if rp_shadowmap
|
||||
{
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.bindShadowMapAtlas();
|
||||
#else
|
||||
Inc.bindShadowMap();
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssrs
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
|
||||
path.drawMeshes("refraction");
|
||||
|
||||
path.setTarget("buf");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.bindTarget("gbufferD1", "gbufferD1");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.bindTarget("gbuffer1", "gbuffer1");
|
||||
path.bindTarget("refr", "tex1");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbuffer_refraction", "gbuffer_refraction");
|
||||
|
||||
path.drawShader("shader_datas/ssrefr_pass/ssrefr_pass");
|
||||
|
||||
path.setTarget("tex");
|
||||
path.bindTarget("buf", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_chromatic_aberration
|
||||
{
|
||||
path.setTarget("buf");
|
||||
|
||||
@ -247,9 +247,12 @@ def make(context_id, rpasses, shadowmap=False, shadowmap_transparent=False):
|
||||
if parse_opacity and not shadowmap_transparent:
|
||||
if mat_state.material.lnx_discard:
|
||||
opac = mat_state.material.lnx_discard_opacity_shadows
|
||||
frag.write('if (opacity < {0}) discard;'.format(opac))
|
||||
elif rpdat.rp_renderer == 'Deferred' and 'translucent' in rpasses and not shadowmap:
|
||||
pass
|
||||
else:
|
||||
opac = '1.0'
|
||||
frag.write('if (opacity < {0}) discard;'.format(opac))
|
||||
frag.write('if (opacity < {0}) discard;'.format(opac))
|
||||
|
||||
make_finalize.make(con_depth)
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ else:
|
||||
def make(context_id):
|
||||
con_refract = mat_state.data.add_context({
|
||||
'name': context_id,
|
||||
'depth_write': False,
|
||||
'depth_write': True,
|
||||
'compare_mode': 'less',
|
||||
'cull_mode': 'clockwise',
|
||||
'blend_source': 'blend_one',
|
||||
|
||||
@ -55,6 +55,8 @@ def get_rpasses(material):
|
||||
ar.append('voxel')
|
||||
if rpdat.rp_renderer == 'Forward' and rpdat.rp_depthprepass and not material.lnx_blending and not material.lnx_particle_flag:
|
||||
ar.append('depth')
|
||||
if rpdat.rp_renderer == 'Deferred' and rpdat.rp_ssr and 'translucent' in ar:
|
||||
ar.append('depth')
|
||||
|
||||
if material.lnx_cast_shadow and rpdat.rp_shadows and ('mesh' in ar):
|
||||
if 'translucent' in ar or 'refraction' in ar:
|
||||
|
||||
Reference in New Issue
Block a user