1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Standarize the number of barycentric coordinate vertex attributes.

Use only two coordinates as vertex attributes for triangles to match the number of coordinates rectangles use. The third one can be computed in the vertex shader.
This commit is contained in:
S2S 2020-12-25 19:58:40 +01:00 committed by Sergey Lipskiy
parent 47054eabc0
commit a214ab822e
6 changed files with 8 additions and 11 deletions

View File

@ -278,7 +278,7 @@ public:
"IN highp vec2 aTexCoord; \n"
"IN lowp float aNumLights; \n"
"IN highp vec4 aModify; \n"
"IN highp vec3 aBaryCoords; \n"
"IN highp vec2 aBaryCoords; \n"
" \n"
"uniform int uTexturePersp; \n"
"uniform lowp int uTextureFilterMode; \n"
@ -350,7 +350,7 @@ public:
" else \n"
" vShadeColor.rgb = vec3(fp); \n"
" } \n"
" vBaryCoords = vec4(aBaryCoords, 0.5f); \n"
" vBaryCoords = vec4(aBaryCoords, 1.0 - aBaryCoords.x - aBaryCoords.y, 0.5f); \n"
;
}
};
@ -365,7 +365,7 @@ public:
"IN lowp vec4 aColor; \n"
"IN lowp float aNumLights; \n"
"IN highp vec4 aModify; \n"
"IN highp vec3 aBaryCoords; \n"
"IN highp vec2 aBaryCoords; \n"
" \n"
"uniform lowp int uFogUsage; \n"
"uniform mediump vec2 uFogScale; \n"
@ -410,7 +410,7 @@ public:
" else \n"
" vShadeColor.rgb = vec3(fp); \n"
" } \n"
" vBaryCoords = vec4(aBaryCoords, 0.5f); \n"
" vBaryCoords = vec4(aBaryCoords, 1.0 - aBaryCoords.x - aBaryCoords.y, 0.5f); \n"
;
}
};

View File

@ -50,7 +50,7 @@ BufferedDrawer::BufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArray *
glVertexAttribPointer(triangleAttrib::color, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, r)));
glVertexAttribPointer(triangleAttrib::texcoord, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, s)));
glVertexAttribPointer(triangleAttrib::modify, 4, GL_BYTE, GL_TRUE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, modify)));
glVertexAttribPointer(triangleAttrib::barycoords, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)(offsetof(Vertex, bc0)));
glVertexAttribPointer(triangleAttrib::barycoords, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)(offsetof(Vertex, bc0)));
}
void BufferedDrawer::_initBuffer(Buffer & _buffer, GLuint _bufSize)
@ -168,7 +168,6 @@ void BufferedDrawer::_convertFromSPVertex(bool _flatColors, u32 _count, const SP
dst.modify = src.modify;
dst.bc0 = src.bc0;
dst.bc1 = src.bc1;
dst.bc2 = src.bc2;
}
}

View File

@ -58,7 +58,7 @@ namespace opengl {
f32 r, g, b, a;
f32 s, t;
u32 modify;
f32 bc0, bc1, bc2;
f32 bc0, bc1;
};
void _initBuffer(Buffer & _buffer, GLuint _bufSize);

View File

@ -75,7 +75,7 @@ void UnbufferedDrawer::drawTriangles(const graphics::Context::DrawTriangleParame
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, true);
const void * ptr = &_params.vertices->bc0;
if (_updateAttribPointer(triangleAttrib::barycoords, ptr))
glVertexAttribPointer(triangleAttrib::barycoords, 3, GL_FLOAT, GL_FALSE, sizeof(SPVertex), ptr);
glVertexAttribPointer(triangleAttrib::barycoords, 2, GL_FLOAT, GL_FALSE, sizeof(SPVertex), ptr);
}
if (isHWLightingAllowed())

View File

@ -62,7 +62,6 @@ void GraphicsDrawer::addTriangle(u32 _v0, u32 _v1, u32 _v2)
SPVertex& vtx = triangles.vertices[triangles.elements[i]];
vtx.bc0 = i - firstIndex == 0 ? 1.0f : 0.0f;
vtx.bc1 = i - firstIndex == 1 ? 1.0f : 0.0f;
vtx.bc2 = i - firstIndex == 2 ? 1.0f : 0.0f;
}
if ((gSP.geometryMode & G_LIGHTING) == 0) {
@ -863,7 +862,6 @@ void GraphicsDrawer::drawScreenSpaceTriangle(u32 _numVtx, graphics::DrawModePara
vtx.bc0 = (i % 3 == 0) ? 1.0f : 0.0f;
vtx.bc1 = (i % 3 == 1) ? 1.0f : 0.0f;
vtx.bc2 = (i % 3 == 2) ? 1.0f : 0.0f;
}
m_modifyVertices = MODIFY_ALL;

View File

@ -40,7 +40,7 @@ struct SPVertex
f32 r, g, b, a;
f32 flat_r, flat_g, flat_b, flat_a;
f32 s, t;
f32 bc0, bc1, bc2;
f32 bc0, bc1;
u32 modify;
u8 HWLight;
u8 clip;