diff --git a/Engine/source/gfx/gfxDevice.h b/Engine/source/gfx/gfxDevice.h index 2fa414cdd..ca5d3f94d 100644 --- a/Engine/source/gfx/gfxDevice.h +++ b/Engine/source/gfx/gfxDevice.h @@ -868,6 +868,8 @@ public: /// Sets the current stateblock (actually activated in ::updateStates) virtual void setStateBlock( GFXStateBlock *block ); + GFXStateBlock* getStateBlock() { return mNewStateBlock; } + /// This sets a stateblock directly from the description /// structure. Its acceptable to use this for debug rendering /// and other low frequency rendering tasks. diff --git a/Engine/source/gfx/primBuilder.cpp b/Engine/source/gfx/primBuilder.cpp index 42ac2d495..af33d3a41 100644 --- a/Engine/source/gfx/primBuilder.cpp +++ b/Engine/source/gfx/primBuilder.cpp @@ -179,8 +179,19 @@ void end( bool useGenericShaders ) } } - if ( useGenericShaders ) - GFX->setupGenericShaders( GFXDevice::GSModColorTexture ); + if ( useGenericShaders ) + { + GFXStateBlock *currentBlock = GFX->getStateBlock(); + if (currentBlock && currentBlock->getDesc().samplersDefined) + { + if (currentBlock->getDesc().vertexColorEnable) + GFX->setupGenericShaders( GFXDevice::GSModColorTexture ); + else + GFX->setupGenericShaders( GFXDevice::GSTexture ); + } + else + GFX->setupGenericShaders( GFXDevice::GSColor ); + } const GFXVertexPCT *srcVerts = mTempVertBuff.address(); U32 numVerts = mCurVertIndex;