mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 00:16:27 +01:00
FLWFinalizeWorld takes care of assigning gl_Position
This commit is contained in:
parent
05b56b9b5e
commit
4111680755
9 changed files with 32 additions and 93 deletions
|
@ -25,12 +25,6 @@ varying vec4 Color;
|
|||
varying float Diffuse;
|
||||
varying vec2 Light;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
void main() {
|
||||
vec3 rotated = rotateVertexByQuat(aPos - .5, aInstanceRot) + aInstancePos + .5;
|
||||
|
||||
|
@ -38,7 +32,7 @@ void main() {
|
|||
|
||||
vec3 norm = rotateVertexByQuat(aNormal, aInstanceRot);
|
||||
|
||||
FLWFinalizeWorldPos(worldPos, uCameraPos);
|
||||
FLWFinalizeWorldPos(worldPos);
|
||||
FLWFinalizeNormal(norm);
|
||||
|
||||
float scrollSize = aScrollTexture.w - aScrollTexture.y;
|
||||
|
@ -47,7 +41,6 @@ void main() {
|
|||
Diffuse = diffuse(norm);
|
||||
TexCoords = aTexCoords - aSourceTexture + aScrollTexture.xy + vec2(0, scroll);
|
||||
Light = aLight;
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
|
||||
#ifdef CONTRAPTION
|
||||
if (uDebug == 2) {
|
||||
|
|
|
@ -8,7 +8,12 @@ uniform vec3 uLightBoxSize;
|
|||
uniform vec3 uLightBoxMin;
|
||||
uniform mat4 uModel;
|
||||
|
||||
void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) {
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
void FLWFinalizeWorldPos(inout vec4 worldPos) {
|
||||
worldPos = uModel * worldPos;
|
||||
|
||||
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
|
||||
|
@ -16,6 +21,8 @@ void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) {
|
|||
#if defined(USE_FOG)
|
||||
FragDistance = length(worldPos.xyz);
|
||||
#endif
|
||||
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
}
|
||||
|
||||
void FLWFinalizeNormal(inout vec3 normal) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#version 110
|
||||
#define PI 3.1415926538
|
||||
|
||||
#flwbuiltins
|
||||
#flwinclude <"create:core/matutils.glsl">
|
||||
#flwinclude <"create:core/quaternion.glsl">
|
||||
#flwinclude <"create:core/diffuse.glsl">
|
||||
|
@ -22,45 +23,24 @@ attribute float aSpeed;
|
|||
varying float Diffuse;
|
||||
varying vec2 TexCoords;
|
||||
varying vec4 Color;
|
||||
varying vec3 BoxCoord;
|
||||
varying vec2 Light;
|
||||
|
||||
uniform vec3 uLightBoxSize;
|
||||
uniform vec3 uLightBoxMin;
|
||||
uniform mat4 uModel;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
#if defined(USE_FOG)
|
||||
varying float FragDistance;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
float degrees = aOffset + uTime * aSpeed / 20.;
|
||||
//float angle = fract(degrees / 360.) * PI * 2.;
|
||||
|
||||
vec4 kineticRot = quat(aAxis, degrees);
|
||||
vec3 rotated = rotateVertexByQuat(aPos - aRotationCenter, kineticRot) + aRotationCenter;
|
||||
vec3 localPos = rotateVertexByQuat(rotated - .5, aInstanceRot) + aInstancePos + .5;
|
||||
|
||||
vec4 worldPos = uModel * vec4(localPos, 1.);
|
||||
|
||||
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, aInstanceRot) + aInstancePos + .5, 1.);
|
||||
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(aNormal, kineticRot), aInstanceRot);
|
||||
norm = modelToNormal(uModel) * norm;
|
||||
|
||||
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
|
||||
FLWFinalizeWorldPos(worldPos);
|
||||
FLWFinalizeNormal(norm);
|
||||
|
||||
Diffuse = diffuse(norm);
|
||||
TexCoords = aTexCoords;
|
||||
Light = aModelLight;
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
|
||||
#if defined(USE_FOG)
|
||||
FragDistance = length(worldPos.xyz);
|
||||
#endif
|
||||
|
||||
if (uDebug == 2) {
|
||||
Color = vec4(norm, 1.);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#version 110
|
||||
#define PI 3.1415926538
|
||||
|
||||
#flwbuiltins
|
||||
#flwinclude <"create:core/matutils.glsl">
|
||||
#flwinclude <"create:core/diffuse.glsl">
|
||||
|
||||
|
@ -13,41 +14,21 @@ attribute vec2 aModelLight;
|
|||
varying float Diffuse;
|
||||
varying vec2 TexCoords;
|
||||
varying vec4 Color;
|
||||
varying vec3 BoxCoord;
|
||||
varying vec2 Light;
|
||||
|
||||
uniform vec3 uLightBoxSize;
|
||||
uniform vec3 uLightBoxMin;
|
||||
uniform mat4 uModel;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
#if defined(USE_FOG)
|
||||
varying float FragDistance;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
vec4 viewPos = uModel * vec4(aPos, 1.);
|
||||
vec4 worldPos = vec4(aPos, 1.);
|
||||
vec3 norm = aNormal;
|
||||
|
||||
vec3 norm = (uModel * vec4(aNormal, 0.)).xyz;
|
||||
FLWFinalizeWorldPos(worldPos);
|
||||
FLWFinalizeNormal(norm);
|
||||
|
||||
BoxCoord = (viewPos.xyz - uLightBoxMin) / uLightBoxSize;
|
||||
Diffuse = diffuse(norm);
|
||||
Color = aColor / diffuse(aNormal);
|
||||
Color = aColor / diffuse(norm);
|
||||
TexCoords = aTexCoords;
|
||||
Light = aModelLight;
|
||||
gl_Position = uViewProjection * viewPos;
|
||||
#if defined(USE_FOG)
|
||||
FragDistance = length(viewPos.xyz);
|
||||
#endif
|
||||
|
||||
if (uDebug == 2) {
|
||||
Color = vec4(norm, 1.);
|
||||
} else {
|
||||
Color = aColor / diffuse(aNormal);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,6 @@ varying vec4 Color;
|
|||
varying float Diffuse;
|
||||
varying vec2 Light;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
float toRad(float degrees) {
|
||||
return fract(degrees / 360.) * PI * 2.;
|
||||
}
|
||||
|
@ -62,13 +56,12 @@ void main() {
|
|||
vec4 worldPos = vec4(rotated, 1.);
|
||||
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(aNormal, flapRotation), orientation);
|
||||
|
||||
FLWFinalizeWorldPos(worldPos, uCameraPos);
|
||||
FLWFinalizeWorldPos(worldPos);
|
||||
FLWFinalizeNormal(norm);
|
||||
|
||||
Diffuse = diffuse(norm);
|
||||
TexCoords = aTexCoords;
|
||||
Light = aLight;
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
|
||||
Color = vec4(1.);
|
||||
}
|
||||
|
|
|
@ -18,18 +18,12 @@ varying vec4 Color;
|
|||
varying float Diffuse;
|
||||
varying vec2 Light;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
void main() {
|
||||
vec4 worldPos = aTransform * vec4(aPos, 1.);
|
||||
|
||||
vec3 norm = aNormalMat * aNormal;
|
||||
|
||||
FLWFinalizeWorldPos(worldPos, uCameraPos);
|
||||
FLWFinalizeWorldPos(worldPos);
|
||||
FLWFinalizeNormal(norm);
|
||||
|
||||
norm = normalize(norm);
|
||||
|
@ -37,7 +31,6 @@ void main() {
|
|||
Diffuse = diffuse(norm);
|
||||
TexCoords = aTexCoords;
|
||||
Light = aLight;
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
|
||||
Color = aColor;
|
||||
}
|
||||
|
|
|
@ -20,24 +20,17 @@ varying vec4 Color;
|
|||
varying float Diffuse;
|
||||
varying vec2 Light;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
void main() {
|
||||
vec4 worldPos = vec4(rotateVertexByQuat(aPos - aPivot, aRotation) + aPivot + aInstancePos, 1.);
|
||||
|
||||
vec3 norm = rotateVertexByQuat(aNormal, aRotation);
|
||||
|
||||
FLWFinalizeWorldPos(worldPos, uCameraPos);
|
||||
FLWFinalizeWorldPos(worldPos);
|
||||
FLWFinalizeNormal(norm);
|
||||
|
||||
Diffuse = diffuse(norm);
|
||||
TexCoords = aTexCoords;
|
||||
Light = aLight;
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
|
||||
Color = aColor;
|
||||
}
|
||||
|
|
|
@ -22,12 +22,6 @@ varying vec4 Color;
|
|||
varying float Diffuse;
|
||||
varying vec2 Light;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
mat4 kineticRotation() {
|
||||
float degrees = aOffset + uTime * aSpeed * 3./10.;
|
||||
float angle = fract(degrees / 360.) * PI * 2.;
|
||||
|
@ -41,13 +35,12 @@ void main() {
|
|||
|
||||
vec3 norm = modelToNormal(kineticRotation) * aNormal;
|
||||
|
||||
FLWFinalizeWorldPos(worldPos, uCameraPos);
|
||||
FLWFinalizeWorldPos(worldPos);
|
||||
FLWFinalizeNormal(norm);
|
||||
|
||||
Diffuse = diffuse(norm);
|
||||
TexCoords = aTexCoords;
|
||||
Light = aLight;
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
|
||||
#ifdef CONTRAPTION
|
||||
if (uDebug == 2) {
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform int uDebug;
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
#if defined(USE_FOG)
|
||||
varying float FragDistance;
|
||||
#endif
|
||||
|
||||
void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) {
|
||||
void FLWFinalizeWorldPos(inout vec4 worldPos) {
|
||||
#if defined(USE_FOG)
|
||||
FragDistance = length(worldPos.xyz - cameraPos);
|
||||
FragDistance = length(worldPos.xyz - uCameraPos);
|
||||
#endif
|
||||
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
}
|
||||
|
||||
void FLWFinalizeNormal(inout vec3 normal) {
|
||||
|
|
Loading…
Reference in a new issue