mirror of
https://github.com/Cametendo/EMVs-Creative-coding.git
synced 2026-06-20 17:45:02 +02:00
Compare commits
2 Commits
05b8bae8c0
...
ec3ac51a89
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec3ac51a89 | ||
|
|
e1df61d3c6 |
67
README.md
Normal file
67
README.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
## Website:
|
||||||
|
|
||||||
|
Link to the Repository:
|
||||||
|
https://github.com/cametendo/EMVs-Creative-coding or
|
||||||
|
https://gitea.cametendo.org/Cametendo/EMVs-Creative-coding
|
||||||
|
|
||||||
|
Pre-requisities:
|
||||||
|
|
||||||
|
- p5.js v1.10.0
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Recommendation:
|
||||||
|
|
||||||
|
- VSCode Extension: FiveServer
|
||||||
|
- Python 3.14.5
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
To open the website, click the little "Go Live" Button in the toolbar on the bottom right and then go to /website/index.html in the browser. There you will find all the cool stuff I did.
|
||||||
|
|
||||||
|
Another way to open the website is by using python:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /path/to/your/EMVs-Creative-coding && python -m http.server
|
||||||
|
```
|
||||||
|
|
||||||
|
Example output:
|
||||||
|
|
||||||
|
```
|
||||||
|
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Access it via: `http://localhost:8000/website/`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Minecraft Mod:
|
||||||
|
|
||||||
|
Pre-Requisities:
|
||||||
|
|
||||||
|
- fabric-api-0.141.4+1.21.11.jar
|
||||||
|
- iris-fabric-1.10.7+mc1.21.11.jar
|
||||||
|
- sodium-fabric-0.8.11+mc1.21.11.jar
|
||||||
|
|
||||||
|
To play with the mod, drag the `mc_kuwahara_shader` Folder into `/path/to/your/.minecraft/shaderpacks/`. When you did it correctly, you should get `/.../shaderpacks/mc_kuwahara_shader`.
|
||||||
|
|
||||||
|
The final tree structure should look like this:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/.../.minecraft/shaderpacks/mc_kuwahara_shader
|
||||||
|
├── final.fsh.settings
|
||||||
|
├── shaders
|
||||||
|
│ ├── final.fsh
|
||||||
|
│ ├── final.vsh
|
||||||
|
│ ├── gbuffers_terrain.fsh
|
||||||
|
│ └── gbuffers_terrain.vsh
|
||||||
|
└── shaders.properties
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: It is not recommend to play this shader with integrated graphics (in fullscreen mode). The minimum required GPUs for this shader are:
|
||||||
|
|
||||||
|
- Nvidia: GTX 750 Ti
|
||||||
|
- AMD: RX 460
|
||||||
|
- Intel: UHD
|
||||||
|
|
||||||
|
If you do need to change the settings because of FPS, go to `/mc_kuwahara_shader/shaders/final.fsh` and change `STEP` from 3 to 4 (or 3 to 2 or even 3 to 1, if your PC is srong enough ;D)
|
||||||
1
mc_kuwahara_shader/final.fsh.settings
Normal file
1
mc_kuwahara_shader/final.fsh.settings
Normal file
@@ -0,0 +1 @@
|
|||||||
|
shadowmap=false
|
||||||
3
mc_kuwahara_shader/shaders.properties
Normal file
3
mc_kuwahara_shader/shaders.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
separateAo=true
|
||||||
|
shadowMapResolution=0
|
||||||
|
generateShadowMap=false
|
||||||
59
mc_kuwahara_shader/shaders/final.fsh
Normal file
59
mc_kuwahara_shader/shaders/final.fsh
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#version 150
|
||||||
|
|
||||||
|
uniform float viewWidth;
|
||||||
|
uniform float viewHeight;
|
||||||
|
uniform sampler2D colortex0;
|
||||||
|
|
||||||
|
in vec2 texCoord;
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
// Tune these to trade quality vs performance:
|
||||||
|
// RADIUS 36, STEP 1 → 5476 samples/pixel (original, ~9fps)
|
||||||
|
// RADIUS 36, STEP 3 → 676 samples/pixel (~8x faster)
|
||||||
|
// RADIUS 36, STEP 4 → 400 samples/pixel (~14x faster)
|
||||||
|
// RADIUS 16, STEP 2 → 324 samples/pixel (smaller brush, fast)
|
||||||
|
#define RADIUS 36
|
||||||
|
#define STEP 3
|
||||||
|
|
||||||
|
vec3 kuwahara_region(vec2 uv, vec2 ts, int x0, int x1, int y0, int y1, out float outVariance) {
|
||||||
|
vec3 colorSum = vec3(0.0);
|
||||||
|
float lumaSum = 0.0;
|
||||||
|
float lumaSqSum = 0.0;
|
||||||
|
float count = 0.0;
|
||||||
|
|
||||||
|
for (int i = x0; i <= x1; i += STEP) {
|
||||||
|
for (int j = y0; j <= y1; j += STEP) {
|
||||||
|
vec3 c = texture(colortex0, uv + vec2(float(i), float(j)) * ts).rgb;
|
||||||
|
float luma = dot(c, vec3(0.299, 0.587, 0.114));
|
||||||
|
colorSum += c;
|
||||||
|
lumaSum += luma;
|
||||||
|
lumaSqSum += luma * luma;
|
||||||
|
count += 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 mean = colorSum / count;
|
||||||
|
float meanLuma = lumaSum / count;
|
||||||
|
float variance = (lumaSqSum / count) - (meanLuma * meanLuma);
|
||||||
|
outVariance = variance * variance; // square for harder selection
|
||||||
|
return mean;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec2 ts = vec2(1.0 / viewWidth, 1.0 / viewHeight);
|
||||||
|
|
||||||
|
float v_tr, v_tl, v_bl, v_br;
|
||||||
|
vec3 mean_tr = kuwahara_region(texCoord, ts, 0, RADIUS, 0, RADIUS, v_tr);
|
||||||
|
vec3 mean_tl = kuwahara_region(texCoord, ts, -RADIUS, 0, 0, RADIUS, v_tl);
|
||||||
|
vec3 mean_bl = kuwahara_region(texCoord, ts, -RADIUS, 0, -RADIUS, 0, v_bl);
|
||||||
|
vec3 mean_br = kuwahara_region(texCoord, ts, 0, RADIUS, -RADIUS, 0, v_br);
|
||||||
|
|
||||||
|
vec3 finalColor = mean_tr;
|
||||||
|
float minVar = v_tr;
|
||||||
|
|
||||||
|
if (v_tl < minVar) { minVar = v_tl; finalColor = mean_tl; }
|
||||||
|
if (v_bl < minVar) { minVar = v_bl; finalColor = mean_bl; }
|
||||||
|
if (v_br < minVar) { minVar = v_br; finalColor = mean_br; }
|
||||||
|
|
||||||
|
fragColor = vec4(finalColor, 1.0);
|
||||||
|
}
|
||||||
11
mc_kuwahara_shader/shaders/final.vsh
Normal file
11
mc_kuwahara_shader/shaders/final.vsh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#version 150
|
||||||
|
|
||||||
|
in vec3 vaPosition;
|
||||||
|
in vec2 vaUV0;
|
||||||
|
|
||||||
|
out vec2 texCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(vaPosition.xy * 2.0 - 1.0, 0.0, 1.0);
|
||||||
|
texCoord = vaUV0;
|
||||||
|
}
|
||||||
20
mc_kuwahara_shader/shaders/gbuffers_terrain.fsh
Normal file
20
mc_kuwahara_shader/shaders/gbuffers_terrain.fsh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#version 150
|
||||||
|
|
||||||
|
/* DRAWBUFFERS:0 */
|
||||||
|
|
||||||
|
uniform sampler2D gtexture;
|
||||||
|
uniform sampler2D lightmap;
|
||||||
|
|
||||||
|
in vec2 texCoord;
|
||||||
|
in vec4 tintColor;
|
||||||
|
in vec2 lightCoord;
|
||||||
|
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 color = texture(gtexture, texCoord);
|
||||||
|
if (color.a < 0.1) discard;
|
||||||
|
color *= tintColor;
|
||||||
|
color.rgb *= texture(lightmap, lightCoord).rgb;
|
||||||
|
fragColor = color;
|
||||||
|
}
|
||||||
21
mc_kuwahara_shader/shaders/gbuffers_terrain.vsh
Normal file
21
mc_kuwahara_shader/shaders/gbuffers_terrain.vsh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#version 150
|
||||||
|
|
||||||
|
uniform mat4 modelViewMatrix;
|
||||||
|
uniform mat4 projectionMatrix;
|
||||||
|
uniform vec3 chunkOffset;
|
||||||
|
|
||||||
|
in vec3 vaPosition;
|
||||||
|
in vec4 vaColor;
|
||||||
|
in vec2 vaUV0;
|
||||||
|
in ivec2 vaUV2;
|
||||||
|
|
||||||
|
out vec2 texCoord;
|
||||||
|
out vec4 tintColor;
|
||||||
|
out vec2 lightCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(vaPosition + chunkOffset, 1.0);
|
||||||
|
texCoord = vaUV0;
|
||||||
|
tintColor = vaColor;
|
||||||
|
lightCoord = vaUV2 / 256.0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user