Move Blur to Satin

This commit is contained in:
Pyrofab
2019-07-29 22:30:48 +02:00
parent a7c8ff7526
commit d1d9468482
13 changed files with 49 additions and 275 deletions

View File

@@ -0,0 +1,67 @@
{
"targets": [
"swap"
],
"passes": [
{
"name": "blur:fade_in_blur",
"intarget": "minecraft:main",
"outtarget": "swap",
"uniforms": [
{
"name": "BlurDir",
"values": [ 1.0, 0.0 ]
},
{
"name": "Radius",
"values": [ 8.0 ]
}
]
},
{
"name": "blur:fade_in_blur",
"intarget": "swap",
"outtarget": "minecraft:main",
"uniforms": [
{
"name": "BlurDir",
"values": [ 0.0, 1.0 ]
},
{
"name": "Radius",
"values": [ 8.0 ]
}
]
},
{
"name": "blur:fade_in_blur",
"intarget": "minecraft:main",
"outtarget": "swap",
"uniforms": [
{
"name": "BlurDir",
"values": [ 1.0, 0.0 ]
},
{
"name": "Radius",
"values": [ 8.0 ]
}
]
},
{
"name": "blur:fade_in_blur",
"intarget": "swap",
"outtarget": "minecraft:main",
"uniforms": [
{
"name": "BlurDir",
"values": [ 0.0, 1.0 ]
},
{
"name": "Radius",
"values": [ 8.0 ]
}
]
}
]
}

View File

@@ -0,0 +1,33 @@
#version 120
uniform sampler2D DiffuseSampler;
varying vec2 texCoord;
varying vec2 oneTexel;
uniform vec2 InSize;
uniform vec2 BlurDir;
uniform float Radius;
uniform float Progress;
void main() {
vec4 blurred = vec4(0.0);
float totalStrength = 0.0;
float totalAlpha = 0.0;
float totalSamples = 0.0;
float progRadius = floor(Radius * Progress);
for(float r = -progRadius; r <= progRadius; r += 1.0) {
vec4 sample = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir);
// Accumulate average alpha
totalAlpha = totalAlpha + sample.a;
totalSamples = totalSamples + 1.0;
// Accumulate smoothed blur
float strength = 1.0 - abs(r / progRadius);
totalStrength = totalStrength + strength;
blurred = blurred + sample;
}
gl_FragColor = vec4(blurred.rgb / (progRadius * 2.0 + 1.0), totalAlpha);
}

View File

@@ -0,0 +1,21 @@
{
"blend": {
"func": "add",
"srcrgb": "one",
"dstrgb": "zero"
},
"vertex": "sobel",
"fragment": "blur:fade_in_blur",
"attributes": [ "Position" ],
"samplers": [
{ "name": "DiffuseSampler" }
],
"uniforms": [
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
{ "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
{ "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] },
{ "name": "Progress", "type": "float", "count": 1, "values": [ 0.0 ] }
]
}