Added multisampling to shader
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform vec2 target_tex_size = vec2(1280,720);
|
||||
uniform int sample_count:hint_range(1, 20) = 1;
|
||||
|
||||
uniform float color_steps:hint_range(1.0, 255.0, 1.0);
|
||||
uniform sampler2D color_curve;
|
||||
@@ -10,12 +11,31 @@ void vertex() {
|
||||
// Called for every vertex the material is visible on.
|
||||
}
|
||||
|
||||
vec2 spiralPoint(float t, float spacing)
|
||||
{
|
||||
float b = spacing / (2.0 * PI);
|
||||
float r = b * t;
|
||||
|
||||
return vec2(
|
||||
r * cos(t),
|
||||
r * sin(t)
|
||||
);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
//vec2 texSize = vec2(textureSize(TEXTURE,0)); // For performance reasons, this function should be avoided as it always performs a full texture read. When possible, you should pass the texture size as a uniform instead.
|
||||
//texSize = texSize / 4.;
|
||||
ivec2 intUv = ivec2(target_tex_size * UV);
|
||||
vec2 flooredUv = vec2(intUv) / target_tex_size;
|
||||
vec3 fullColor = texture(TEXTURE,flooredUv).rgb;
|
||||
vec2 uvPixelWidth = 1. / target_tex_size;
|
||||
|
||||
vec3 fullColor = vec3(0);
|
||||
for(int i = 0;i<sample_count;i++){
|
||||
float f = float(i);
|
||||
fullColor += texture(TEXTURE,flooredUv+spiralPoint(f*2.,uvPixelWidth.x / (float(sample_count)/6.283))).rgb;
|
||||
}
|
||||
fullColor /= float(sample_count);
|
||||
|
||||
vec3 strechedColor = vec3(
|
||||
texture(color_curve,vec2(fullColor.r,0)).r,
|
||||
texture(color_curve,vec2(fullColor.g,0)).g,
|
||||
|
||||
Reference in New Issue
Block a user