mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Implement of the shader consts binding.
This commit is contained in:
parent
74138342d1
commit
70c154c7d3
12 changed files with 137 additions and 7 deletions
|
|
@ -41,6 +41,8 @@
|
|||
#include "gfx/util/screenspace.h"
|
||||
#include "math/util/matrixSet.h"
|
||||
|
||||
#include "ts/tsRenderState.h"
|
||||
|
||||
// We need to include customMaterialDefinition for ShaderConstHandles::init
|
||||
#include "materials/customMaterialDefinition.h"
|
||||
|
||||
|
|
@ -118,6 +120,21 @@ void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/
|
|||
mMatInfoFlagsSC = shader->getShaderConstHandle(ShaderGenVars::matInfoFlags);
|
||||
}
|
||||
|
||||
void CustomFeatureShaderConstHandles::init(GFXShader *shader, Vector<CustomShaderFeatureData*> customFeatureData)
|
||||
{
|
||||
for (U32 f = 0; f < customFeatureData.size(); ++f)
|
||||
{
|
||||
for (U32 i = 0; i < customFeatureData[f]->mAddedShaderConstants.size(); ++i)
|
||||
{
|
||||
handleData newSC;
|
||||
newSC.handle = shader->getShaderConstHandle(customFeatureData[f]->mAddedShaderConstants[i]);
|
||||
newSC.handleName = customFeatureData[f]->mAddedShaderConstants[i];
|
||||
|
||||
mHandles.push_back(newSC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// ShaderRenderPassData
|
||||
///
|
||||
|
|
@ -659,6 +676,9 @@ bool ProcessedShaderMaterial::_addPass( ShaderRenderPassData &rpd,
|
|||
return false;
|
||||
rpd.shaderHandles.init( rpd.shader );
|
||||
|
||||
//Store our customShaderFeature handles
|
||||
rpd.customFeatureShaderHandles.init(rpd.shader, mMaterial->mCustomShaderFeatures);
|
||||
|
||||
// If a pass glows, we glow
|
||||
if( rpd.mGlow )
|
||||
mHasGlow = true;
|
||||
|
|
@ -1297,6 +1317,20 @@ void ProcessedShaderMaterial::setSceneInfo(SceneRenderState * state, const Scene
|
|||
for ( U32 i=0; i < rpd->featureShaderHandles.size(); i++ )
|
||||
rpd->featureShaderHandles[i]->setConsts( state, sgData, shaderConsts );
|
||||
|
||||
for (U32 i = 0; i < sgData.customShaderData.size(); i++)
|
||||
{
|
||||
//roll through and try setting our data!
|
||||
for (U32 h = 0; h < rpd->customFeatureShaderHandles.mHandles.size(); ++h)
|
||||
{
|
||||
if (rpd->customFeatureShaderHandles.mHandles[h].handleName == sgData.customShaderData[i]->getHandleName())
|
||||
{
|
||||
if(sgData.customShaderData[i]->getType() == CustomShaderBindingData::Float)
|
||||
shaderConsts->setSafe(rpd->customFeatureShaderHandles.mHandles[h].handle, sgData.customShaderData[i]->getFloat());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LIGHTMGR->setLightInfo( this, mMaterial, sgData, state, pass, shaderConsts );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue