intel graphics now like the shaders

This commit is contained in:
Jozsef 2021-01-23 15:32:17 -08:00
parent 83cb735e62
commit 4cbea0f9c9
6 changed files with 86 additions and 80 deletions

View file

@ -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) {

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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;