glgsg: Correctly handle 4-component texcoords in default shader

This commit is contained in:
rdb 2023-01-13 19:35:45 +01:00
parent 67c413f089
commit 7a8e218da7

View File

@ -171,23 +171,23 @@ static const string default_vshader =
#endif #endif
"in vec4 p3d_Vertex;\n" "in vec4 p3d_Vertex;\n"
"in vec4 p3d_Color;\n" "in vec4 p3d_Color;\n"
"in vec2 p3d_MultiTexCoord0;\n" "in vec4 p3d_MultiTexCoord0;\n"
"out vec2 texcoord;\n" "out vec3 texcoord;\n"
"out vec4 color;\n" "out vec4 color;\n"
#else #else
"#version 100\n" "#version 100\n"
"precision mediump float;\n" "precision mediump float;\n"
"attribute vec4 p3d_Vertex;\n" "attribute vec4 p3d_Vertex;\n"
"attribute vec4 p3d_Color;\n" "attribute vec4 p3d_Color;\n"
"attribute vec2 p3d_MultiTexCoord0;\n" "attribute vec4 p3d_MultiTexCoord0;\n"
"varying vec2 texcoord;\n" "varying vec3 texcoord;\n"
"varying lowp vec4 color;\n" "varying lowp vec4 color;\n"
#endif #endif
"uniform mat4 p3d_ModelViewProjectionMatrix;\n" "uniform mat4 p3d_ModelViewProjectionMatrix;\n"
"uniform vec4 p3d_ColorScale;\n" "uniform vec4 p3d_ColorScale;\n"
"void main(void) {\n" "void main(void) {\n"
" gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n" " gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n"
" texcoord = p3d_MultiTexCoord0;\n" " texcoord = p3d_MultiTexCoord0.xyw;\n"
" color = p3d_Color * p3d_ColorScale;\n" " color = p3d_Color * p3d_ColorScale;\n"
"}\n"; "}\n";
@ -203,15 +203,15 @@ static const string default_vshader_fp64 =
"#extension GL_ARB_gpu_shader_fp64 : require\n" "#extension GL_ARB_gpu_shader_fp64 : require\n"
"in dvec3 p3d_Vertex;\n" "in dvec3 p3d_Vertex;\n"
"in vec4 p3d_Color;\n" "in vec4 p3d_Color;\n"
"in dvec2 p3d_MultiTexCoord0;\n" "in dvec4 p3d_MultiTexCoord0;\n"
"out vec2 texcoord;\n" "out vec3 texcoord;\n"
"out vec4 color;\n" "out vec4 color;\n"
"uniform mat4 p3d_ModelViewMatrix;\n" "uniform mat4 p3d_ModelViewMatrix;\n"
"uniform mat4 p3d_ProjectionMatrix;\n" "uniform mat4 p3d_ProjectionMatrix;\n"
"uniform vec4 p3d_ColorScale;\n" "uniform vec4 p3d_ColorScale;\n"
"void main(void) {\n" // Apply proj & modelview in two steps, more precise "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" " gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n"
" texcoord = vec2(p3d_MultiTexCoord0);\n" " texcoord = vec3(p3d_MultiTexCoord0.xyw);\n"
" color = p3d_Color * p3d_ColorScale;\n" " color = p3d_Color * p3d_ColorScale;\n"
"}\n"; "}\n";
@ -220,15 +220,15 @@ static const string default_vshader_fp64_gl41 =
"#version 410\n" "#version 410\n"
"in dvec3 p3d_Vertex;\n" "in dvec3 p3d_Vertex;\n"
"in vec4 p3d_Color;\n" "in vec4 p3d_Color;\n"
"in dvec2 p3d_MultiTexCoord0;\n" "in dvec4 p3d_MultiTexCoord0;\n"
"out vec2 texcoord;\n" "out vec3 texcoord;\n"
"out vec4 color;\n" "out vec4 color;\n"
"uniform mat4 p3d_ModelViewMatrix;\n" "uniform mat4 p3d_ModelViewMatrix;\n"
"uniform mat4 p3d_ProjectionMatrix;\n" "uniform mat4 p3d_ProjectionMatrix;\n"
"uniform vec4 p3d_ColorScale;\n" "uniform vec4 p3d_ColorScale;\n"
"void main(void) {\n" // Apply proj & modelview in two steps, more precise "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" " gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n"
" texcoord = vec2(p3d_MultiTexCoord0);\n" " texcoord = vec3(p3d_MultiTexCoord0.xyw);\n"
" color = p3d_Color * p3d_ColorScale;\n" " color = p3d_Color * p3d_ColorScale;\n"
"}\n"; "}\n";
#endif #endif
@ -240,7 +240,7 @@ static const string default_fshader =
#else #else
"#version 130\n" "#version 130\n"
#endif #endif
"in vec2 texcoord;\n" "in vec3 texcoord;\n"
"in vec4 color;\n" "in vec4 color;\n"
"out vec4 p3d_FragColor;\n" "out vec4 p3d_FragColor;\n"
"uniform sampler2D p3d_Texture0;\n" "uniform sampler2D p3d_Texture0;\n"
@ -248,18 +248,18 @@ static const string default_fshader =
#else #else
"#version 100\n" "#version 100\n"
"precision mediump float;\n" "precision mediump float;\n"
"varying vec2 texcoord;\n" "varying vec3 texcoord;\n"
"varying lowp vec4 color;\n" "varying lowp vec4 color;\n"
"uniform lowp sampler2D p3d_Texture0;\n" "uniform lowp sampler2D p3d_Texture0;\n"
"uniform lowp vec4 p3d_TexAlphaOnly;\n" "uniform lowp vec4 p3d_TexAlphaOnly;\n"
#endif #endif
"void main(void) {\n" "void main(void) {\n"
#ifndef OPENGLES #ifndef OPENGLES
" p3d_FragColor = texture(p3d_Texture0, texcoord);\n" " p3d_FragColor = textureProj(p3d_Texture0, texcoord);\n"
" p3d_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering " p3d_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering
" p3d_FragColor *= color;\n" " p3d_FragColor *= color;\n"
#else #else
" gl_FragColor = texture2D(p3d_Texture0, texcoord);\n" " gl_FragColor = texture2DProj(p3d_Texture0, texcoord);\n"
" gl_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering " gl_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering
" gl_FragColor *= color;\n" " gl_FragColor *= color;\n"
#endif #endif