From 3657eb9bce4816e10a4492fa9c16bfebd69b499e Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 6 Feb 2021 19:36:50 +0100 Subject: [PATCH] glgsg: Support texture transforms in default shader --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 0ea627fdd2..6f6d153bb0 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -179,10 +179,11 @@ static const string default_vshader = "varying lowp vec4 color;\n" #endif "uniform mat4 p3d_ModelViewProjectionMatrix;\n" + "uniform mat4 p3d_TextureMatrix;\n" "uniform vec4 p3d_ColorScale;\n" "void main(void) {\n" " gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n" - " texcoord = p3d_MultiTexCoord0;\n" + " texcoord = (p3d_TextureMatrix * vec4(p3d_MultiTexCoord0.x, p3d_MultiTexCoord0.y, 0, 1)).xy;\n" " color = p3d_Color * p3d_ColorScale;\n" "}\n"; @@ -203,10 +204,11 @@ static const string default_vshader_fp64 = "out vec4 color;\n" "uniform mat4 p3d_ModelViewMatrix;\n" "uniform mat4 p3d_ProjectionMatrix;\n" + "uniform mat4 p3d_TextureMatrix;\n" "uniform vec4 p3d_ColorScale;\n" "void main(void) {\n" // Apply proj & modelview in two steps, more precise " gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n" - " texcoord = vec2(p3d_MultiTexCoord0);\n" + " texcoord = (p3d_TextureMatrix * vec4(p3d_MultiTexCoord0.x, p3d_MultiTexCoord0.y, 0, 1)).xy;\n" " color = p3d_Color * p3d_ColorScale;\n" "}\n"; @@ -220,10 +222,11 @@ static const string default_vshader_fp64_gl41 = "out vec4 color;\n" "uniform mat4 p3d_ModelViewMatrix;\n" "uniform mat4 p3d_ProjectionMatrix;\n" + "uniform mat4 p3d_TextureMatrix;\n" "uniform vec4 p3d_ColorScale;\n" "void main(void) {\n" // Apply proj & modelview in two steps, more precise " gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n" - " texcoord = vec2(p3d_MultiTexCoord0);\n" + " texcoord = (p3d_TextureMatrix * vec4(p3d_MultiTexCoord0.x, p3d_MultiTexCoord0.y, 0, 1)).xy;\n" " color = p3d_Color * p3d_ColorScale;\n" "}\n"; #endif