Anti-aliased overlays
This commit is contained in:
parent
02bd6dde8a
commit
48dc9d0147
|
@ -132,7 +132,7 @@ void main() {
|
|||
#endif
|
||||
|
||||
#ifdef _CDepth
|
||||
float depth = texture(gbufferD, texCo).r * 2.0 - 1.0;
|
||||
float depth = (1.0 - texture(gbuffer0, texCo).a) * 2.0 - 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef _CFXAA
|
||||
|
@ -187,7 +187,7 @@ void main() {
|
|||
#else
|
||||
|
||||
#ifdef _CDOF
|
||||
vec3 col = dof(texCo, depth, tex, gbufferD, texStep);
|
||||
vec3 col = dof(texCo, depth, tex, gbuffer0, texStep);
|
||||
#else
|
||||
vec3 col = texture(tex, texCo).rgb;
|
||||
#endif
|
||||
|
@ -210,7 +210,7 @@ void main() {
|
|||
vec4 lndc = VP * vec4(light, 1.0);
|
||||
lndc.xy /= lndc.w;
|
||||
vec2 lss = lndc.xy * 0.5 + 0.5;
|
||||
float lssdepth = linearize(texture(gbufferD, lss).r * 2.0 - 1.0);
|
||||
float lssdepth = linearize((1.0 - texture(gbuffer0, lss).a) * 2.0 - 1.0);
|
||||
float lightDistance = distance(eye, light);
|
||||
if (lightDistance <= lssdepth) {
|
||||
vec2 lensuv = texCo * 2.0 - 1.0;
|
||||
|
|
|
@ -33,10 +33,10 @@ vec3 color(vec2 coords, const float blur, const sampler2D tex, const vec2 texSte
|
|||
return col + mix(vec3(0.0), col, thresh * blur);
|
||||
}
|
||||
|
||||
vec3 dof(const vec2 texCoord, const float gdepth, const sampler2D tex, const sampler2D gbufferD, const vec2 texStep) {
|
||||
vec3 dof(const vec2 texCoord, const float gdepth, const sampler2D tex, const sampler2D gbuffer0, const vec2 texStep) {
|
||||
float depth = linearize(gdepth);
|
||||
const float fDepth = compoDOFDistance;
|
||||
// float fDepth = linearize(texture(gbufferD, focus).r * 2.0 - 1.0); // Autofocus
|
||||
// float fDepth = linearize((1.0 - texture(gbuffer0, focus).a) * 2.0 - 1.0); // Autofocus
|
||||
|
||||
const float f = compoDOFLength; // Focal length in mm
|
||||
const float d = fDepth * 1000.0; // Focal plane in mm
|
||||
|
|
Binary file not shown.
|
@ -112,10 +112,15 @@ def make_deferred(cam):
|
|||
if not cam.rp_ssr:
|
||||
relink('SSR', 'Draw Compositor')
|
||||
|
||||
last_node = 'Draw Compositor'
|
||||
if not cam.rp_compositornodes:
|
||||
pass
|
||||
|
||||
last_node = 'Draw Compositor'
|
||||
if cam.rp_overlays:
|
||||
links.new(nodes[last_node].outputs[0], nodes['Clear Target Overlay'].inputs[0])
|
||||
last_node = 'Draw Meshes Overlay'
|
||||
links.new(nodes[last_node].outputs[0], nodes['SMAA'].inputs[0])
|
||||
|
||||
if cam.rp_antialiasing == 'SMAA':
|
||||
last_node = 'SMAA'
|
||||
elif cam.rp_antialiasing == 'TAA':
|
||||
|
@ -132,6 +137,3 @@ def make_deferred(cam):
|
|||
l = nodes['Draw Compositor'].outputs[0].links[0]
|
||||
links.remove(l)
|
||||
links.new(nodes['Framebuffer'].outputs[0], nodes['Draw Compositor'].inputs[1])
|
||||
|
||||
if cam.rp_overlays:
|
||||
links.new(nodes[last_node].outputs[0], nodes['Clear Target Overlay'].inputs[0])
|
||||
|
|
|
@ -231,24 +231,24 @@ def make_draw_compositor(stage, node_group, node, with_fxaa=False):
|
|||
compo_depth = False # Read depth
|
||||
# compo_pos = False # Construct position from depth
|
||||
if with_fxaa: # FXAA directly in compositor, useful for forward path
|
||||
compositor_defs += '_CompoFXAA'
|
||||
compositor_defs += '_CFXAA'
|
||||
if wrd.generate_letterbox:
|
||||
compositor_defs += '_CompoLetterbox'
|
||||
compositor_defs += '_CLetterbox'
|
||||
if wrd.generate_grain:
|
||||
compositor_defs += '_CompoGrain'
|
||||
compositor_defs += '_CGrain'
|
||||
if bpy.data.scenes[0].cycles.film_exposure != 1.0:
|
||||
compositor_defs += '_CompoExposure'
|
||||
compositor_defs += '_CExposure'
|
||||
if wrd.generate_fog:
|
||||
compositor_defs += '_CompoFog'
|
||||
compositor_defs += '_CFog'
|
||||
# compo_pos = True
|
||||
if build_node_tree.cam.dof_distance > 0.0:
|
||||
compositor_defs += '_CompoDOF'
|
||||
compositor_defs += '_CDOF'
|
||||
compo_depth = True
|
||||
# if compo_pos:
|
||||
# compositor_defs += '_CompoPos'
|
||||
# compositor_defs += '_CPos'
|
||||
# compo_depth = True
|
||||
if compo_depth:
|
||||
compositor_defs += '_CompoDepth'
|
||||
compositor_defs += '_CDepth'
|
||||
|
||||
wrd.compo_defs = compositor_defs
|
||||
|
||||
|
|
|
@ -290,7 +290,6 @@ def make_forward_base(con_mesh, parse_opacity=False):
|
|||
frag.write('vec3 direct = lambertDiffuseBRDF(albedo, dotNL);')
|
||||
frag.write('direct += specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);')
|
||||
|
||||
|
||||
if '_Irr' in wrd.world_defs:
|
||||
frag.write('vec3 indirect = (shIrradiance(n, 2.2) / PI) * albedo;')
|
||||
|
||||
|
|
|
@ -5,6 +5,11 @@ import material.make_mesh as make_mesh
|
|||
def make(context_id):
|
||||
con_overlay = mat_state.data.add_context({ 'name': context_id, 'depth_write': True, 'compare_mode': 'less', 'cull_mode': 'clockwise' })
|
||||
|
||||
make_mesh.forward(con_overlay)
|
||||
make_mesh.make_base(con_overlay, parse_opacity=False)
|
||||
|
||||
frag = con_overlay.frag
|
||||
frag.add_out('vec4 fragColor')
|
||||
frag.write('fragColor = vec4(basecol, 1.0);')
|
||||
frag.write('fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / 2.2));')
|
||||
|
||||
return con_overlay
|
||||
|
|
Loading…
Reference in a new issue