You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Merge pull request #99551 from DarioSamo/fragment-density-map
Implement Fragment density map support.
This commit is contained in:
@@ -59,7 +59,11 @@ layout(location = 0) in vec2 uv_interp;
|
||||
layout(set = 0, binding = 0) uniform sampler2D source_color;
|
||||
#endif /* USE_MULTIVIEW */
|
||||
|
||||
#ifdef SPLIT_RG
|
||||
layout(location = 0) out vec2 frag_color;
|
||||
#else
|
||||
layout(location = 0) out uint frag_color;
|
||||
#endif
|
||||
|
||||
layout(push_constant, std430) uniform Params {
|
||||
float max_texel_factor;
|
||||
@@ -79,6 +83,10 @@ void main() {
|
||||
// Input is standardized. R for X, G for Y, 0.0 (0) = 1, 0.33 (85) = 2, 0.66 (170) = 3, 1.0 (255) = 8
|
||||
vec4 color = textureLod(source_color, uv, 0.0);
|
||||
|
||||
#ifdef SPLIT_RG
|
||||
// Density map for VRS according to VK_EXT_fragment_density_map, we can use as is.
|
||||
frag_color = max(vec2(1.0f) - color.rg, vec2(1.0f / 255.0f));
|
||||
#else
|
||||
// Output image shading rate image for VRS according to VK_KHR_fragment_shading_rate.
|
||||
color.r = clamp(floor(color.r * params.max_texel_factor + 0.1), 0.0, params.max_texel_factor);
|
||||
color.g = clamp(floor(color.g * params.max_texel_factor + 0.1), 0.0, params.max_texel_factor);
|
||||
@@ -94,4 +102,5 @@ void main() {
|
||||
// Encode to frag_color;
|
||||
frag_color = int(color.r + 0.1) << 2;
|
||||
frag_color += int(color.g + 0.1);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user