diff options
| author | Sampsa <69092953+S4mpsa@users.noreply.github.com> | 2024-09-12 15:03:41 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-12 14:03:41 +0200 |
| commit | c2faa68ac8369db571e8136962b1cac5db206dd0 (patch) | |
| tree | a2e6ab7379d32e13ca3a5a8de847e99957bfdf49 /src/main/resources/assets/goodgenerator/shaders | |
| parent | 07cc2ec931b0e479026e78298a7bd926019c9334 (diff) | |
| download | GT5-Unofficial-c2faa68ac8369db571e8136962b1cac5db206dd0.tar.gz GT5-Unofficial-c2faa68ac8369db571e8136962b1cac5db206dd0.tar.bz2 GT5-Unofficial-c2faa68ac8369db571e8136962b1cac5db206dd0.zip | |
Add Antimatter Power Generation (#3117)
Co-authored-by: BlueWeabo <ilia.iliev2005@gmail.com>
Co-authored-by: Mary <33456283+FourIsTheNumber@users.noreply.github.com>
Co-authored-by: BucketBrigade <138534411+CookieBrigade@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/resources/assets/goodgenerator/shaders')
4 files changed, 184 insertions, 0 deletions
diff --git a/src/main/resources/assets/goodgenerator/shaders/antimatter.frag.glsl b/src/main/resources/assets/goodgenerator/shaders/antimatter.frag.glsl new file mode 100644 index 0000000000..08b80694d6 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/shaders/antimatter.frag.glsl @@ -0,0 +1,9 @@ +#version 120 +uniform float u_Opacity; +varying vec3 v_Color; + + +void main() { + // Color ramp from 0 to 1 + gl_FragColor = vec4(v_Color.rgb,u_Opacity); +} diff --git a/src/main/resources/assets/goodgenerator/shaders/antimatter.vert.glsl b/src/main/resources/assets/goodgenerator/shaders/antimatter.vert.glsl new file mode 100644 index 0000000000..8286a26a4f --- /dev/null +++ b/src/main/resources/assets/goodgenerator/shaders/antimatter.vert.glsl @@ -0,0 +1,80 @@ +#version 120 + + +uniform float u_SpikeMult; +uniform float u_Scale; +uniform float u_ScaleSnapshot; +uniform vec3 u_ColorCore; +uniform vec3 u_ColorSpike; +uniform float u_Time; +uniform float u_TimeSnapshot; +varying vec3 v_Color; + +/* +float wave ( vec3 input){ + return (cos(input.x + u_Time*1.2)*cos(input.y + u_Time*1.3)*cos(input.z + u_Time*1.4)); +} +*/ +const float PI = 3.14159265358979323846; + + +float lazyHash(vec3 input){ + vec3 v = fract(input*1.23456 + 3.1456); + v*=7; + return fract(v.y + v.x*(v.z+1)); +} + + +float wave ( vec3 input){ + float val = lazyHash(input); + float pulse = cos(val*2*PI + u_Time)*cos(u_Time*(1+val)); // Slow save + return pulse; +} + +float trim (float val){ + return clamp(val - .1,0,1)/.9; +} + +float amp(float x){ + float b = smoothstep(0.,1.,x); + float c = pow(b,.3); + return c; +} + +float triangle(float x){ + return 1.0 - abs(2.0 * (x - 0.5)); +} + +void main() { + //grab local position + vec3 pos = gl_Vertex.xyz; + + //Grabs how far the vertex is for center + //Antimatter.model has spikes that are 2 unit away, and the 'core' is 1 unit away + float len = length(pos); + + //Grabs distance that remains as spike + float spike = len-1; + + //Spike + float extension = wave(pos); + extension = abs(extension); + float spikeSize = extension * u_SpikeMult; + + //Scale + float timelerp = clamp(1,0,(u_Time-u_TimeSnapshot)/2.5); + float scale = mix(u_ScaleSnapshot,u_Scale,timelerp)*(1 + 0.5*spike*(spikeSize - 1)); + + vec3 currentCoreColor = mix(u_ColorCore,u_ColorSpike,triangle(mod((u_Time/4.0 + lazyHash(pos)/2),1.0))); + vec3 currentSpikeColor = mix(u_ColorCore,u_ColorSpike,triangle(mod((u_Time/2.0 + lazyHash(pos)),1.0))); + //v_Color = mix(u_ColorCore,u_ColorSpike,extension*spike); + v_Color = mix(currentCoreColor,currentSpikeColor,extension*spike); + mat4 mScale = mat4( + scale,0,0,0, + 0,scale,0,0, + 0,0,scale,0, + 0,0,0,1); + + + gl_Position = gl_ModelViewProjectionMatrix * mScale * gl_Vertex; +} diff --git a/src/main/resources/assets/goodgenerator/shaders/protomatter.frag.glsl b/src/main/resources/assets/goodgenerator/shaders/protomatter.frag.glsl new file mode 100644 index 0000000000..ab6df42637 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/shaders/protomatter.frag.glsl @@ -0,0 +1,8 @@ +#version 120 +uniform vec3 u_Color; +uniform float u_Opacity; + +void main() { + // Color ramp from 0 to 1 + gl_FragColor = vec4(u_Color,1); +} diff --git a/src/main/resources/assets/goodgenerator/shaders/protomatter.vert.glsl b/src/main/resources/assets/goodgenerator/shaders/protomatter.vert.glsl new file mode 100644 index 0000000000..746b31cc46 --- /dev/null +++ b/src/main/resources/assets/goodgenerator/shaders/protomatter.vert.glsl @@ -0,0 +1,87 @@ +#version 120 +attribute float a_VertexID; + +uniform float u_CubeCount; +uniform float u_Time; +uniform float u_Scale; +uniform float u_SpiralRadius; +uniform vec3 u_Vertices[24]; + +const float PI = 3.14159265358979323846; + +int modulo(int a, int b){ + return int(mod(float(a),float(b))); +} + +int idVertexTransform(float id){ + int i = int(id); + int l = modulo(i,6); // Local vertex id for face: 0..5 inclusive + int v = modulo((l-l/3),4); // Transform 0,1,2,3,4,5 to 0,1,2,2,3,0 + int f = (i/6)*4; // Grab face offset for vertex + return f+v; +} + + +//Best fit equation, needs to be manually calculated +//Alternatives should be looked if shader is going to be multi purpose +float positionEquation(float tickTime){ + float x = tickTime/20; + float y1 = 7.6331796059e-12*pow(x,1.7827335640e+01); + float y2 = x/10.0; + float y = max(y1,y2); + return y; +} + +float velocityEquation(float tickTime){ + return (positionEquation(tickTime + 0.001)-positionEquation(tickTime))/.001; +} + +void main() { + float cubeCount = u_CubeCount; + float maxDistance = 22.5; + + //This probably needs a better method for generating cubes + int cube_id = int(a_VertexID)/36; + int local_id = idVertexTransform(mod(a_VertexID, 36)); + vec3 pos = u_Vertices[local_id]; + + + //Beam particles y speed + float loopTime = 100; + float cycleOffset = (cube_id/cubeCount) * loopTime; + float cubeTime = mod(u_Time+cycleOffset,loopTime); + float dist = positionEquation(cubeTime); + + + //beam particles position x&z + float halfCycle = PI * mod(cube_id,2); + float x_offset = sin(cube_id/cubeCount * 3 * PI + halfCycle) * u_SpiralRadius; + float z_offset = cos(cube_id/cubeCount * 3 * PI + halfCycle) * u_SpiralRadius; + float y_offset = maxDistance-dist; + + //scale + float size = min((cubeTime/loopTime)/.8,1)*u_Scale; + float tall = size*max(1,maxDistance-y_offset); + float width = min(size/sqrt(tall),size); + + float y_trim = max(0,tall/2-y_offset); + + tall -= y_trim; + y_offset += y_trim/2; + + mat4 scale = mat4 ( + width,0,0,0, + 0,tall,0,0, + 0,0,width,0, + 0,0,0,1 + ); + + mat4 gravity = mat4( + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + x_offset,y_offset,z_offset,1 + ); + + gl_Position = gl_ModelViewProjectionMatrix * (gravity * (scale*vec4(pos,1))); +} |
