-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dcbb24
commit 13b0642
Showing
10 changed files
with
256 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
flutter-ui/src/main/java/com/primogemstudio/advancedfmk/mixin/RenderSystemMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
flutter-ui/src/main/resources/assets/minecraft/shaders/core/blit_no_flip.fsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#version 150 | ||
|
||
uniform sampler2D DiffuseSampler; | ||
|
||
in vec2 texCoord; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() { | ||
fragColor = texture(DiffuseSampler, texCoord); | ||
} |
2 changes: 1 addition & 1 deletion
2
flutter-ui/src/main/resources/assets/minecraft/shaders/core/blit_no_flip.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
flutter-ui/src/main/resources/assets/minecraft/shaders/filter/gaussian_blur.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"targets": [ | ||
"swap" | ||
], | ||
"passes": [ | ||
{ | ||
"name": "gaussian_blur", | ||
"intarget": "minecraft:main", | ||
"outtarget": "swap", | ||
"uniforms": [ | ||
] | ||
}, | ||
{ | ||
"name": "blit", | ||
"intarget": "swap", | ||
"outtarget": "minecraft:main" | ||
} | ||
] | ||
} |
79 changes: 79 additions & 0 deletions
79
flutter-ui/src/main/resources/assets/minecraft/shaders/program/gaussian_blur.fsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#version 150 | ||
|
||
uniform sampler2D DiffuseSampler; | ||
uniform sampler2D InputSampler; | ||
|
||
uniform vec4 ColorModulate; | ||
uniform int Radius; | ||
uniform int DigType; | ||
uniform float NoiseStrength; | ||
|
||
in vec2 texCoord; | ||
in vec2 oneTexel; | ||
|
||
out vec4 fragColor; | ||
|
||
#define PI2 6.2831853072 | ||
|
||
vec4 blur(int samples) { | ||
vec4 O = vec4(0.0); | ||
float r = float(samples)*0.5; | ||
float sigma = r*0.5; | ||
float f = 1./(6.28318530718*sigma*sigma); | ||
|
||
int s2 = samples*samples; | ||
for (int i = 0; i<s2; i++) { | ||
vec2 d = vec2(i%samples, i/samples) - r; | ||
O += texture(DiffuseSampler, texCoord + oneTexel * d) * exp(-0.5 * dot(d/=sigma, d)) * f; | ||
} | ||
// use pre-multiplied alpha | ||
return O/O.a; | ||
} | ||
|
||
vec4 blur_dig2(int samples) { | ||
float count = 1.0; | ||
vec4 color = texture(DiffuseSampler, texCoord); | ||
float directionStep = PI2 / 48; | ||
|
||
vec2 off; | ||
float c, s, dist, dist2, weight; | ||
for (float d = 0.0; d < PI2; d += directionStep) { | ||
c = cos(d); | ||
s = sin(d); | ||
dist = 1.0 / max(abs(c), abs(s)); | ||
dist2 = dist * 3.0; | ||
off = vec2(c, s); | ||
for (float i = dist2; i <= 32.0; i += dist2) { | ||
weight = i / samples; | ||
count += weight; | ||
color += texture(DiffuseSampler, texCoord + off * oneTexel * i) * weight; | ||
} | ||
} | ||
|
||
return color / count; | ||
} | ||
|
||
float random(vec2 st) { | ||
return (fract(sin(dot(st.xy, | ||
vec2(12.9898,78.233)))* | ||
43758.5453123) - 0.5) * 2; | ||
} | ||
|
||
void main() { | ||
vec4 col = texture(InputSampler, texCoord); | ||
vec4 dst = texture(DiffuseSampler, texCoord); | ||
if (col.a <= 0.01) | ||
{ | ||
fragColor = dst * ColorModulate; | ||
return; | ||
} | ||
|
||
col.a = 0.88; | ||
|
||
fragColor = mix(DigType == 0 ? blur(Radius) : blur_dig2(Radius), vec4(col.xyz, 1.0), col.a); | ||
fragColor.x += random(dst.xy * 0.03125 * texCoord) * NoiseStrength; | ||
fragColor.y += random(dst.xz * 0.03125 * texCoord) * NoiseStrength; | ||
fragColor.z += random(dst.yz * 0.03125 * texCoord) * NoiseStrength; | ||
fragColor.a = dst.a; | ||
fragColor *= ColorModulate; | ||
} |
98 changes: 98 additions & 0 deletions
98
flutter-ui/src/main/resources/assets/minecraft/shaders/program/gaussian_blur.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"blend": { | ||
"func": "add", | ||
"srcrgb": "srcalpha", | ||
"dstrgb": "1-srcalpha" | ||
}, | ||
"vertex": "gaussian_blur", | ||
"fragment": "gaussian_blur", | ||
"attributes": [ | ||
"Position" | ||
], | ||
"samplers": [ | ||
{ | ||
"name": "DiffuseSampler" | ||
}, | ||
{ | ||
"name": "InputSampler" | ||
} | ||
], | ||
"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": "ColorModulate", | ||
"type": "float", | ||
"count": 4, | ||
"values": [ | ||
1.0, | ||
1.0, | ||
1.0, | ||
1.0 | ||
] | ||
}, | ||
{ | ||
"name": "Radius", | ||
"type": "int", | ||
"count": 1, | ||
"values": [ | ||
8 | ||
] | ||
}, | ||
{ | ||
"name": "DigType", | ||
"type": "int", | ||
"count": 1, | ||
"values": [ | ||
0 | ||
] | ||
}, | ||
{ | ||
"name": "NoiseStrength", | ||
"type": "float", | ||
"count": 1, | ||
"values": [ | ||
0 | ||
] | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
flutter-ui/src/main/resources/assets/minecraft/shaders/program/gaussian_blur.vsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#version 150 | ||
|
||
in vec4 Position; | ||
|
||
uniform mat4 ProjMat; | ||
uniform vec2 InSize; | ||
uniform vec2 OutSize; | ||
|
||
out vec2 texCoord; | ||
out vec2 oneTexel; | ||
|
||
void main(){ | ||
vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); | ||
gl_Position = vec4(outPos.xy, 0.2, 1.0); | ||
|
||
oneTexel = 1.0 / InSize; | ||
|
||
texCoord = Position.xy / OutSize; | ||
} |