-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Showing
2 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
src/main/resources/assets/malum/shaders/core/gravity_vortex.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,74 @@ | ||
#version 150 | ||
|
||
#moj_import <fog.glsl> | ||
|
||
const float numRings = 20.0; | ||
const vec2 center = vec2(0.5); | ||
const float spacing = 1.0 / numRings; | ||
const float slow = 30.0; | ||
const float cycleDur = 1.0; | ||
const float tunnelElongation = 0.25; | ||
|
||
uniform sampler2D Sampler0; | ||
|
||
uniform float GameTime; | ||
|
||
uniform vec4 ColorModulator; | ||
uniform float FogStart; | ||
uniform float FogEnd; | ||
uniform vec4 FogColor; | ||
|
||
in float vertexDistance; | ||
in vec4 vertexColor; | ||
in vec4 lightMapColor; | ||
in vec4 overlayColor; | ||
in vec2 texCoord0; | ||
in vec4 normal; | ||
|
||
out vec4 fragColor; | ||
|
||
//taken from https://www.shadertoy.com/view/ltBXRc | ||
float variation(vec2 v1, vec2 v2, float strength, float speed) { | ||
return sin(dot(normalize(v1), normalize(v2)) * strength + GameTime * 1000 * speed) / 100.0; | ||
} | ||
|
||
//taken from https://www.shadertoy.com/view/ltBXRc | ||
vec3 paintCircle (vec2 uv, vec2 center, float rad, float width, float index) { | ||
vec2 diff = center-uv; | ||
float len = length(diff); | ||
float scale = rad; | ||
float mult = mod(index, 2.) == 0. ? 1. : -1.; | ||
len += variation(diff, vec2(rad*mult, 1.0), 7.0*scale, 2.0); | ||
len -= variation(diff, vec2(1.0, rad*mult), 7.0*scale, 2.0); | ||
float circle = smoothstep((rad-width)*scale, (rad)*scale, len) - smoothstep((rad)*scale, (rad+width)*scale, len); | ||
return vec3(circle); | ||
} | ||
|
||
|
||
vec3 paintRing(vec2 uv, vec2 center, float radius, float index){ | ||
vec3 color = paintCircle(uv, center, radius, 0.075, index); | ||
color *= vec3(0.9,0.05,0.9); | ||
color += paintCircle(uv, center, radius, 0.015, index); //White | ||
return color; | ||
} | ||
|
||
|
||
void main() { | ||
vec2 uv = texCoord0; | ||
|
||
float radius = mod(1000 * GameTime/slow, cycleDur); | ||
vec3 color; | ||
|
||
float border = 0.25; | ||
vec2 bl = smoothstep(0.0, border, uv); | ||
vec2 tr = smoothstep(0.0, border, 1.0 - uv); | ||
|
||
for(float i = 0.0; i < numRings; i++){ | ||
color += paintRing(uv, center, tunnelElongation*log(mod(radius + i * spacing, cycleDur)), i ); | ||
color += paintRing(uv, center, log(mod(radius + i * spacing, cycleDur)), i); | ||
} | ||
|
||
color = mix(color, vec3(0.0), distance(uv, center) * 1.95); | ||
|
||
fragColor = vec4(color, 0.5); | ||
} |
149 changes: 149 additions & 0 deletions
149
src/main/resources/assets/malum/shaders/core/gravity_vortex.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,149 @@ | ||
{ | ||
"blend": { | ||
"func": "add", | ||
"srcrgb": "srcalpha", | ||
"dstrgb": "1-srcalpha" | ||
}, | ||
"vertex": "lodestone:generic", | ||
"fragment": "malum:gravity_vortex", | ||
"attributes": [ | ||
"Position", | ||
"Color", | ||
"UV0", | ||
"UV2" | ||
], | ||
"samplers": [ | ||
{ | ||
"name": "Sampler0" | ||
}, | ||
{ | ||
"name": "Sampler2" | ||
} | ||
], | ||
"uniforms": [ | ||
{ | ||
"name": "ModelViewMat", | ||
"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": "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": "IViewRotMat", | ||
"type": "matrix3x3", | ||
"count": 9, | ||
"values": [ | ||
1.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
1.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
1.0 | ||
] | ||
}, | ||
{ | ||
"name": "ColorModulator", | ||
"type": "float", | ||
"count": 4, | ||
"values": [ | ||
1.0, | ||
1.0, | ||
1.0, | ||
1.0 | ||
] | ||
}, | ||
{ | ||
"name": "FogStart", | ||
"type": "float", | ||
"count": 1, | ||
"values": [ | ||
0.0 | ||
] | ||
}, | ||
{ | ||
"name": "FogEnd", | ||
"type": "float", | ||
"count": 1, | ||
"values": [ | ||
1.0 | ||
] | ||
}, | ||
{ | ||
"name": "FogColor", | ||
"type": "float", | ||
"count": 4, | ||
"values": [ | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0 | ||
] | ||
}, | ||
{ | ||
"name": "FogShape", | ||
"type": "int", | ||
"count": 1, | ||
"values": [ | ||
0 | ||
] | ||
}, | ||
{ | ||
"name": "GameTime", | ||
"type": "float", | ||
"count": 1, | ||
"values": [ | ||
0.0 | ||
] | ||
}, | ||
{ | ||
"name": "LumiTransparency", | ||
"type": "float", | ||
"count": 1, | ||
"values": [ | ||
0.0 | ||
] | ||
} | ||
] | ||
} |