editor icons are darker when they are behind some scene geom

This commit is contained in:
Mikulas Florek 2019-09-27 00:28:12 +02:00
parent a24f2c853e
commit 482a2f85f9
2 changed files with 22 additions and 6 deletions

View file

@ -1,3 +1,5 @@
include "pipelines/common.glsl"
texture_slot { texture_slot {
name = "Albedo", name = "Albedo",
default_texture = "textures/common/white.tga" default_texture = "textures/common/white.tga"
@ -16,10 +18,13 @@ vertex_shader [[
const vec2 a_uv = vec2(0, 0); const vec2 a_uv = vec2(0, 0);
#endif #endif
layout (location = 0) out vec2 v_uv; layout (location = 0) out vec2 v_uv;
layout (location = 1) out vec3 v_wpos;
void main() { void main() {
v_uv = a_uv; v_uv = a_uv;
gl_Position = u_camera_projection * u_camera_view * u_model * vec4(a_position, 1); vec4 p = u_camera_view * u_model * vec4(a_position, 1);
v_wpos = p.xyz;
gl_Position = u_camera_projection * p;
} }
]] ]]
@ -27,15 +32,20 @@ vertex_shader [[
fragment_shader [[ fragment_shader [[
layout (binding=0) uniform sampler2D u_albedomap; layout (binding=0) uniform sampler2D u_albedomap;
layout (binding=1) uniform sampler2D u_gbuffer_depth;
layout (location = 0) in vec2 v_uv; layout (location = 0) in vec2 v_uv;
layout (location = 1) in vec3 v_wpos;
layout(location = 0) out vec4 o_color; layout(location = 0) out vec4 o_color;
void main() { void main() {
vec2 screen_uv = gl_FragCoord.xy / u_framebuffer_size;
vec3 wpos = getViewPosition(u_gbuffer_depth, u_camera_inv_view_projection, screen_uv);
vec4 albedo = texture(u_albedomap, v_uv); vec4 albedo = texture(u_albedomap, v_uv);
#ifdef ALPHA_CUTOUT #ifdef ALPHA_CUTOUT
if(albedo.a < 0.5) discard; if(albedo.a < 0.5) discard;
#endif #endif
o_color.rgb = albedo.rgb; o_color.rgb = albedo.rgb;
o_color.w = 1; o_color.a = 1;
if(length(wpos) < length(v_wpos)) o_color.rgb *= 0.25;
} }
]] ]]

View file

@ -270,9 +270,11 @@ function main()
end end
debugPass(res, shadowmap) debugPass(res, shadowmap)
local icon_ds = -1
if SCENE_VIEW ~= nil then if SCENE_VIEW ~= nil then
icon_ds = createRenderbuffer(1, 1, true, "depth24stencil8", "icon_ds")
pass(getCameraParams()) pass(getCameraParams())
setRenderTargets(res, gbuffer_depth) setRenderTargets(res, icon_ds)
clear(CLEAR_DEPTH, 0, 0, 0, 1, 0) clear(CLEAR_DEPTH, 0, 0, 0, 1, 0)
renderGizmos() renderGizmos()
end end
@ -280,11 +282,15 @@ function main()
render2D() render2D()
if SCENE_VIEW ~= nil then if SCENE_VIEW ~= nil then
if enable_icons then
renderIcons()
end
renderDebugShapes() renderDebugShapes()
renderSelectionOutline(res) renderSelectionOutline(res)
if enable_icons then
setRenderTargets(res, icon_ds)
bindRenderbuffers({
gbuffer_depth,
}, 1)
renderIcons()
end
end end
setOutput(res) setOutput(res)