diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-04-11 14:43:12 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-04-11 19:44:07 -0300 |
commit | d81911490b447541b21305c16d27b078c184f9fe (patch) | |
tree | 49cc4038a2a94011cbe5100d142358ddddfa8278 /servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl | |
parent | ae42cb7b0a41f1248ddef408671961da8a6e9770 (diff) |
Moved most of the effect code to compute.
Simplifies it and improves performance.
Improves image barrier handling per mipmap on RenderingDeviceVulkan
Diffstat (limited to 'servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl')
-rw-r--r-- | servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl b/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl new file mode 100644 index 0000000000..1f499cf372 --- /dev/null +++ b/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl @@ -0,0 +1,68 @@ +/* clang-format off */ +[vertex] + +#version 450 + +VERSION_DEFINES + +layout(location = 0) out vec2 uv_interp; +/* clang-format on */ + +layout(push_constant, binding = 1, std430) uniform Params { + vec4 section; + vec2 pixel_size; + bool flip_y; + bool use_section; + bool force_luminance; + uint pad[3]; +} +params; + +void main() { + + vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0)); + uv_interp = base_arr[gl_VertexIndex]; + + if (params.use_section) { + uv_interp = params.section.xy + uv_interp * params.section.zw; + } + + gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0); + + if (params.flip_y) { + uv_interp.y = 1.0 - uv_interp.y; + } +} + +/* clang-format off */ +[fragment] + +#version 450 + +VERSION_DEFINES + +layout(push_constant, binding = 1, std430) uniform Params { + vec4 section; + vec2 pixel_size; + bool flip_y; + bool use_section; + bool force_luminance; + uint pad[3]; +} params; + + +layout(location = 0) in vec2 uv_interp; +/* clang-format on */ + +layout(set = 0, binding = 0) uniform sampler2D source_color; + +layout(location = 0) out vec4 frag_color; + +void main() { + + vec4 color = texture(source_color, uv_interp, 0.0); + if (params.force_luminance) { + color.rgb = vec3(max(max(color.r, color.g), color.b)); + } + frag_color = color; +} |