mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-04 07:31:16 +00:00 
			
		
		
		
	Merge pull request #65322 from ceLoFaN/fix-dof-artifact-at-high-blur
This commit is contained in:
		
						commit
						ecaa7b634e
					
				
					 2 changed files with 6 additions and 8 deletions
				
			
		| 
						 | 
					@ -186,6 +186,7 @@ void main() {
 | 
				
			||||||
	uv += pixel_size * 0.5; //half pixel to read centers
 | 
						uv += pixel_size * 0.5; //half pixel to read centers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vec4 color = texture(color_texture, uv);
 | 
						vec4 color = texture(color_texture, uv);
 | 
				
			||||||
 | 
						float initial_blur = color.a;
 | 
				
			||||||
	float accum = 1.0;
 | 
						float accum = 1.0;
 | 
				
			||||||
	float radius = params.blur_scale;
 | 
						float radius = params.blur_scale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -193,8 +194,8 @@ void main() {
 | 
				
			||||||
		vec2 suv = uv + vec2(cos(ang), sin(ang)) * pixel_size * radius;
 | 
							vec2 suv = uv + vec2(cos(ang), sin(ang)) * pixel_size * radius;
 | 
				
			||||||
		vec4 sample_color = texture(color_texture, suv);
 | 
							vec4 sample_color = texture(color_texture, suv);
 | 
				
			||||||
		float sample_size = abs(sample_color.a);
 | 
							float sample_size = abs(sample_color.a);
 | 
				
			||||||
		if (sample_color.a > color.a) {
 | 
							if (sample_color.a > initial_blur) {
 | 
				
			||||||
			sample_size = clamp(sample_size, 0.0, abs(color.a) * 2.0);
 | 
								sample_size = clamp(sample_size, 0.0, abs(initial_blur) * 2.0);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		float m = smoothstep(radius - 0.5, radius + 0.5, sample_size);
 | 
							float m = smoothstep(radius - 0.5, radius + 0.5, sample_size);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -221,12 +221,9 @@ void main() {
 | 
				
			||||||
		vec4 sample_color = texture(source_color, uv_adj);
 | 
							vec4 sample_color = texture(source_color, uv_adj);
 | 
				
			||||||
		sample_color.a = texture(source_weight, uv_adj).r;
 | 
							sample_color.a = texture(source_weight, uv_adj).r;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		float limit;
 | 
							float limit = abs(sample_color.a);
 | 
				
			||||||
 | 
							if (sample_color.a > color.a) {
 | 
				
			||||||
		if (sample_color.a < color.a) {
 | 
								limit = clamp(limit, 0.0, abs(color.a) * 2.0);
 | 
				
			||||||
			limit = abs(sample_color.a);
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			limit = abs(color.a);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		limit -= DEPTH_GAP;
 | 
							limit -= DEPTH_GAP;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue