Fix preview scale

This commit is contained in:
KillzXGaming 2019-03-24 11:31:19 -04:00
parent fbbbbd51bf
commit ab44950984
12 changed files with 12 additions and 8 deletions

Binary file not shown.

View file

@ -554,8 +554,8 @@ namespace FirstPlugin
SetRenderSettings(defaultShaderProgram);
Matrix4 previewScale = Utils.TransformValues(Vector3.Zero, Vector3.Zero, Runtime.previewScale);
Matrix4 camMat = previewScale * control.mtxCam * control.mtxProj;
defaultShaderProgram.SetMatrix4x4("previewScale", ref previewScale);
GL.Disable(EnableCap.CullFace);

View file

@ -292,6 +292,8 @@ namespace FirstPlugin
control.UpdateModelMatrix(ModelTransform);
Matrix4 previewScale = Utils.TransformValues(Vector3.Zero, Vector3.Zero, Runtime.previewScale);
shader.SetMatrix4x4("previewScale", ref previewScale);
Matrix4 camMat = previewScale * control.mtxCam * control.mtxProj;
Matrix4 sphereMatrix = camMat;

View file

@ -59,7 +59,7 @@ namespace Switch_Toolbox.Library
else
position = bone * rotation * vec4((point.xyz - vec3(0, 1, 0)) * scale, 1);
}
gl_Position = mtxCam * mtxMdl * vec4(position.xyz, 1);
gl_Position = mtxCam * mtxMdl * previewScale * vec4(position.xyz, 1);
}");

View file

@ -89,7 +89,7 @@ namespace Switch_Toolbox.Library.Rendering
control.CurrentShader = solidColorShaderProgram;
Matrix4 previewScale = Utils.TransformValues(Vector3.Zero, Vector3.Zero, Runtime.previewScale);
Matrix4 camMat = previewScale * control.mtxCam * control.mtxProj;
Matrix4 camMat = control.mtxCam * control.mtxProj;
Matrix4 invertedCamera = camMat.Inverted();
Vector3 lightDirection = new Vector3(0f, 0f, -1f);

View file

@ -3,6 +3,7 @@
uniform mat4 mtxCam;
uniform mat4 mtxMdl;
uniform mat4 sphereMatrix;
uniform mat4 previewScale;
in vec3 vPosition;
in vec3 vNormal;
@ -135,7 +136,7 @@ void main()
if (vBone.x != -1.0)
objPos = skin(vPosition, index);
vec4 position = mtxCam * mtxMdl * vec4(objPos.xyz, 1.0);
vec4 position = mtxCam * mtxMdl * previewScale * vec4(objPos.xyz, 1.0);
normal = vNormal;
viewNormal = mat3(sphereMatrix) * normal.xyz;
@ -146,17 +147,17 @@ void main()
if (RigidSkinning == 1)
{
position = mtxCam * mtxMdl * (bones[index.x] * vec4(vPosition, 1.0));
position = mtxCam * mtxMdl * previewScale * (bones[index.x] * vec4(vPosition, 1.0));
normal = mat3(bones[index.x]) * vNormal.xyz * 1;
}
if (NoSkinning == 1)
{
position = mtxCam * mtxMdl * (SingleBoneBindTransform * vec4(vPosition, 1.0));
position = mtxCam * mtxMdl * previewScale * (SingleBoneBindTransform * vec4(vPosition, 1.0));
normal = mat3(SingleBoneBindTransform) * vNormal.xyz * 1;
//normal = normalize(normal);
}
gl_Position = position;
gl_Position =position;
f_texcoord0 = vUV0;

View file

@ -12,6 +12,7 @@ out vec3 position;
uniform mat4 mtxCam;
uniform mat4 mtxMdl;
uniform mat4 previewScale;
void main()
{
@ -19,7 +20,7 @@ void main()
color = vColor;
position = vPosition;
gl_Position = mtxCam * mtxMdl * vec4(vPosition.xyz, 1.0);
gl_Position = mtxCam * mtxMdl * previewScale * vec4(vPosition.xyz, 1.0);
vec3 distance = (vPosition.xyz + vec3(5, 5, 5))/2;