diff options
Diffstat (limited to 'source/gameengine/Rasterizer')
11 files changed, 131 insertions, 40 deletions
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index 61860c4c405..ab00658dde6 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -57,6 +57,7 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, m_polymatid(m_newpolymatid++), m_flag(0), m_enabled(0), + m_enabledattribs(0), m_multimode(0) { m_shininess = 35.0; @@ -153,5 +154,11 @@ const unsigned int RAS_IPolyMaterial::GetEnabled() const return m_enabled; } +const unsigned int RAS_IPolyMaterial::GetEnabledAttribs() const +{ + return m_enabledattribs; +} + + unsigned int RAS_IPolyMaterial::m_newpolymatid = 0; diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 3284ddb7ddd..0813b7f7463 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -78,6 +78,7 @@ protected: // will move... unsigned int m_flag;//MaterialProps unsigned int m_enabled;// enabled for this mat + unsigned int m_enabledattribs;// attribs enabled for this mat int m_multimode; // sum of values public: @@ -142,6 +143,7 @@ public: const STR_String& GetTextureName() const; const unsigned int GetFlag() const; const unsigned int GetEnabled() const; + const unsigned int GetEnabledAttribs() const; /* * PreCalculate texture gen diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 18a7f261c94..fb2c898cdd5 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -390,6 +390,7 @@ public: virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)=0; virtual void SetTexCoords(TexCoGen coords, int unit) = 0; + virtual void SetTexCoordsAttrib(TexCoGen coords, int unit) = 0; virtual void SetAttrib(int type) = 0; virtual void GetViewMatrix(MT_Matrix4x4 &mat) const = 0; diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index e4b654343e7..0374ffba478 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -256,13 +256,14 @@ int RAS_MeshObject::FindOrAddVertex(int vtxarray, const MT_Vector4& tangent, const unsigned int rgbacolor, const MT_Vector3& normal, + bool flat, RAS_IPolyMaterial* mat, int orgindex) { KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray]; - RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, 0); + RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, flat? TV_CALCFACENORMAL: 0); #define KX_FIND_SHARED_VERTICES #ifdef KX_FIND_SHARED_VERTICES diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index 89c472cd0d4..d8e7a3391aa 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -238,6 +238,7 @@ public: const MT_Vector4& tangent, const unsigned int rgbacolor, const MT_Vector3& normal, + bool flat, RAS_IPolyMaterial* mat, int orgindex ); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp index 81a7ccb7a5d..43405779998 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp @@ -426,6 +426,7 @@ PFNGLGETATTRIBLOCATIONARBPROC blGetAttribLocationARB; PFNGLVERTEXATTRIB3FVARBPROC blVertexAttrib3fvARB; PFNGLVERTEXATTRIB4FARBPROC blVertexAttrib4fARB; PFNGLVERTEXATTRIB4FVARBPROC blVertexAttrib4fvARB; + PFNGLVERTEXATTRIBPOINTERARBPROC blVertexAttribPointerARB; PFNGLGETPROGRAMSTRINGARBPROC blGetProgramStringARB; PFNGLGETVERTEXATTRIBDVARBPROC blGetVertexAttribdvARB; PFNGLGETVERTEXATTRIBFVARBPROC blGetVertexAttribfvARB; @@ -634,6 +635,7 @@ static void LinkExtensions() bgl::blVertexAttrib3fvARB = reinterpret_cast<PFNGLVERTEXATTRIB3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib3fvARB")); bgl::blVertexAttrib4fARB = reinterpret_cast<PFNGLVERTEXATTRIB4FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib4fARB")); bgl::blVertexAttrib4fvARB = reinterpret_cast<PFNGLVERTEXATTRIB4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib4fvARB")); + bgl::blVertexAttribPointerARB = reinterpret_cast<PFNGLVERTEXATTRIBPOINTERARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttribPointerARB")); bgl::blGetVertexAttribdvARB = reinterpret_cast<PFNGLGETVERTEXATTRIBDVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribdvARB")); bgl::blGetVertexAttribfvARB = reinterpret_cast<PFNGLGETVERTEXATTRIBFVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribfvARB")); bgl::blGetVertexAttribivARB = reinterpret_cast<PFNGLGETVERTEXATTRIBIVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribivARB")); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h index 3e24ee204a1..fd253d7030c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h @@ -523,6 +523,7 @@ extern PFNGLVERTEXATTRIB3FARBPROC blVertexAttrib3fARB; extern PFNGLVERTEXATTRIB3FVARBPROC blVertexAttrib3fvARB; extern PFNGLVERTEXATTRIB4FARBPROC blVertexAttrib4fARB; extern PFNGLVERTEXATTRIB4FVARBPROC blVertexAttrib4fvARB; +extern PFNGLVERTEXATTRIBPOINTERARBPROC blVertexAttribPointerARB; extern PFNGLGETPROGRAMSTRINGARBPROC blGetProgramStringARB; extern PFNGLGETVERTEXATTRIBDVARBPROC blGetVertexAttribdvARB; extern PFNGLGETVERTEXATTRIBFVARBPROC blGetVertexAttribfvARB; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index f99121e5b7c..f07e54d92a8 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -1213,12 +1213,19 @@ void RAS_OpenGLRasterizer::SetTexCoords(TexCoGen coords,int unit) m_texco[unit] = coords; } +void RAS_OpenGLRasterizer::SetTexCoordsAttrib(TexCoGen coords,int unit) +{ + // this changes from material to material + if(unit < RAS_MAX_ATTRIB) + m_texcoattrib[unit] = coords; +} + void RAS_OpenGLRasterizer::SetAttrib(int type) { if(type == RAS_TEXTANGENT) m_useTang=true; } -void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv, int enabled) +void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv, int enabled, int enabledattribs) { #if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) if (!getenv("WITHOUT_GLEXT")) { @@ -1256,8 +1263,39 @@ void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv, int enabled) #endif #ifdef GL_ARB_vertex_program - if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program) - bgl::blVertexAttrib4fvARB(1/*tangent*/, tv.getTangent()); + if(bgl::RAS_EXT_support._ARB_vertex_program) { + for(int unit=0; unit<enabledattribs; unit++) { + if( tv.getFlag() & TV_2NDUV && tv.getUnit() == unit ) { + bgl::blVertexAttrib2fvARB(unit, tv.getUV2()); + continue; + } + switch(m_texcoattrib[unit]) { + case RAS_TEXCO_DISABLE: + case RAS_TEXCO_OBJECT: + case RAS_TEXCO_GEN: + break; + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + bgl::blVertexAttrib3fvARB(unit, tv.getLocalXYZ()); + break; + case RAS_TEXCO_UV1: + bgl::blVertexAttrib2fvARB(unit, tv.getUV1()); + break; + case RAS_TEXCO_NORM: + bgl::blVertexAttrib3fvARB(unit, tv.getNormal()); + break; + case RAS_TEXTANGENT: + bgl::blVertexAttrib4fvARB(unit, tv.getTangent()); + break; + case RAS_TEXCO_UV2: + bgl::blVertexAttrib2fvARB(unit, tv.getUV2()); + break; + } + } + + if(m_useTang) + bgl::blVertexAttrib4fvARB(1/*tangent*/, tv.getTangent()); + } #endif } @@ -1332,6 +1370,7 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti( const KX_IndexArray & indexarray = (*indexarrays[vt]); numindices = indexarray.size(); const unsigned int enabled = polymat->GetEnabled(); + const unsigned int enabledattribs = polymat->GetEnabledAttribs(); if (!numindices) break; @@ -1364,25 +1403,25 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti( // glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; } @@ -1399,28 +1438,28 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti( glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; } @@ -1440,19 +1479,19 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti( glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); // glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; } @@ -1464,21 +1503,21 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti( // glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; // glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; } @@ -1533,6 +1572,7 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( const KX_IndexArray & indexarray = (*indexarrays[vt]); numindices = indexarray.size(); const unsigned int enabled = polymat->GetEnabled(); + const unsigned int enabledattribs = polymat->GetEnabledAttribs(); if (!numindices) continue; @@ -1584,27 +1624,27 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; } @@ -1640,7 +1680,7 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; @@ -1648,7 +1688,7 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; @@ -1656,7 +1696,7 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; @@ -1664,7 +1704,7 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; } @@ -1701,19 +1741,19 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; } @@ -1743,21 +1783,21 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); if (!recalc) glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); + TexCoord(vertexarray[(indexarray[vindex])],enabled,enabledattribs ); glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); vindex++; } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 23714a12151..4282df97df2 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -41,7 +41,8 @@ using namespace std; #include "RAS_MaterialBucket.h" #include "RAS_ICanvas.h" -#define RAS_MAX 3// match in BL_Material +#define RAS_MAX 3 // match in BL_Material +#define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader struct OglDebugLine { @@ -95,6 +96,7 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer protected: int m_drawingmode; TexCoGen m_texco[RAS_MAX]; + TexCoGen m_texcoattrib[RAS_MAX_ATTRIB]; bool m_useTang; /** Stores the caching information for the last material activated. */ @@ -286,9 +288,10 @@ public: std::vector <OglDebugLine> m_debugLines; - virtual void SetTexCoords(TexCoGen coords,int enabled); + virtual void SetTexCoords(TexCoGen coords,int unit); + virtual void SetTexCoordsAttrib(TexCoGen coords,int unit); virtual void SetAttrib(int type); - void TexCoord(const RAS_TexVert &tv, int unit); + void TexCoord(const RAS_TexVert &tv, int enabled, int enabledattribs); virtual void GetViewMatrix(MT_Matrix4x4 &mat) const; void Tangent(const RAS_TexVert& v1, diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index ddfcc3f3f9d..ec99e2c2c44 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -244,6 +244,7 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa const RAS_TexVert* vertexarray; unsigned int numindices, vt; const unsigned int enabled = polymat->GetEnabled(); + const unsigned int enabledattribs = polymat->GetEnabledAttribs(); if (drawmode != GL_LINES) { @@ -273,7 +274,7 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa continue; glVertexPointer(3,GL_FLOAT,vtxstride,vertexarray->getLocalXYZ()); - TexCoordPtr(vertexarray, enabled); + TexCoordPtr(vertexarray, enabled, enabledattribs); //glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1()); glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); @@ -290,7 +291,7 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa } } -void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv, int enabled) +void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv, int enabled, int enabledattribs) { #if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) if (!getenv("WITHOUT_GLEXT")) { @@ -331,11 +332,43 @@ void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv, int enabled) } } } + } +#endif #ifdef GL_ARB_vertex_program - if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program) + if(bgl::RAS_EXT_support._ARB_vertex_program) { + for(int unit=0; unit<enabledattribs; unit++) { + if( tv->getFlag() & TV_2NDUV && tv->getUnit() == unit ) { + bgl::blVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV2()); + continue; + } + switch(m_texcoattrib[unit]) { + case RAS_TEXCO_DISABLE: + case RAS_TEXCO_OBJECT: + case RAS_TEXCO_GEN: + break; + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + bgl::blVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getLocalXYZ()); + break; + case RAS_TEXCO_UV1: + bgl::blVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV1()); + break; + case RAS_TEXCO_NORM: + bgl::blVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal()); + break; + case RAS_TEXTANGENT: + bgl::blVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getTangent()); + break; + case RAS_TEXCO_UV2: + bgl::blVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV2()); + break; + } + } + + /* TODO brecht: this looks broken? test if it ever runs */ + if(m_useTang) bgl::blVertexAttrib4fvARB(1/*tangent*/, tv->getTangent()); -#endif } #endif } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h index 4d478b0171f..a793e070a4c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h @@ -33,7 +33,7 @@ class RAS_VAOpenGLRasterizer : public RAS_OpenGLRasterizer { - void TexCoordPtr(const RAS_TexVert *tv, int unit); + void TexCoordPtr(const RAS_TexVert *tv, int enabled, int enabledattribs); bool m_Lock; public: |