Create world matrix uniform
This commit is contained in:
+2
-18
@@ -9,27 +9,11 @@ uniform vec2 winSize;
|
||||
uniform float zoom;
|
||||
uniform vec2 translation;
|
||||
uniform float rotation;
|
||||
|
||||
vec2 tran(vec2 v)
|
||||
{
|
||||
return (v - translation);
|
||||
}
|
||||
vec2 rot(vec2 v)
|
||||
{
|
||||
return vec2 ( v.x * cos(-rotation) - v.y * sin(-rotation)
|
||||
, v.x * sin(-rotation) + v.y * cos(-rotation)
|
||||
);
|
||||
}
|
||||
vec2 scal(vec2 v)
|
||||
{
|
||||
return vec2 ( 2 * v.x * zoom / winSize.x
|
||||
, 2 * v.y * zoom / winSize.y
|
||||
);
|
||||
}
|
||||
uniform mat4 worldMat;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(scal(rot(tran(position.xy))),position.z,1);
|
||||
gl_Position = worldMat * vec4(position.xyz,1);
|
||||
vColor = color;
|
||||
vparams = saEaRadWdth;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ uniform vec2 winSize;
|
||||
uniform float zoom;
|
||||
uniform vec2 translation;
|
||||
uniform float rotation;
|
||||
uniform mat4 worldMat;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
+20
-18
@@ -7,26 +7,28 @@ uniform vec2 winSize;
|
||||
uniform float zoom;
|
||||
uniform float rotation;
|
||||
uniform vec2 translation;
|
||||
uniform mat4 worldMat;
|
||||
|
||||
vec2 tran(vec2 v)
|
||||
{
|
||||
return (v - translation);
|
||||
}
|
||||
vec2 rot(vec2 v)
|
||||
{
|
||||
return vec2 ( v.x * cos(-rotation) - v.y * sin(-rotation)
|
||||
, v.x * sin(-rotation) + v.y * cos(-rotation)
|
||||
);
|
||||
}
|
||||
vec2 scal(vec2 v)
|
||||
{
|
||||
return vec2 ( 2 * v.x * zoom / winSize.x
|
||||
, 2 * v.y * zoom / winSize.y
|
||||
);
|
||||
}
|
||||
|
||||
mat4 tranMat = mat4
|
||||
( 1.0, 0.0, 0.0, 0.0
|
||||
, 0.0, 1.0, 0.0, 0.0
|
||||
, 0.0, 0.0, 1.0, 0.0
|
||||
, -translation.x, -translation.y, 0.0, 1.0
|
||||
) ;
|
||||
mat4 rotMat = mat4
|
||||
( cos(rotation), sin(-rotation), 0.0, 0.0
|
||||
, sin(rotation), cos(rotation), 0.0, 0.0
|
||||
, 0.0, 0.0, 1.0, 0.0
|
||||
, 0.0, 0.0, 0.0, 1.0
|
||||
) ;
|
||||
mat4 scalMat = mat4
|
||||
( 2*zoom/winSize.x, 0.0, 0.0, 0.0
|
||||
, 0.0, 2*zoom/winSize.y, 0.0, 0.0
|
||||
, 0.0, 0.0, 1.0, 0.0
|
||||
, 0.0, 0.0, 0.0, 1.0
|
||||
) ;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(scal(rot(tran(position.xy))),position.z,1);
|
||||
gl_Position = worldMat * vec4(position.xyz,1);
|
||||
vColor = color;
|
||||
}
|
||||
|
||||
+20
-17
@@ -9,26 +9,29 @@ uniform vec2 winSize;
|
||||
uniform float zoom;
|
||||
uniform vec2 translation;
|
||||
uniform float rotation;
|
||||
uniform mat4 worldMat;
|
||||
|
||||
vec2 tran(vec2 v)
|
||||
{
|
||||
return (v - translation);
|
||||
}
|
||||
vec2 rot(vec2 v)
|
||||
{
|
||||
return vec2 ( v.x * cos(-rotation) - v.y * sin(-rotation)
|
||||
, v.x * sin(-rotation) + v.y * cos(-rotation)
|
||||
);
|
||||
}
|
||||
vec2 scal(vec2 v)
|
||||
{
|
||||
return vec2 ( 2 * v.x * zoom / winSize.x
|
||||
, 2 * v.y * zoom / winSize.y
|
||||
);
|
||||
}
|
||||
mat4 tranMat = mat4
|
||||
( 1.0, 0.0, 0.0, 0.0
|
||||
, 0.0, 1.0, 0.0, 0.0
|
||||
, 0.0, 0.0, 1.0, 0.0
|
||||
, -translation.x, -translation.y, 0.0, 1.0
|
||||
) ;
|
||||
mat4 rotMat = mat4
|
||||
( cos(rotation), sin(-rotation), 0.0, 0.0
|
||||
, sin(rotation), cos(rotation), 0.0, 0.0
|
||||
, 0.0, 0.0, 1.0, 0.0
|
||||
, 0.0, 0.0, 0.0, 1.0
|
||||
) ;
|
||||
mat4 scalMat = mat4
|
||||
( 2*zoom/winSize.x, 0.0, 0.0, 0.0
|
||||
, 0.0, 2*zoom/winSize.y, 0.0, 0.0
|
||||
, 0.0, 0.0, 1.0, 0.0
|
||||
, 0.0, 0.0, 0.0, 1.0
|
||||
) ;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(scal(rot(tran(position.xy))),position.z,1);
|
||||
gl_Position = scalMat * rotMat * tranMat * vec4(position.xyz,1);
|
||||
vColor = color;
|
||||
vRad = rad;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ uniform vec2 winSize;
|
||||
uniform float zoom;
|
||||
uniform vec2 translation;
|
||||
uniform float rotation;
|
||||
uniform mat4 worldMat;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ uniform vec2 winSize;
|
||||
uniform float zoom;
|
||||
uniform float rotation;
|
||||
uniform vec2 translation;
|
||||
uniform mat4 worldMat;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user