From 4cbea0f9c9eecb7ab4c6fabed4cf9ead2ae15503 Mon Sep 17 00:00:00 2001 From: Jozsef Date: Sat, 23 Jan 2021 15:32:17 -0800 Subject: [PATCH] intel graphics now like the shaders --- .../resources/assets/create/shader/belt.vert | 20 +++++----- .../assets/create/shader/contraption.vert | 14 +++---- .../create/shader/contraption_actor.vert | 37 ++++++++++--------- .../create/shader/contraption_belt.vert | 35 +++++++++--------- .../create/shader/contraption_rotating.vert | 32 ++++++++-------- .../assets/create/shader/rotating.vert | 28 ++++++++------ 6 files changed, 86 insertions(+), 80 deletions(-) diff --git a/src/main/resources/assets/create/shader/belt.vert b/src/main/resources/assets/create/shader/belt.vert index e1d1a1168..6e4ba0fbf 100644 --- a/src/main/resources/assets/create/shader/belt.vert +++ b/src/main/resources/assets/create/shader/belt.vert @@ -28,28 +28,28 @@ uniform int debug; mat4 rotate(vec3 axis, float angle) { float s = sin(angle); float c = cos(angle); - float oc = 1.0 - c; + float oc = 1 - 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., - oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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., 1.); + 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, + oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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, 1); } float diffuse(vec3 normal) { float x = normal.x; float y = normal.y; float z = normal.z; - return min(x * x * 0.6f + y * y * ((3f + y) / 4f) + z * z * 0.8f, 1f); + return min(x * x * .6 + y * y * ((3 + y) / 4) + z * z * .8, 1); } void main() { - vec3 rot = fract(rotationDegrees / 360.) * PI * 2.; + vec3 rot = fract(rotationDegrees / 360) * PI * 2; mat4 rotation = rotate(vec3(0, 1, 0), rot.y) * rotate(vec3(0, 0, 1), rot.z) * rotate(vec3(1, 0, 0), rot.x); - vec4 renderPos = rotation * vec4(aPos - vec3(0.5), 1f); - renderPos += vec4(instancePos + vec3(0.5), 0); + vec4 renderPos = rotation * vec4(aPos - vec3(.5), 1); + renderPos += vec4(instancePos + vec3(.5), 0); float scrollSize = scrollTexture.w - scrollTexture.y; @@ -59,7 +59,7 @@ void main() { Diffuse = diffuse(norm); Light = light; - TexCoords = aTexCoords - sourceUV + scrollTexture.xy + vec2(0., scroll); + TexCoords = aTexCoords - sourceUV + scrollTexture.xy + vec2(0, scroll); gl_Position = projection * view * renderPos; if (debug == 1) { diff --git a/src/main/resources/assets/create/shader/contraption.vert b/src/main/resources/assets/create/shader/contraption.vert index edd750914..cffa4e863 100644 --- a/src/main/resources/assets/create/shader/contraption.vert +++ b/src/main/resources/assets/create/shader/contraption.vert @@ -24,25 +24,25 @@ uniform int debug; mat4 rotate(vec3 axis, float angle) { float s = sin(angle); float c = cos(angle); - float oc = 1.0 - c; + float oc = 1 - 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., - oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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., 1.); + 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, + oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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, 1); } float diffuse(vec3 normal) { float x = normal.x; float y = normal.y; float z = normal.z; - return min(x * x * 0.6f + y * y * ((3f + y) / 4f) + z * z * 0.8f, 1f); + return min(x * x * .6 + y * y * ((3 + y) / 4) + z * z * .8, 1); } void main() { vec4 worldPos = model * vec4(aPos, 1); - vec3 norm = (model * vec4(aNormal, 0.)).xyz; + vec3 norm = (model * vec4(aNormal, 0)).xyz; BoxCoord = (worldPos.xyz - lightBoxMin) / lightBoxSize; Diffuse = diffuse(norm); diff --git a/src/main/resources/assets/create/shader/contraption_actor.vert b/src/main/resources/assets/create/shader/contraption_actor.vert index be74dba37..58c00ee1e 100644 --- a/src/main/resources/assets/create/shader/contraption_actor.vert +++ b/src/main/resources/assets/create/shader/contraption_actor.vert @@ -30,15 +30,23 @@ uniform mat4 projection; uniform mat4 view; uniform int debug; + mat4 rotate(vec3 axis, float angle) { float s = sin(angle); float c = cos(angle); - float oc = 1.0 - c; + float oc = 1 - 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., - oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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., 1.); + 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, + oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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, 1); +} + +float diffuse(vec3 normal) { + float x = normal.x; + float y = normal.y; + float z = normal.z; + return min(x * x * .6 + y * y * ((3 + y) / 4) + z * z * .8, 1); } mat4 rotation(vec3 rot) { @@ -47,31 +55,24 @@ mat4 rotation(vec3 rot) { mat4 kineticRotation() { const float speed = -20; - float degrees = rotationOffset + time * speed * -3./10.; - float angle = fract(degrees / 360.) * PI * 2.; + float degrees = rotationOffset + time * speed * -3/10; + float angle = fract(degrees / 360) * PI * 2; return rotate(normalize(localRotationAxis), angle); } -float diffuse(vec3 normal) { - float x = normal.x; - float y = normal.y; - float z = normal.z; - return min(x * x * 0.6f + y * y * ((3f + y) / 4f) + z * z * 0.8f, 1f); -} - void main() { mat4 kineticRotation = kineticRotation(); vec4 localPos = kineticRotation * vec4(aPos - rotationCenter, 1) + vec4(rotationCenter, 0); //localPos = vec4(localPos.xyz + instancePos, 1); - vec3 rot = fract(localRotation / 360.) * PI * 2.; + vec3 rot = fract(localRotation / 360) * PI * 2; mat4 localRot = rotation(rot); - localPos = localRot * vec4(localPos.xyz - 0.5, 1f) + vec4(instancePos + 0.5, 0); + localPos = localRot * vec4(localPos.xyz - .5, 1) + vec4(instancePos + .5, 0); vec4 worldPos = model * localPos; - vec3 norm = normalize(model * localRot * kineticRotation * vec4(aNormal, 0.)).xyz; + vec3 norm = normalize(model * localRot * kineticRotation * vec4(aNormal, 0)).xyz; BoxCoord = (worldPos.xyz - lightBoxMin) / lightBoxSize; Diffuse = diffuse(norm); @@ -81,6 +82,6 @@ void main() { if (debug == 2) { Color = vec4(norm, 1); } else { - Color = vec4(1.); + Color = vec4(1); } } \ No newline at end of file diff --git a/src/main/resources/assets/create/shader/contraption_belt.vert b/src/main/resources/assets/create/shader/contraption_belt.vert index edd05364c..e965c2e98 100644 --- a/src/main/resources/assets/create/shader/contraption_belt.vert +++ b/src/main/resources/assets/create/shader/contraption_belt.vert @@ -29,15 +29,23 @@ uniform mat4 projection; uniform mat4 view; uniform int debug; + mat4 rotate(vec3 axis, float angle) { float s = sin(angle); float c = cos(angle); - float oc = 1.0 - c; + float oc = 1 - 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., - oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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., 1.); + 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, + oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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, 1); +} + +float diffuse(vec3 normal) { + float x = normal.x; + float y = normal.y; + float z = normal.z; + return min(x * x * .6 + y * y * ((3 + y) / 4) + z * z * .8, 1); } mat4 rotation(vec3 rot) { @@ -49,32 +57,25 @@ mat4 localRotation() { return rotation(rot); } -float diffuse(vec3 normal) { - float x = normal.x; - float y = normal.y; - float z = normal.z; - return min(x * x * 0.6f + y * y * ((3f + y) / 4f) + z * z * 0.8f, 1f); -} - void main() { mat4 localRotation = localRotation(); - vec4 localPos = localRotation * vec4(aPos - 0.5, 1f) + vec4(instancePos + 0.5, 0); + vec4 localPos = localRotation * vec4(aPos - .5, 1) + vec4(instancePos + .5, 0); vec4 worldPos = model * localPos; float scrollSize = scrollTexture.w - scrollTexture.y; - float scroll = fract(speed * time / (36 * 16.)) * scrollSize * scrollMult; + float scroll = fract(speed * time / (36 * 16)) * scrollSize * scrollMult; - vec3 norm = normalize(model * localRotation * vec4(aNormal, 0.)).xyz; + vec3 norm = normalize(model * localRotation * vec4(aNormal, 0)).xyz; BoxCoord = (worldPos.xyz - lightBoxMin) / lightBoxSize; Diffuse = diffuse(norm); - TexCoords = aTexCoords - sourceUV + scrollTexture.xy + vec2(0., scroll); + TexCoords = aTexCoords - sourceUV + scrollTexture.xy + vec2(0, scroll); gl_Position = projection * view * worldPos; if (debug == 2) { Color = vec4(norm, 1); } else { - Color = vec4(1.); + Color = vec4(1); } } diff --git a/src/main/resources/assets/create/shader/contraption_rotating.vert b/src/main/resources/assets/create/shader/contraption_rotating.vert index b494b58d6..1c1887511 100644 --- a/src/main/resources/assets/create/shader/contraption_rotating.vert +++ b/src/main/resources/assets/create/shader/contraption_rotating.vert @@ -29,35 +29,35 @@ uniform int debug; mat4 rotate(vec3 axis, float angle) { float s = sin(angle); float c = cos(angle); - float oc = 1.0 - c; + float oc = 1 - 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., - oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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., 1.); -} - -mat4 kineticRotation() { - float degrees = rotationOffset + time * speed * -3./10.; - float angle = fract(degrees / 360.) * PI * 2.; - - return rotate(normalize(rotationAxis), angle); + 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, + oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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, 1); } float diffuse(vec3 normal) { float x = normal.x; float y = normal.y; float z = normal.z; - return min(x * x * 0.6f + y * y * ((3f + y) / 4f) + z * z * 0.8f, 1f); + return min(x * x * .6 + y * y * ((3 + y) / 4) + z * z * .8, 1); +} + +mat4 kineticRotation() { + float degrees = rotationOffset + time * speed * -3/10; + float angle = fract(degrees / 360) * PI * 2; + + return rotate(normalize(rotationAxis), angle); } void main() { mat4 kineticRotation = kineticRotation(); - vec4 localPos = kineticRotation * vec4(aPos - 0.5, 1f) + vec4(instancePos + 0.5, 0); + vec4 localPos = kineticRotation * vec4(aPos - .5, 1) + vec4(instancePos + .5, 0); vec4 worldPos = model * localPos; - vec3 norm = normalize(model * kineticRotation * vec4(aNormal, 0.)).xyz; + vec3 norm = normalize(model * kineticRotation * vec4(aNormal, 0)).xyz; BoxCoord = (worldPos.xyz - lightBoxMin) / lightBoxSize; Diffuse = diffuse(norm); @@ -67,6 +67,6 @@ void main() { if (debug == 2) { Color = vec4(norm, 1); } else { - Color = vec4(1.); + Color = vec4(1); } } \ No newline at end of file diff --git a/src/main/resources/assets/create/shader/rotating.vert b/src/main/resources/assets/create/shader/rotating.vert index da40a8935..93b292516 100644 --- a/src/main/resources/assets/create/shader/rotating.vert +++ b/src/main/resources/assets/create/shader/rotating.vert @@ -22,34 +22,38 @@ uniform mat4 projection; uniform mat4 view; uniform int debug; -mat4 kineticRotation() { - float degrees = rotationOffset + time * speed * -3./10.; - float angle = fract(degrees / 360.) * PI * 2.; - - vec3 axis = normalize(rotationAxis); +mat4 rotate(vec3 axis, float angle) { float s = sin(angle); float c = cos(angle); - float oc = 1.0 - c; + float oc = 1 - 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., - oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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., 1.); + 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, + oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 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, 1); } float diffuse(vec3 normal) { float x = normal.x; float y = normal.y; float z = normal.z; - return min(x * x * 0.6f + y * y * ((3f + y) / 4f) + z * z * 0.8f, 1f); + return min(x * x * .6 + y * y * ((3 + y) / 4) + z * z * .8, 1); } + +mat4 kineticRotation() { + float degrees = rotationOffset + time * speed * -3/10; + float angle = fract(degrees / 360) * PI * 2; + + return rotate(normalize(rotationAxis), angle); +} + void main() { mat4 rotation = kineticRotation(); vec4 renderPos = rotation * vec4(aPos - vec3(0.5), 1); renderPos += vec4(instancePos + vec3(0.5), 0); - vec3 norm = (rotation * vec4(aNormal, 0.)).xyz; + vec3 norm = (rotation * vec4(aNormal, 0)).xyz; Diffuse = diffuse(norm); TexCoords = aTexCoords;