51 lines
No EOL
1.2 KiB
Text
51 lines
No EOL
1.2 KiB
Text
include "pipelines/common.glsl"
|
|
|
|
texture_slot {
|
|
name = "Albedo",
|
|
default_texture = "textures/common/white.tga"
|
|
}
|
|
|
|
------------------
|
|
|
|
vertex_shader [[
|
|
layout(std140, binding = 4) uniform Model {
|
|
mat4 u_model;
|
|
};
|
|
layout(location = 0) in vec3 a_position;
|
|
#ifdef _HAS_ATTR1
|
|
layout(location = 1) in vec2 a_uv;
|
|
#else
|
|
const vec2 a_uv = vec2(0, 0);
|
|
#endif
|
|
layout (location = 0) out vec2 v_uv;
|
|
layout (location = 1) out vec3 v_wpos;
|
|
|
|
void main() {
|
|
v_uv = a_uv;
|
|
vec4 p = u_camera_view * u_model * vec4(a_position, 1);
|
|
v_wpos = p.xyz;
|
|
gl_Position = u_camera_projection * p;
|
|
}
|
|
]]
|
|
|
|
---------------------
|
|
|
|
fragment_shader [[
|
|
layout (binding=0) uniform sampler2D u_albedomap;
|
|
layout (binding=1) uniform sampler2D u_gbuffer_depth;
|
|
layout (location = 0) in vec2 v_uv;
|
|
layout (location = 1) in vec3 v_wpos;
|
|
layout(location = 0) out vec4 o_color;
|
|
|
|
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);
|
|
#ifdef ALPHA_CUTOUT
|
|
if(albedo.a < 0.5) discard;
|
|
#endif
|
|
o_color.rgb = albedo.rgb;
|
|
o_color.a = 1;
|
|
if(length(wpos) < length(v_wpos)) o_color.rgb *= 0.25;
|
|
}
|
|
]] |