diff --git a/src/main/resources/assets/nhutilities/shader/cosmic.frag b/src/main/resources/assets/nhutilities/shader/cosmic.frag deleted file mode 100644 index 5e91f4f..0000000 --- a/src/main/resources/assets/nhutilities/shader/cosmic.frag +++ /dev/null @@ -1,182 +0,0 @@ -#version 120 - -#define M_PI 3.1415926535897932384626433832795 - -const int cosmiccount = 10; -const int cosmicoutof = 101; - -uniform sampler2D texture0; -uniform vec3 lightlevel; - -uniform float time2; - -uniform float yaw; -uniform float pitch; -uniform float externalScale; - -uniform float lightmix; -uniform float opacity; - -uniform mat2 cosmicuvs[cosmiccount]; - -varying vec3 position; - -float rand2d(vec2 x) { - return fract(sin(mod(dot(x, vec2(12.9898, 78.233)), 3.14)) * 43758.5453); -} - -mat4 rotationMatrix(vec3 axis, float angle) -{ - - axis = normalize(axis); - float s = sin(angle); - float c = cos(angle); - float oc = 1.0 - c; - - return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, - oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, - oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, - 0.0, 0.0, 0.0, 1.0); -} - -void main (void) -{ - vec4 light = gl_Color; - vec4 mask = texture2D(texture0, gl_TexCoord[0].xy); - light.rgb *= lightlevel; - float correctTime = mod(time2,12000); - - float oneOverExternalScale = 1.0/externalScale; - - int uvtiles = 16; - - // background colour - vec4 col = vec4(0.1,0.0,0.0,1.0); - - float pulse = mod(correctTime,400)/400.0; - - col.g = sin(pulse*M_PI*2) * 0.075 + 0.225; - col.b = cos(pulse*M_PI*2) * 0.05 + 0.3; - - // get ray from camera to fragment - vec4 dir = normalize(vec4( -position, 0)); - - // rotate the ray to show the right bit of the sphere for the angle - float sb = sin(pitch); - float cb = cos(pitch); - dir = normalize(vec4(dir.x, dir.y * cb - dir.z * sb, dir.y * sb + dir.z * cb, 0)); - - float sa = sin(-yaw); - float ca = cos(-yaw); - dir = normalize(vec4(dir.z * sa + dir.x * ca, dir.y, dir.z * ca - dir.x * sa, 0)); - - vec4 ray; - - // draw the layers - for (int i=0; i<16; i++) { - int mult = 16-i; - - // get semi-random stuff - int j = i + 7; - float rand1 = (j * j * 4321 + j * 8) * 2.0; - int k = j + 1; - float rand2 = (k * k * k * 239 + k * 37) * 3.6; - float rand3 = rand1 * 347.4 + rand2 * 63.4; - - // random rotation matrix by random rotation around random axis - vec3 axis = normalize(vec3(sin(rand1), sin(rand2) , cos(rand3))); - - // apply - ray = dir * rotationMatrix(axis, mod(rand3, 2*M_PI)); - - // calcuate the UVs from the final ray - float rawu = 0.5 + (atan(ray.z,ray.x)/(2*M_PI)); - float rawv = 0.5 + (asin(ray.y)/M_PI); - - // get UV scaled for layers and offset by time; - float scale = mult*0.5 + 2.75; - float u = rawu * scale * externalScale; - //float v = (rawv + time * 0.00006) * scale * 0.6; - float v = (rawv + correctTime * 0.0002 * oneOverExternalScale) * scale * 0.6 * externalScale; - - vec2 tex = vec2( u, v ); - - // tile position of the current uv - int tu = int(mod(floor(u*uvtiles),uvtiles)); - int tv = int(mod(floor(v*uvtiles),uvtiles)); - - // get pseudorandom variants - int symbol = int(rand2d(vec2(tu, tv + i * 10.0)) * cosmicoutof); - int rotation = int(mod(pow(tu,float(tv)) + tu + 3 + tv*i, 8)); - bool flip = false; - if (rotation >= 4) { - rotation -= 4; - flip = true; - } - - // if it's an icon, then add the colour! - if (symbol >= 0 && symbol < cosmiccount) { - - vec2 cosmictex = vec2(1.0,1.0); - vec4 tcol = vec4(1.0,0.0,0.0,1.0); - - // get uv within the tile - float ru = clamp(mod(u,1.0)*uvtiles - tu, 0.0, 1.0); - float rv = clamp(mod(v,1.0)*uvtiles - tv, 0.0, 1.0); - - if (flip) { - ru = 1.0 - ru; - } - - float oru = ru; - float orv = rv; - - // rotate uvs if necessary - if (rotation == 1) { - oru = 1.0-rv; - orv = ru; - } else if (rotation == 2) { - oru = 1.0-ru; - orv = 1.0-rv; - } else if (rotation == 3) { - oru = rv; - orv = 1.0-ru; - } - - // get the iicon uvs for the tile - float umin = cosmicuvs[symbol][0][0]; - float umax = cosmicuvs[symbol][1][0]; - float vmin = cosmicuvs[symbol][0][1]; - float vmax = cosmicuvs[symbol][1][1]; - - // interpolate based on tile uvs - cosmictex.x = umin * (1.0-oru) + umax * oru; - cosmictex.y = vmin * (1.0-orv) + vmax * orv; - - tcol = texture2D(texture0, cosmictex); - - // set the alpha, blending out at the bunched ends - float a = tcol.r * (0.5 + (1.0/mult) * 1.0) * (1.0-smoothstep(0.15, 0.48, abs(rawv-0.5))); - - // get fancy colours - float r = (mod(rand1, 29.0)/29.0) * 0.3 + 0.4; - float g = (mod(rand2, 35.0)/35.0) * 0.4 + 0.6; - float b = (mod(rand1, 17.0)/17.0) * 0.3 + 0.7; - - // mix the colours - //col = col*(1-a) + vec4(r,g,b,1)*a; - col = col + vec4(r,g,b,1)*a; - } - } - - // apply lighting - vec3 shade = light.rgb * (lightmix) + vec3(1.0-lightmix,1.0-lightmix,1.0-lightmix); - col.rgb *= shade; - - // apply mask - col.a *= mask.a * opacity; - - col = clamp(col,0.0,1.0); - - gl_FragColor = col; -} diff --git a/src/main/resources/assets/nhutilities/shader/cosmic.vert b/src/main/resources/assets/nhutilities/shader/cosmic.vert deleted file mode 100644 index 9b319d5..0000000 --- a/src/main/resources/assets/nhutilities/shader/cosmic.vert +++ /dev/null @@ -1,224 +0,0 @@ -#version 120 - -vec4 Ambient; -vec4 Diffuse; -vec4 Specular; - -attribute float activelights; - -varying vec3 position; - -void pointLight(in int i, in vec3 normal, in vec3 eye, in vec3 ecPosition3) -{ - float nDotVP; // normal . light direction - float nDotHV; // normal . light half vector - float pf; // power factor - float attenuation; // computed attenuation factor - float d; // distance from surface to light source - vec3 VP; // direction from surface to light position - vec3 halfVector; // direction of maximum highlights - - // Compute vector from surface to light position - VP = vec3 (gl_LightSource[i].position) - ecPosition3; - - // Compute distance between surface and light position - d = length(VP); - - // Normalize the vector from surface to light position - VP = normalize(VP); - - // Compute attenuation - attenuation = 1.0 / (gl_LightSource[i].constantAttenuation + - gl_LightSource[i].linearAttenuation * d + - gl_LightSource[i].quadraticAttenuation * d * d); - - halfVector = normalize(VP + eye); - - nDotVP = max(0.0, dot(normal, VP)); - //nDotHV = max(0.0, dot(normal, halfVector)); - - //if (nDotVP == 0.0) - //{ - pf = 0.0; - //} - //else - //{ - // pf = pow(nDotHV, gl_FrontMaterial.shininess); - //} - Ambient += gl_LightSource[i].ambient * attenuation; - Diffuse += gl_LightSource[i].diffuse * nDotVP * attenuation; - //Specular += gl_LightSource[i].specular * pf * attenuation; -} - -void spotLight(in int i, in vec3 normal, in vec3 eye, in vec3 ecPosition3) -{ - float nDotVP; // normal . light direction - float nDotHV; // normal . light half vector - float pf; // power factor - float spotDot; // cosine of angle between spotlight - float spotAttenuation; // spotlight attenuation factor - float attenuation; // computed attenuation factor - float d; // distance from surface to light source - vec3 VP; // direction from surface to light position - vec3 halfVector; // direction of maximum highlights - - // Compute vector from surface to light position - VP = vec3 (gl_LightSource[i].position) - ecPosition3; - - // Compute distance between surface and light position - d = length(VP); - - // Normalize the vector from surface to light position - VP = normalize(VP); - - // Compute attenuation - attenuation = 1.0 / (gl_LightSource[i].constantAttenuation + - gl_LightSource[i].linearAttenuation * d + - gl_LightSource[i].quadraticAttenuation * d * d); - - // See if point on surface is inside cone of illumination - spotDot = dot(-VP, normalize(gl_LightSource[i].spotDirection)); - - if (spotDot < gl_LightSource[i].spotCosCutoff) - { - spotAttenuation = 0.0; // light adds no contribution - } - else - { - spotAttenuation = pow(spotDot, gl_LightSource[i].spotExponent); - - } - // Combine the spotlight and distance attenuation. - attenuation *= spotAttenuation; - - halfVector = normalize(VP + eye); - - nDotVP = max(0.0, dot(normal, VP)); - //nDotHV = max(0.0, dot(normal, halfVector)); - - //if (nDotVP == 0.0) - //{ - pf = 0.0; - //} - //else - //{ -// pf = pow(nDotHV, gl_FrontMaterial.shininess); -// - // } - Ambient += gl_LightSource[i].ambient * attenuation; - Diffuse += gl_LightSource[i].diffuse * nDotVP * attenuation; - //Specular += gl_LightSource[i].specular * pf * attenuation; - -} - -void directionalLight(in int i, in vec3 normal) -{ - float nDotVP; // normal . light direction - float nDotHV; // normal . light half vector - float pf; // power factor - - nDotVP = max(0.0, dot(normal, normalize(vec3 (gl_LightSource[i].position)))); - //nDotHV = max(0.0, dot(normal, vec3 (gl_LightSource[i].halfVector))); - - //if (nDotVP == 0.0) - //{ - pf = 0.0; - //} - //else - //{ -// pf = pow(nDotHV, gl_FrontMaterial.shininess); - //} - Ambient += gl_LightSource[i].ambient; - Diffuse += gl_LightSource[i].diffuse * nDotVP; - //Specular += gl_LightSource[i].specular * pf; -} - -vec3 fnormal(void) -{ - //Compute the normal - vec3 normal = gl_NormalMatrix * gl_Normal; - normal = normalize(normal); - return normal; -} - -void ProcessLight(in int i, in vec3 normal, in vec3 eye, in vec3 ecPosition3) -{ - if (gl_LightSource[i].spotCutoff==180.0) - { - if (gl_LightSource[i].position.w==0.0) - { - directionalLight(i, normal); - } - else - { - pointLight(i, normal, eye, ecPosition3); - } - } - else - { - spotLight(i,normal,eye,ecPosition3); - } -} - -void flight(in vec3 normal, in vec4 ecPosition, float alphaFade) -{ - vec4 color; - vec3 ecPosition3; - vec3 eye; - int i; - - ecPosition3 = (vec3 (ecPosition)) / ecPosition.w; - eye = vec3 (0.0, 0.0, 1.0); - - // Clear the light intensity accumulators - Ambient = vec4 (0.0); - Diffuse = vec4 (0.0); - Specular = vec4 (0.0); - - if (activelights>0) - { - ProcessLight(0,normal,eye,ecPosition3); - } - if (activelights>1) - { - ProcessLight(1,normal,eye,ecPosition3); - } - //if (activelights>2) - //{ - // ProcessLight(2,normal,eye,ecPosition3); - //} - //if (activelights>3) - //{ - // ProcessLight(3,normal,eye,ecPosition3); - //} - - color = gl_FrontLightModelProduct.sceneColor + - Ambient * gl_FrontMaterial.ambient + - Diffuse * gl_FrontMaterial.diffuse; - color += Specular * gl_FrontMaterial.specular; - color = clamp( color, 0.0, 1.0 ); - gl_FrontColor = color; - gl_FrontColor.a *= alphaFade; -} - -void main (void) -{ - vec3 transformedNormal; - float alphaFade = 1.0; - - // Eye-coordinate position of vertex, needed in various calculations - vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; - - // Do fixed functionality vertex transform - gl_Position = ftransform(); - transformedNormal = fnormal(); - flight(transformedNormal, ecPosition, alphaFade); - - //Enable texture coordinates - gl_TexCoord[0] = gl_MultiTexCoord0; - //gl_TexCoord[1] = gl_MultiTexCoord1; - //gl_TexCoord[2] = gl_MultiTexCoord2; - //gl_TexCoord[3] = gl_MultiTexCoord3; - - position = (gl_ModelViewMatrix * gl_Vertex).xyz; -} \ No newline at end of file