mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Merge branch 'ModernEditorLayoutWIP' of https://github.com/Areloch/Torque3D into development
This commit is contained in:
commit
3697737498
148 changed files with 3463 additions and 547 deletions
|
|
@ -680,10 +680,30 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
|||
rdata.setAccuTex(mAccuTex);
|
||||
|
||||
//Various arbitrary shader render bits to add
|
||||
CustomShaderBindingData strudelCSB;
|
||||
strudelCSB.setFloat4(StringTable->insert("overrideColor"), mOverrideColor);
|
||||
if (mCustomShaderBinds.empty())
|
||||
{
|
||||
CustomShaderBindingData minBnds;
|
||||
minBnds.setFloat3(StringTable->insert("objectBoundsMin"), getWorldBox().minExtents);
|
||||
mCustomShaderBinds.push_back(minBnds);
|
||||
|
||||
rdata.addCustomShaderBinding(strudelCSB);
|
||||
CustomShaderBindingData maxBnds;
|
||||
maxBnds.setFloat3(StringTable->insert("objectBoundsMax"), getWorldBox().maxExtents);
|
||||
mCustomShaderBinds.push_back(maxBnds);
|
||||
|
||||
CustomShaderBindingData colorMin;
|
||||
colorMin.setFloat3(StringTable->insert("colorMin"), Point3F(1,0,0));
|
||||
mCustomShaderBinds.push_back(colorMin);
|
||||
|
||||
CustomShaderBindingData colorMax;
|
||||
colorMax.setFloat3(StringTable->insert("colorMax"), Point3F(0, 1, 0));
|
||||
mCustomShaderBinds.push_back(colorMax);
|
||||
}
|
||||
|
||||
if (!mCustomShaderBinds.empty())
|
||||
{
|
||||
for(U32 i=0; i < mCustomShaderBinds.size(); i++)
|
||||
rdata.addCustomShaderBinding(mCustomShaderBinds[i]);
|
||||
}
|
||||
|
||||
// If we have submesh culling enabled then prepare
|
||||
// the object space frustum to pass to the shape.
|
||||
|
|
|
|||
|
|
@ -203,6 +203,8 @@ protected:
|
|||
F32 mRenderNormalScalar;
|
||||
S32 mForceDetail;
|
||||
|
||||
Vector<CustomShaderBindingData> mCustomShaderBinds;
|
||||
|
||||
public:
|
||||
|
||||
TSStatic();
|
||||
|
|
|
|||
|
|
@ -832,6 +832,8 @@ GuiTreeViewCtrl::GuiTreeViewCtrl()
|
|||
mTexSelected = NULL;
|
||||
|
||||
mRenderTooltipDelegate.bind( this, &GuiTreeViewCtrl::renderTooltip );
|
||||
|
||||
mDoFilterChildren = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -1122,7 +1124,7 @@ void GuiTreeViewCtrl::_expandObjectHierarchy( SimGroup* group )
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdate )
|
||||
void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdate, bool skipFlter )
|
||||
{
|
||||
if (!item || !mActive || !isVisible() || !mProfile )
|
||||
return;
|
||||
|
|
@ -1145,7 +1147,7 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
|
|||
|
||||
// If we have a filter pattern, sync the item's filtering status to it.
|
||||
|
||||
if( !getFilterText().isEmpty() )
|
||||
if( !getFilterText().isEmpty() && !skipFlter)
|
||||
{
|
||||
// Determine the filtering status by looking for the filter
|
||||
// text in the item's display text.
|
||||
|
|
@ -1154,7 +1156,11 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
|
|||
item->getDisplayText( sizeof( displayText ), displayText );
|
||||
if( !dStristr( displayText, mFilterText ) )
|
||||
{
|
||||
item->mState.set( Item::Filtered );
|
||||
//Last check, see if we special-exception this item
|
||||
if (!mItemFilterExceptionList.contains(item->mId))
|
||||
item->mState.set(Item::Filtered);
|
||||
else
|
||||
item->mState.clear(Item::Filtered);
|
||||
|
||||
// If it's not a parent, we're done. Otherwise, there may be children
|
||||
// that are not filtered so we need to process them first.
|
||||
|
|
@ -1163,7 +1169,9 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
|
|||
return;
|
||||
}
|
||||
else
|
||||
item->mState.clear( Item::Filtered );
|
||||
{
|
||||
item->mState.clear(Item::Filtered);
|
||||
}
|
||||
}
|
||||
else
|
||||
item->mState.clear( Item::Filtered );
|
||||
|
|
@ -1217,7 +1225,10 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
|
|||
Item *pChildTemp = child;
|
||||
child = child->mNext;
|
||||
|
||||
_buildItem( pChildTemp, tabLevel + 1, bForceFullUpdate );
|
||||
if (!mItemFilterExceptionList.contains(item->mId) && !mDoFilterChildren && !item->isFiltered())
|
||||
_buildItem( pChildTemp, tabLevel + 1, bForceFullUpdate, true );
|
||||
else
|
||||
_buildItem(pChildTemp, tabLevel + 1, bForceFullUpdate, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4775,6 +4786,18 @@ void GuiTreeViewCtrl::setFilterText( const String& text )
|
|||
mFlags.set( RebuildVisible );
|
||||
}
|
||||
|
||||
void GuiTreeViewCtrl::setItemFilterException(U32 item, bool isExempted)
|
||||
{
|
||||
if (isExempted)
|
||||
{
|
||||
mItemFilterExceptionList.push_back(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
mItemFilterExceptionList.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Console Methods.
|
||||
//=============================================================================
|
||||
|
|
@ -5574,6 +5597,25 @@ DefineEngineMethod( GuiTreeViewCtrl, setFilterText, void, ( const char* pattern
|
|||
object->setFilterText( pattern );
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiTreeViewCtrl, setFilterChildren, void, (bool doFilterChildren), (true),
|
||||
"Set the pattern by which to filter items in the tree. Only items in the tree whose text "
|
||||
"matches this pattern are displayed.\n\n"
|
||||
"@param pattern New pattern based on which visible items in the tree should be filtered. If empty, all items become visible.\n\n"
|
||||
"@see getFilterText\n"
|
||||
"@see clearFilterText")
|
||||
{
|
||||
object->setFilterChildren(doFilterChildren);
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiTreeViewCtrl, setItemFilterException, void, (U32 item, bool isExempt), (0, true),
|
||||
"Set the pattern by which to filter items in the tree. Only items in the tree whose text "
|
||||
"matches this pattern are displayed.\n\n"
|
||||
"@param pattern New pattern based on which visible items in the tree should be filtered. If empty, all items become visible.\n\n"
|
||||
"@see getFilterText\n"
|
||||
"@see clearFilterText")
|
||||
{
|
||||
object->setItemFilterException(item, isExempt);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineMethod( GuiTreeViewCtrl, clearFilterText, void, (),,
|
||||
|
|
|
|||
|
|
@ -356,6 +356,11 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
|
|||
/// Current filter that determines which items in the tree are displayed and which are hidden.
|
||||
String mFilterText;
|
||||
|
||||
/// If true, all items are filtered. If false, then children of items that successfully pass filter are not filtered
|
||||
bool mDoFilterChildren;
|
||||
|
||||
Vector<U32> mItemFilterExceptionList;
|
||||
|
||||
/// If true, a trace of actions taken by the control is logged to the console. Can
|
||||
/// be turned on with the setDebug() script method.
|
||||
bool mDebug;
|
||||
|
|
@ -431,7 +436,7 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
|
|||
|
||||
void _deleteItem(Item* item);
|
||||
|
||||
void _buildItem(Item* item, U32 tabLevel, bool bForceFullUpdate = false);
|
||||
void _buildItem(Item* item, U32 tabLevel, bool bForceFullUpdate = false, bool skipFlter = false);
|
||||
|
||||
Item* _findItemByAmbiguousId( S32 itemOrObjectId, bool buildVirtual = true );
|
||||
|
||||
|
|
@ -569,6 +574,9 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
|
|||
/// matches this pattern are displayed.
|
||||
void setFilterText( const String& text );
|
||||
|
||||
void setFilterChildren(bool doFilter) { mDoFilterChildren = doFilter; }
|
||||
void setItemFilterException(U32 item, bool isExempt);
|
||||
|
||||
/// Clear the current item filtering pattern.
|
||||
void clearFilterText() { setFilterText( String::EmptyString ); }
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ struct GFXStateBlockDesc;
|
|||
class GFXVertexFormat;
|
||||
class MatrixSet;
|
||||
class ProcessedMaterial;
|
||||
class GuiTreeViewCtrl;
|
||||
|
||||
///
|
||||
class BaseMatInstance
|
||||
|
|
@ -225,6 +226,7 @@ public:
|
|||
virtual const GFXVertexFormat* getVertexFormat() const = 0;
|
||||
|
||||
virtual void dumpShaderInfo() const = 0;
|
||||
virtual void getShaderInfo(GuiTreeViewCtrl* tree, U32 item) const = 0;
|
||||
|
||||
/// Fast test for use of normal maps in this material.
|
||||
bool hasNormalMap() const { return mHasNormalMaps; }
|
||||
|
|
|
|||
|
|
@ -77,6 +77,14 @@ public:
|
|||
}
|
||||
Point4F getFloat4() { return mFloat4; }
|
||||
|
||||
void setTexture2D(StringTableEntry shaderConstName, GFXTexHandle f)
|
||||
{
|
||||
targetedUniformName = shaderConstName;
|
||||
texture = f;
|
||||
type = Texture2D;
|
||||
}
|
||||
GFXTexHandle getTexture2D() { return texture; }
|
||||
|
||||
StringTableEntry getHandleName() {
|
||||
return targetedUniformName;
|
||||
}
|
||||
|
|
@ -86,4 +94,4 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@
|
|||
#include "core/util/safeDelete.h"
|
||||
#include "ts/tsShape.h"
|
||||
|
||||
#include "gui/controls/guiTreeViewCtrl.h"
|
||||
|
||||
class MatInstParameters;
|
||||
|
||||
class MatInstanceParameterHandle : public MaterialParameterHandle
|
||||
|
|
@ -598,3 +600,35 @@ void MatInstance::dumpShaderInfo() const
|
|||
|
||||
mProcessedMaterial->dumpMaterialInfo();
|
||||
}
|
||||
|
||||
void MatInstance::getShaderInfo(GuiTreeViewCtrl* tree, U32 item) const
|
||||
{
|
||||
if (mMaterial == NULL)
|
||||
{
|
||||
Con::errorf("Trying to get Material information on an invalid MatInstance");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mProcessedMaterial == NULL)
|
||||
{
|
||||
Con::printf(" [no processed material!]");
|
||||
return;
|
||||
}
|
||||
|
||||
const FeatureSet features = mProcessedMaterial->getFeatures();
|
||||
|
||||
String featureDesc = "";
|
||||
for (U32 i = 0; i < features.getCount(); i++)
|
||||
{
|
||||
const FeatureType& ft = features.getAt(i);
|
||||
|
||||
featureDesc += ft.getName();
|
||||
|
||||
if(i+1 < features.getCount())
|
||||
featureDesc += ", ";
|
||||
}
|
||||
|
||||
U32 newItem = tree->insertItem(item, featureDesc);
|
||||
|
||||
mProcessedMaterial->getMaterialInfo(tree, newItem);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ShaderFeature;
|
|||
class MatInstanceParameterHandle;
|
||||
class MatInstParameters;
|
||||
class ProcessedMaterial;
|
||||
|
||||
class GuiTreeViewCtrl;
|
||||
|
||||
///
|
||||
class MatInstance : public BaseMatInstance
|
||||
|
|
@ -87,6 +87,7 @@ public:
|
|||
virtual const FeatureSet& getFeatures() const;
|
||||
virtual const FeatureSet& getRequestedFeatures() const { return mFeatureList; }
|
||||
virtual void dumpShaderInfo() const;
|
||||
virtual void getShaderInfo(GuiTreeViewCtrl* tree, U32 item) const;
|
||||
|
||||
|
||||
ProcessedMaterial *getProcessedMaterial() const { return mProcessedMaterial; }
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "sfx/sfxTypes.h"
|
||||
#include "core/util/safeDelete.h"
|
||||
#include "T3D/accumulationVolume.h"
|
||||
|
||||
#include "gui/controls/guiTreeViewCtrl.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT( Material );
|
||||
|
||||
|
|
@ -709,6 +709,12 @@ DefineEngineMethod( Material, dumpInstances, void, (),,
|
|||
MATMGR->dumpMaterialInstances( object );
|
||||
}
|
||||
|
||||
DefineEngineMethod(Material, getMaterialInstances, void, (GuiTreeViewCtrl* matTree), (nullAsType< GuiTreeViewCtrl*>()),
|
||||
"Dumps a formatted list of the currently allocated material instances for this material to the console.")
|
||||
{
|
||||
MATMGR->getMaterialInstances(object, matTree);
|
||||
}
|
||||
|
||||
DefineEngineMethod( Material, getAnimFlags, const char*, (U32 id), , "" )
|
||||
{
|
||||
char * animFlags = Con::getReturnBuffer(512);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#include "gui/controls/guiTreeViewCtrl.h"
|
||||
|
||||
MODULE_BEGIN( MaterialManager )
|
||||
|
||||
|
|
@ -397,6 +398,36 @@ void MaterialManager::dumpMaterialInstances( BaseMaterialDefinition *target ) co
|
|||
Con::printf( "---------------------- Dump complete ----------------------");
|
||||
}
|
||||
|
||||
void MaterialManager::getMaterialInstances(BaseMaterialDefinition* target, GuiTreeViewCtrl* materailInstanceTree)
|
||||
{
|
||||
if (!mMatInstanceList.size())
|
||||
return;
|
||||
|
||||
if (!target)
|
||||
{
|
||||
Con::errorf("Can't form a list without a specific MaterialDefinition");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!materailInstanceTree)
|
||||
{
|
||||
Con::errorf("Requires a valid GuiTreeViewCtrl object to populate data into!");
|
||||
return;
|
||||
}
|
||||
|
||||
U32 matItem = materailInstanceTree->insertItem(0, target->getName());
|
||||
|
||||
for (U32 i = 0; i < mMatInstanceList.size(); i++)
|
||||
{
|
||||
BaseMatInstance* inst = mMatInstanceList[i];
|
||||
|
||||
if (target && inst->getMaterial() != target)
|
||||
continue;
|
||||
|
||||
inst->getShaderInfo(materailInstanceTree, matItem);
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialManager::_track( MatInstance *matInstance )
|
||||
{
|
||||
mMatInstanceList.push_back( matInstance );
|
||||
|
|
@ -480,6 +511,16 @@ DefineEngineFunction( dumpMaterialInstances, void, (), ,
|
|||
MATMGR->dumpMaterialInstances();
|
||||
}
|
||||
|
||||
DefineEngineFunction(getMaterialInstances, void, (BaseMaterialDefinition* target, GuiTreeViewCtrl* tree), (nullAsType<BaseMaterialDefinition*>(), nullAsType<GuiTreeViewCtrl*>()),
|
||||
"@brief Dumps a formatted list of currently allocated material instances to the console.\n\n"
|
||||
"@ingroup Materials")
|
||||
{
|
||||
if (target == nullptr || tree == nullptr)
|
||||
return;
|
||||
|
||||
MATMGR->getMaterialInstances(target, tree);
|
||||
}
|
||||
|
||||
DefineEngineFunction( getMapEntry, const char*, (const char * texName), ,
|
||||
"@hide")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
class SimSet;
|
||||
class MatInstance;
|
||||
class GuiTreeViewCtrl;
|
||||
|
||||
class MaterialManager : public ManagedSingleton<MaterialManager>
|
||||
{
|
||||
|
|
@ -97,6 +98,8 @@ public:
|
|||
|
||||
void dumpMaterialInstances( BaseMaterialDefinition *target = NULL ) const;
|
||||
|
||||
void getMaterialInstances(BaseMaterialDefinition* target, GuiTreeViewCtrl* tree);
|
||||
|
||||
void updateTime();
|
||||
F32 getTotalTime() const { return mAccumTime; }
|
||||
F32 getDeltaTime() const { return mDt; }
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class SceneRenderState;
|
|||
class GFXVertexBufferHandleBase;
|
||||
class GFXPrimitiveBufferHandle;
|
||||
class MatrixSet;
|
||||
class GuiTreeViewCtrl;
|
||||
|
||||
/// This contains the common data needed to render a pass.
|
||||
struct RenderPassData
|
||||
|
|
@ -226,6 +227,8 @@ public:
|
|||
/// Dump shader info, or FF texture info?
|
||||
virtual void dumpMaterialInfo() { }
|
||||
|
||||
virtual void getMaterialInfo(GuiTreeViewCtrl* tree, U32 item) {}
|
||||
|
||||
/// Returns the source material.
|
||||
Material* getMaterial() const { return mMaterial; }
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
// We need to include customMaterialDefinition for ShaderConstHandles::init
|
||||
#include "materials/customMaterialDefinition.h"
|
||||
|
||||
|
||||
#include "gui/controls/guiTreeViewCtrl.h"
|
||||
#include "ts/tsShape.h"
|
||||
|
||||
///
|
||||
|
|
@ -1534,3 +1534,26 @@ void ProcessedShaderMaterial::dumpMaterialInfo()
|
|||
Con::printf( " [%i] %s", i, shader->describeSelf().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessedShaderMaterial::getMaterialInfo(GuiTreeViewCtrl* tree, U32 item)
|
||||
{
|
||||
for (U32 i = 0; i < getNumPasses(); i++)
|
||||
{
|
||||
const ShaderRenderPassData* passData = _getRPD(i);
|
||||
|
||||
if (passData == NULL)
|
||||
continue;
|
||||
|
||||
char passStr[64];
|
||||
dSprintf(passStr, 64, "Pass Number: %i", i);
|
||||
|
||||
U32 passItem = tree->insertItem(item, passStr);
|
||||
|
||||
const GFXShader * shader = passData->shader;
|
||||
|
||||
if (shader == NULL)
|
||||
tree->insertItem(passItem, "[NULL shader]");
|
||||
else
|
||||
tree->insertItem(passItem, shader->describeSelf().c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ public:
|
|||
virtual void setBuffers(GFXVertexBufferHandleBase* vertBuffer, GFXPrimitiveBufferHandle* primBuffer);
|
||||
virtual bool stepInstance();
|
||||
virtual void dumpMaterialInfo();
|
||||
virtual void getMaterialInfo(GuiTreeViewCtrl* tree, U32 item);
|
||||
virtual MaterialParameters* allocMaterialParameters();
|
||||
virtual MaterialParameters* getDefaultMaterialParameters() { return mDefaultParameters; }
|
||||
virtual MaterialParameterHandle* getMaterialParameterHandle(const String& name);
|
||||
|
|
|
|||
|
|
@ -424,12 +424,11 @@ void RenderDeferredMgr::render( SceneRenderState *state )
|
|||
mat->setNodeTransforms(passRI->mNodeTransforms, passRI->mNodeTransformCount);
|
||||
}
|
||||
|
||||
//-JR
|
||||
//push along any overriden fields that are instance-specific as well
|
||||
if (passRI->mCustomShaderData.size() > 0)
|
||||
{
|
||||
mat->setCustomShaderData(passRI->mCustomShaderData);
|
||||
}
|
||||
//push along any overriden fields that are instance-specific as well
|
||||
if (passRI->mCustomShaderData.size() > 0)
|
||||
{
|
||||
mat->setCustomShaderData(passRI->mCustomShaderData);
|
||||
}
|
||||
|
||||
// If we're instanced then don't render yet.
|
||||
if ( mat->isInstanced() )
|
||||
|
|
|
|||
350
Engine/source/shaderGen/GLSL/customFeatureGLSL.cpp
Normal file
350
Engine/source/shaderGen/GLSL/customFeatureGLSL.cpp
Normal file
|
|
@ -0,0 +1,350 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "customFeatureGLSL.h"
|
||||
#include "shaderGen/shaderFeature.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
#include "shaderGen/featureMgr.h"
|
||||
//#include "materials/materialFeatureTypes.h"
|
||||
//#include "gfx/gfxDevice.h"
|
||||
//#include "materials/processedMaterial.h"
|
||||
|
||||
//****************************************************************************
|
||||
// Accu Texture
|
||||
//****************************************************************************
|
||||
void CustomFeatureGLSL::processVert(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd)
|
||||
{
|
||||
meta = new MultiLine;
|
||||
|
||||
mFeatureData = fd;
|
||||
mComponentList = componentList;
|
||||
|
||||
mOutputState = VertexOutput;
|
||||
|
||||
if (mOwner->isMethod("processVertGLSL"))
|
||||
Con::executef(mOwner, "processVertGLSL");
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd)
|
||||
{
|
||||
meta = new MultiLine;
|
||||
|
||||
mFeatureData = fd;
|
||||
mComponentList = componentList;
|
||||
|
||||
mOutputState = PixelOutput;
|
||||
|
||||
if (mOwner->isMethod("processPixelGLSL"))
|
||||
Con::executef(mOwner, "processPixelGLSL");
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::setTexData(Material::StageData& stageDat,
|
||||
const MaterialFeatureData& fd,
|
||||
RenderPassData& passData,
|
||||
U32& texIndex)
|
||||
{
|
||||
|
||||
if (mOwner->isMethod("setTextureData"))
|
||||
Con::executef(mOwner, "setTextureData");
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::addUniform(String name, String type, String defaultValue, U32 arraySize)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Var* newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
VarHolder newVarHolder(name, type, "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.sampler = false;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constSortPos = cspPotentialPrimitive;
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::addSampler(String name, String type, U32 arraySize)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Var* newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//As far as I know, it's always SamplerState regardless of the texture's type
|
||||
VarHolder newVarHolder(name, "SamplerState", "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.sampler = true;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::addTexture(String name, String type, String samplerState, U32 arraySize)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Var* newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//go find our sampler state var
|
||||
U32 constNum = 0;
|
||||
|
||||
Var* samplerStateVar = (Var*)LangElement::find(samplerState.c_str());
|
||||
if (!samplerStateVar)
|
||||
{
|
||||
//check our holder vars
|
||||
bool foundHolder = false;
|
||||
for (U32 v = 0; v < mVars.size(); v++)
|
||||
{
|
||||
if (mVars[v].varName == samplerState)
|
||||
{
|
||||
constNum = mVars[v].constNum;
|
||||
foundHolder = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundHolder)
|
||||
{
|
||||
Con::errorf("CustomShaderFeature::addTexture: Unable to find texture's sampler state!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
constNum = samplerStateVar->constNum;
|
||||
}
|
||||
|
||||
VarHolder newVarHolder(name, type, "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.texture = true;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constNum = constNum; // used as texture unit num here
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::addVariable(String name, String type, String defaultValue)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Var* newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
if (!defaultValue.isEmpty())
|
||||
{
|
||||
char declareStatement[128];
|
||||
dSprintf(declareStatement, 128, " @ = %s;\n", defaultValue.c_str());
|
||||
|
||||
newVar = new Var(name, type);
|
||||
LangElement* newVarDecl = new DecOp(newVar);
|
||||
meta->addStatement(new GenOp(declareStatement, newVarDecl));
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder newVarHolder(name, type, defaultValue);
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::addConnector(String name, String type, String elementName)
|
||||
{
|
||||
// grab connector texcoord register
|
||||
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(mComponentList[C_CONNECTOR]);
|
||||
|
||||
//Get element
|
||||
S32 element = -1;
|
||||
|
||||
if (elementName == String("RT_POSITION"))
|
||||
element = RT_POSITION;
|
||||
else if (elementName == String("RT_NORMAL"))
|
||||
element = RT_NORMAL;
|
||||
else if (elementName == String("RT_BINORMAL"))
|
||||
element = RT_BINORMAL;
|
||||
else if (elementName == String("RT_TANGENT"))
|
||||
element = RT_TANGENT;
|
||||
else if (elementName == String("RT_TANGENTW"))
|
||||
element = RT_TANGENTW;
|
||||
else if (elementName == String("RT_COLOR"))
|
||||
element = RT_COLOR;
|
||||
else if (elementName == String("RT_TEXCOORD"))
|
||||
element = RT_TEXCOORD;
|
||||
else if (elementName == String("RT_VPOS"))
|
||||
element = RT_VPOS;
|
||||
else if (elementName == String("RT_SVPOSITION"))
|
||||
element = RT_SVPOSITION;
|
||||
else if (elementName == String("RT_BLENDINDICES"))
|
||||
element = RT_BLENDINDICES;
|
||||
else if (elementName == String("RT_BLENDWEIGHT"))
|
||||
element = RT_BLENDWEIGHT;
|
||||
|
||||
if (element == -1)
|
||||
{
|
||||
Con::errorf("CustomShaderFeatureHLSL::addConnector - Invalid element type %s", elementName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
VarHolder newVarHolder(name, type, "");
|
||||
|
||||
newVarHolder.elementId = element;
|
||||
|
||||
if (mOutputState == VertexOutput)
|
||||
newVarHolder.structName = "OUT";
|
||||
else if (mOutputState == PixelOutput)
|
||||
newVarHolder.structName = "IN";
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::addVertTexCoord(String name)
|
||||
{
|
||||
VarHolder newVarHolder(name, "", "");
|
||||
newVarHolder.texCoord = true;
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValueRef * argv)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Vector<Var*> varList;
|
||||
bool declarationStatement = false;
|
||||
|
||||
for (U32 i = 0; i < argc; i++)
|
||||
{
|
||||
String varName = argv[i].getStringValue();
|
||||
Var* newVar = (Var*)LangElement::find(varName.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//ok, check our existing var holders, see if we just haven't utilized it yet
|
||||
for (U32 v = 0; v < mVars.size(); v++)
|
||||
{
|
||||
if (mVars[v].varName == varName)
|
||||
{
|
||||
if (!mVars[v].texCoord)
|
||||
{
|
||||
if (mVars[v].elementId != -1)
|
||||
{
|
||||
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(mComponentList[C_CONNECTOR]);
|
||||
Var* newDeclVar = connectComp->getElement((RegisterType)mVars[v].elementId);
|
||||
newDeclVar->setName(mVars[v].varName);
|
||||
newDeclVar->setStructName(mVars[v].structName);
|
||||
newDeclVar->setType(mVars[v].type);
|
||||
|
||||
newVar = newDeclVar;
|
||||
}
|
||||
else
|
||||
{
|
||||
Var* newDeclVar = new Var(mVars[v].varName, mVars[v].type);
|
||||
|
||||
newDeclVar->arraySize = mVars[v].arraySize;
|
||||
newDeclVar->uniform = mVars[v].uniform;
|
||||
newDeclVar->sampler = mVars[v].sampler;
|
||||
newDeclVar->texture = mVars[v].texture;
|
||||
newDeclVar->constNum = mVars[v].constNum;
|
||||
newDeclVar->constSortPos = mVars[v].constSortPos;
|
||||
|
||||
if (!newDeclVar->uniform)
|
||||
{
|
||||
LangElement* newVarDecl = new DecOp(newDeclVar);
|
||||
newVar = (Var*)newVarDecl;
|
||||
|
||||
declarationStatement = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newVar = newDeclVar;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newVar = getVertTexCoord(mVars[v].varName);
|
||||
}
|
||||
|
||||
mVars.erase(v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!newVar)
|
||||
{
|
||||
//couldn't find that variable, bail out
|
||||
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
varList.push_back(newVar);
|
||||
}
|
||||
|
||||
//not happy about it, but do a trampoline here to pass along the args
|
||||
|
||||
switch (varList.size())
|
||||
{
|
||||
case 0:
|
||||
meta->addStatement(new GenOp(format + "\n"));
|
||||
break;
|
||||
case 1:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0]));
|
||||
break;
|
||||
case 2:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1]));
|
||||
break;
|
||||
case 3:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2]));
|
||||
break;
|
||||
case 4:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3]));
|
||||
break;
|
||||
case 5:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3], varList[4]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomFeatureGLSL::hasFeature(String name)
|
||||
{
|
||||
for (U32 i = 0; i < mFeatureData.materialFeatures.getCount(); i++)
|
||||
{
|
||||
String featureName = mFeatureData.materialFeatures.getAt(i).getName();
|
||||
if (name == featureName)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
132
Engine/source/shaderGen/GLSL/customFeatureGLSL.h
Normal file
132
Engine/source/shaderGen/GLSL/customFeatureGLSL.h
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
#ifndef _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_
|
||||
#include "shaderGen/GLSL/shaderFeatureGLSL.h"
|
||||
#endif
|
||||
#ifndef _LANG_ELEMENT_H_
|
||||
#include "shaderGen/langElement.h"
|
||||
#endif
|
||||
#ifndef _GFXDEVICE_H_
|
||||
#include "gfx/gfxDevice.h"
|
||||
#endif
|
||||
#ifndef _FEATUREMGR_H_
|
||||
#include "shaderGen/featureMgr.h"
|
||||
#endif
|
||||
#ifndef _MATERIALFEATURETYPES_H_
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#endif
|
||||
#ifndef _MATERIALFEATUREDATA_H_
|
||||
#include "materials/materialFeatureData.h"
|
||||
#endif
|
||||
|
||||
#ifndef CUSTOMSHADERFEATURE_H
|
||||
#include "shaderGen/customShaderFeature.h"
|
||||
#endif
|
||||
|
||||
class CustomShaderFeatureData;
|
||||
|
||||
class CustomFeatureGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
friend class CustomShaderFeatureData;
|
||||
|
||||
struct VarHolder
|
||||
{
|
||||
String varName;
|
||||
String type;
|
||||
String defaultValue;
|
||||
S32 elementId;
|
||||
bool uniform;
|
||||
bool sampler;
|
||||
bool texture;
|
||||
bool texCoord;
|
||||
U32 constNum;
|
||||
U32 arraySize;
|
||||
String structName;
|
||||
ConstantSortPosition constSortPos;
|
||||
|
||||
VarHolder() :
|
||||
varName(""),
|
||||
type(""),
|
||||
defaultValue(""),
|
||||
elementId(-1),
|
||||
uniform(false),
|
||||
sampler(false),
|
||||
texture(false),
|
||||
texCoord(false),
|
||||
constNum(0),
|
||||
arraySize(0),
|
||||
structName(""),
|
||||
constSortPos(cspUninit)
|
||||
{
|
||||
}
|
||||
|
||||
VarHolder(String _varName, String _type, String _defaultValue) :
|
||||
elementId(-1), uniform(false), sampler(false), texture(false), texCoord(false), constNum(0), arraySize(0), structName(""), constSortPos(cspUninit)
|
||||
{
|
||||
varName = _varName;
|
||||
type = _type;
|
||||
defaultValue = _defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
Vector<VarHolder> mVars;
|
||||
|
||||
Vector<VarHolder> mConnectorVars;
|
||||
|
||||
enum outputState
|
||||
{
|
||||
NoOutput,
|
||||
VertexOutput,
|
||||
PixelOutput
|
||||
};
|
||||
|
||||
outputState mOutputState;
|
||||
|
||||
public:
|
||||
CustomShaderFeatureData* mOwner;
|
||||
|
||||
Vector<ShaderComponent*> mComponentList;
|
||||
MaterialFeatureData mFeatureData;
|
||||
|
||||
protected:
|
||||
MultiLine* meta;
|
||||
|
||||
public:
|
||||
|
||||
//****************************************************************************
|
||||
// Accu Texture
|
||||
//****************************************************************************
|
||||
virtual void processVert(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd);
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd);
|
||||
|
||||
virtual Material::BlendOp getBlendOp() { return Material::LerpAlpha; }
|
||||
|
||||
virtual Resources getResources(const MaterialFeatureData& fd)
|
||||
{
|
||||
Resources res;
|
||||
res.numTex = 1;
|
||||
res.numTexReg = 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
virtual void setTexData(Material::StageData& stageDat,
|
||||
const MaterialFeatureData& fd,
|
||||
RenderPassData& passData,
|
||||
U32& texIndex);
|
||||
|
||||
virtual String getName()
|
||||
{
|
||||
return mOwner->getName();
|
||||
}
|
||||
|
||||
bool hasFeature(String name);
|
||||
|
||||
void addUniform(String name, String type, String defaultValue, U32 arraySize = 0);
|
||||
void addVariable(String name, String type, String defaultValue);
|
||||
void addSampler(String name, String type, U32 arraySize = 0);
|
||||
void addTexture(String name, String type, String samplerState, U32 arraySize);
|
||||
void addConnector(String name, String type, String elementName);
|
||||
void addVertTexCoord(String name);
|
||||
void writeLine(String format, S32 argc, ConsoleValueRef* argv);
|
||||
};
|
||||
|
|
@ -31,438 +31,467 @@
|
|||
//****************************************************************************
|
||||
// Accu Texture
|
||||
//****************************************************************************
|
||||
void CustomFeatureHLSL::processVert(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
void CustomFeatureHLSL::processVert(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd)
|
||||
{
|
||||
/*MultiLine *meta = new MultiLine;
|
||||
getOutTexCoord( "texCoord",
|
||||
"float2",
|
||||
false,
|
||||
meta,
|
||||
componentList );
|
||||
/*MultiLine *meta = new MultiLine;
|
||||
getOutTexCoord( "texCoord",
|
||||
"float2",
|
||||
false,
|
||||
meta,
|
||||
componentList );
|
||||
|
||||
getOutObjToTangentSpace( componentList, meta, fd );
|
||||
getOutObjToTangentSpace( componentList, meta, fd );
|
||||
|
||||
output = meta;*/
|
||||
output = meta;*/
|
||||
|
||||
meta = new MultiLine;
|
||||
meta = new MultiLine;
|
||||
|
||||
mFeatureData = fd;
|
||||
mComponentList = componentList;
|
||||
mFeatureData = fd;
|
||||
mComponentList = componentList;
|
||||
|
||||
mOutputState = VertexOutput;
|
||||
mOutputState = VertexOutput;
|
||||
|
||||
if (mOwner->isMethod("processVertHLSL"))
|
||||
Con::executef(mOwner, "processVertHLSL");
|
||||
if (mOwner->isMethod("processVertHLSL"))
|
||||
Con::executef(mOwner, "processVertHLSL");
|
||||
|
||||
output = meta;
|
||||
output = meta;
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
void CustomFeatureHLSL::processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd)
|
||||
{
|
||||
meta = new MultiLine;
|
||||
meta = new MultiLine;
|
||||
|
||||
mFeatureData = fd;
|
||||
mComponentList = componentList;
|
||||
mFeatureData = fd;
|
||||
mComponentList = componentList;
|
||||
|
||||
mOutputState = PixelOutput;
|
||||
|
||||
/*MultiLine *meta = new MultiLine;
|
||||
mOutputState = PixelOutput;
|
||||
|
||||
output = meta;
|
||||
/*MultiLine *meta = new MultiLine;
|
||||
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
return;
|
||||
}
|
||||
output = meta;
|
||||
|
||||
// accu map
|
||||
Var *accuMap = new Var;
|
||||
accuMap->setType("SamplerState");
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
return;
|
||||
}
|
||||
|
||||
accuMap->setName( "accuMap" );
|
||||
accuMap->uniform = true;
|
||||
accuMap->sampler = true;
|
||||
accuMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
// accu map
|
||||
Var *accuMap = new Var;
|
||||
accuMap->setType("SamplerState");
|
||||
|
||||
// accuColor var
|
||||
Var *accuColor = new Var;
|
||||
accuColor->setType( "float4" );
|
||||
accuColor->setName( "accuColor" );
|
||||
LangElement *colorAccuDecl = new DecOp( accuColor );
|
||||
accuMap->setName( "accuMap" );
|
||||
accuMap->uniform = true;
|
||||
accuMap->sampler = true;
|
||||
accuMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
// plc (placement)
|
||||
Var *accuPlc = new Var;
|
||||
accuPlc->setType( "float4" );
|
||||
accuPlc->setName( "plc" );
|
||||
LangElement *plcAccu = new DecOp( accuPlc );
|
||||
// accuColor var
|
||||
Var *accuColor = new Var;
|
||||
accuColor->setType( "float4" );
|
||||
accuColor->setName( "accuColor" );
|
||||
LangElement *colorAccuDecl = new DecOp( accuColor );
|
||||
|
||||
// accu constants
|
||||
Var *accuScale = (Var*)LangElement::find( "accuScale" );
|
||||
if ( !accuScale )
|
||||
{
|
||||
accuScale = new Var;
|
||||
accuScale->setType( "float" );
|
||||
accuScale->setName( "accuScale" );
|
||||
accuScale->uniform = true;
|
||||
accuScale->sampler = false;
|
||||
accuScale->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuDirection = (Var*)LangElement::find( "accuDirection" );
|
||||
if ( !accuDirection )
|
||||
{
|
||||
accuDirection = new Var;
|
||||
accuDirection->setType( "float" );
|
||||
accuDirection->setName( "accuDirection" );
|
||||
accuDirection->uniform = true;
|
||||
accuDirection->sampler = false;
|
||||
accuDirection->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuStrength = (Var*)LangElement::find( "accuStrength" );
|
||||
if ( !accuStrength )
|
||||
{
|
||||
accuStrength = new Var;
|
||||
accuStrength->setType( "float" );
|
||||
accuStrength->setName( "accuStrength" );
|
||||
accuStrength->uniform = true;
|
||||
accuStrength->sampler = false;
|
||||
accuStrength->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuCoverage = (Var*)LangElement::find( "accuCoverage" );
|
||||
if ( !accuCoverage )
|
||||
{
|
||||
accuCoverage = new Var;
|
||||
accuCoverage->setType( "float" );
|
||||
accuCoverage->setName( "accuCoverage" );
|
||||
accuCoverage->uniform = true;
|
||||
accuCoverage->sampler = false;
|
||||
accuCoverage->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuSpecular = (Var*)LangElement::find( "accuSpecular" );
|
||||
if ( !accuSpecular )
|
||||
{
|
||||
accuSpecular = new Var;
|
||||
accuSpecular->setType( "float" );
|
||||
accuSpecular->setName( "accuSpecular" );
|
||||
accuSpecular->uniform = true;
|
||||
accuSpecular->sampler = false;
|
||||
accuSpecular->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
// plc (placement)
|
||||
Var *accuPlc = new Var;
|
||||
accuPlc->setType( "float4" );
|
||||
accuPlc->setName( "plc" );
|
||||
LangElement *plcAccu = new DecOp( accuPlc );
|
||||
|
||||
Var *inTex = getInTexCoord( "texCoord", "float2", componentList );
|
||||
Var *accuVec = getInTexCoord( "accuVec", "float3", componentList );
|
||||
Var *bumpNorm = (Var *)LangElement::find( "bumpSample" );
|
||||
if( bumpNorm == NULL )
|
||||
{
|
||||
bumpNorm = (Var *)LangElement::find( "bumpNormal" );
|
||||
if (!bumpNorm)
|
||||
return;
|
||||
}
|
||||
// accu constants
|
||||
Var *accuScale = (Var*)LangElement::find( "accuScale" );
|
||||
if ( !accuScale )
|
||||
{
|
||||
accuScale = new Var;
|
||||
accuScale->setType( "float" );
|
||||
accuScale->setName( "accuScale" );
|
||||
accuScale->uniform = true;
|
||||
accuScale->sampler = false;
|
||||
accuScale->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuDirection = (Var*)LangElement::find( "accuDirection" );
|
||||
if ( !accuDirection )
|
||||
{
|
||||
accuDirection = new Var;
|
||||
accuDirection->setType( "float" );
|
||||
accuDirection->setName( "accuDirection" );
|
||||
accuDirection->uniform = true;
|
||||
accuDirection->sampler = false;
|
||||
accuDirection->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuStrength = (Var*)LangElement::find( "accuStrength" );
|
||||
if ( !accuStrength )
|
||||
{
|
||||
accuStrength = new Var;
|
||||
accuStrength->setType( "float" );
|
||||
accuStrength->setName( "accuStrength" );
|
||||
accuStrength->uniform = true;
|
||||
accuStrength->sampler = false;
|
||||
accuStrength->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuCoverage = (Var*)LangElement::find( "accuCoverage" );
|
||||
if ( !accuCoverage )
|
||||
{
|
||||
accuCoverage = new Var;
|
||||
accuCoverage->setType( "float" );
|
||||
accuCoverage->setName( "accuCoverage" );
|
||||
accuCoverage->uniform = true;
|
||||
accuCoverage->sampler = false;
|
||||
accuCoverage->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuSpecular = (Var*)LangElement::find( "accuSpecular" );
|
||||
if ( !accuSpecular )
|
||||
{
|
||||
accuSpecular = new Var;
|
||||
accuSpecular->setType( "float" );
|
||||
accuSpecular->setName( "accuSpecular" );
|
||||
accuSpecular->uniform = true;
|
||||
accuSpecular->sampler = false;
|
||||
accuSpecular->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
// get the accu pixel color
|
||||
Var *inTex = getInTexCoord( "texCoord", "float2", componentList );
|
||||
Var *accuVec = getInTexCoord( "accuVec", "float3", componentList );
|
||||
Var *bumpNorm = (Var *)LangElement::find( "bumpSample" );
|
||||
if( bumpNorm == NULL )
|
||||
{
|
||||
bumpNorm = (Var *)LangElement::find( "bumpNormal" );
|
||||
if (!bumpNorm)
|
||||
return;
|
||||
}
|
||||
|
||||
Var *accuMapTex = new Var;
|
||||
accuMapTex->setType("Texture2D");
|
||||
accuMapTex->setName("accuMapTex");
|
||||
accuMapTex->uniform = true;
|
||||
accuMapTex->texture = true;
|
||||
accuMapTex->constNum = accuMap->constNum;
|
||||
meta->addStatement(new GenOp(" @ = @.Sample(@, @ * @);\r\n", colorAccuDecl, accuMapTex, accuMap, inTex, accuScale));
|
||||
// get the accu pixel color
|
||||
|
||||
// scale up normals
|
||||
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
|
||||
Var *accuMapTex = new Var;
|
||||
accuMapTex->setType("Texture2D");
|
||||
accuMapTex->setName("accuMapTex");
|
||||
accuMapTex->uniform = true;
|
||||
accuMapTex->texture = true;
|
||||
accuMapTex->constNum = accuMap->constNum;
|
||||
meta->addStatement(new GenOp(" @ = @.Sample(@, @ * @);\r\n", colorAccuDecl, accuMapTex, accuMap, inTex, accuScale));
|
||||
|
||||
// assign direction
|
||||
meta->addStatement( new GenOp( " @.z *= @*2.0;\r\n", accuVec, accuDirection ) );
|
||||
// scale up normals
|
||||
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
|
||||
|
||||
// saturate based on strength
|
||||
meta->addStatement( new GenOp( " @ = saturate( dot( @.xyz, @.xyz * pow(@, 5) ) );\r\n", plcAccu, bumpNorm, accuVec, accuStrength ) );
|
||||
// assign direction
|
||||
meta->addStatement( new GenOp( " @.z *= @*2.0;\r\n", accuVec, accuDirection ) );
|
||||
|
||||
// add coverage
|
||||
meta->addStatement( new GenOp( " @.a += (2 * pow(@/2, 5)) - 0.5;\r\n", accuPlc, accuCoverage ) );
|
||||
// saturate based on strength
|
||||
meta->addStatement( new GenOp( " @ = saturate( dot( @.xyz, @.xyz * pow(@, 5) ) );\r\n", plcAccu, bumpNorm, accuVec, accuStrength ) );
|
||||
|
||||
// clamp to a sensible value
|
||||
meta->addStatement( new GenOp( " @.a = clamp(@.a, 0, 1);\r\n", accuPlc, accuPlc ) );
|
||||
// add coverage
|
||||
meta->addStatement( new GenOp( " @.a += (2 * pow(@/2, 5)) - 0.5;\r\n", accuPlc, accuCoverage ) );
|
||||
|
||||
// light
|
||||
Var *lightColor = (Var*) LangElement::find( "d_lightcolor" );
|
||||
if(lightColor != NULL)
|
||||
meta->addStatement( new GenOp( " @ *= float4(@, 1.0);\r\n\r\n", accuColor, lightColor ) );
|
||||
// clamp to a sensible value
|
||||
meta->addStatement( new GenOp( " @.a = clamp(@.a, 0, 1);\r\n", accuPlc, accuPlc ) );
|
||||
|
||||
// lerp with current pixel - use the accu alpha as well
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @, @.a * @.a);\r\n", color, color, accuColor, accuPlc, accuColor ) );
|
||||
// light
|
||||
Var *lightColor = (Var*) LangElement::find( "d_lightcolor" );
|
||||
if(lightColor != NULL)
|
||||
meta->addStatement( new GenOp( " @ *= float4(@, 1.0);\r\n\r\n", accuColor, lightColor ) );
|
||||
|
||||
// the result should always be opaque
|
||||
meta->addStatement( new GenOp( " @.a = 1.0;\r\n", color ) );*/
|
||||
if (mOwner->isMethod("processPixelHLSL"))
|
||||
Con::executef(mOwner, "processPixelHLSL");
|
||||
// lerp with current pixel - use the accu alpha as well
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @, @.a * @.a);\r\n", color, color, accuColor, accuPlc, accuColor ) );
|
||||
|
||||
output = meta;
|
||||
// the result should always be opaque
|
||||
meta->addStatement( new GenOp( " @.a = 1.0;\r\n", color ) );*/
|
||||
if (mOwner->isMethod("processPixelHLSL"))
|
||||
Con::executef(mOwner, "processPixelHLSL");
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::setTexData(Material::StageData &stageDat,
|
||||
const MaterialFeatureData &fd,
|
||||
RenderPassData &passData,
|
||||
U32 &texIndex)
|
||||
void CustomFeatureHLSL::setTexData(Material::StageData& stageDat,
|
||||
const MaterialFeatureData& fd,
|
||||
RenderPassData& passData,
|
||||
U32& texIndex)
|
||||
{
|
||||
//GFXTextureObject *tex = stageDat.getTex( MFT_AccuMap );
|
||||
//if ( tex )
|
||||
//{
|
||||
//passData.mSamplerNames[ texIndex ] = "AccuMap";
|
||||
//passData.mTexType[ texIndex++ ] = Material::AccuMap;
|
||||
//}
|
||||
//GFXTextureObject *tex = stageDat.getTex( MFT_AccuMap );
|
||||
//if ( tex )
|
||||
//{
|
||||
//passData.mSamplerNames[ texIndex ] = "AccuMap";
|
||||
//passData.mTexType[ texIndex++ ] = Material::AccuMap;
|
||||
//}
|
||||
|
||||
if (mOwner->isMethod("setTextureData"))
|
||||
Con::executef(mOwner, "setTextureData");
|
||||
if (mOwner->isMethod("setTextureData"))
|
||||
Con::executef(mOwner, "setTextureData");
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::addUniform(String name, String type, String defaultValue, U32 arraySize)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Var *newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
VarHolder newVarHolder(name, type, "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.sampler = false;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constSortPos = cspPotentialPrimitive;
|
||||
//do the var/arg fetching here
|
||||
Var* newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
VarHolder newVarHolder(name, type, "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.sampler = false;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constSortPos = cspPotentialPrimitive;
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
mVars.push_back(newVarHolder);
|
||||
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::addSampler(String name, String type, U32 arraySize)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Var *newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//As far as I know, it's always SamplerState regardless of the texture's type
|
||||
VarHolder newVarHolder(name, "SamplerState", "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.sampler = true;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
//do the var/arg fetching here
|
||||
Var* newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//As far as I know, it's always SamplerState regardless of the texture's type
|
||||
VarHolder newVarHolder(name, "SamplerState", "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.sampler = true;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
mVars.push_back(newVarHolder);
|
||||
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::addTexture(String name, String type, String samplerState, U32 arraySize)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Var *newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//go find our sampler state var
|
||||
U32 constNum = 0;
|
||||
//do the var/arg fetching here
|
||||
Var* newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//go find our sampler state var
|
||||
U32 constNum = 0;
|
||||
|
||||
Var *samplerStateVar = (Var*)LangElement::find(samplerState.c_str());
|
||||
if (!samplerStateVar)
|
||||
{
|
||||
//check our holder vars
|
||||
bool foundHolder = false;
|
||||
for (U32 v = 0; v < mVars.size(); v++)
|
||||
{
|
||||
if (mVars[v].varName == samplerState)
|
||||
{
|
||||
constNum = mVars[v].constNum;
|
||||
foundHolder = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Var* samplerStateVar = (Var*)LangElement::find(samplerState.c_str());
|
||||
if (!samplerStateVar)
|
||||
{
|
||||
//check our holder vars
|
||||
bool foundHolder = false;
|
||||
for (U32 v = 0; v < mVars.size(); v++)
|
||||
{
|
||||
if (mVars[v].varName == samplerState)
|
||||
{
|
||||
constNum = mVars[v].constNum;
|
||||
foundHolder = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundHolder)
|
||||
{
|
||||
Con::errorf("CustomShaderFeature::addTexture: Unable to find texture's sampler state!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
constNum = samplerStateVar->constNum;
|
||||
}
|
||||
if (!foundHolder)
|
||||
{
|
||||
Con::errorf("CustomShaderFeature::addTexture: Unable to find texture's sampler state!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
constNum = samplerStateVar->constNum;
|
||||
}
|
||||
|
||||
VarHolder newVarHolder(name, type, "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.texture = true;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constNum = constNum; // used as texture unit num here
|
||||
VarHolder newVarHolder(name, type, "");
|
||||
newVarHolder.arraySize = arraySize;
|
||||
newVarHolder.texture = true;
|
||||
newVarHolder.uniform = true;
|
||||
newVarHolder.constNum = constNum; // used as texture unit num here
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
mVars.push_back(newVarHolder);
|
||||
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::addVariable(String name, String type, String defaultValue)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Var *newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
if (!defaultValue.isEmpty())
|
||||
{
|
||||
char declareStatement[128];
|
||||
dSprintf(declareStatement, 128, " @ = %s;\n", defaultValue.c_str());
|
||||
//do the var/arg fetching here
|
||||
Var* newVar = (Var*)LangElement::find(name.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
if (!defaultValue.isEmpty())
|
||||
{
|
||||
char declareStatement[128];
|
||||
dSprintf(declareStatement, 128, " @ = %s;\n", defaultValue.c_str());
|
||||
|
||||
newVar = new Var(name, type);
|
||||
LangElement *newVarDecl = new DecOp(newVar);
|
||||
meta->addStatement(new GenOp(declareStatement, newVarDecl));
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder newVarHolder(name, type, defaultValue);
|
||||
newVar = new Var(name, type);
|
||||
LangElement* newVarDecl = new DecOp(newVar);
|
||||
meta->addStatement(new GenOp(declareStatement, newVarDecl));
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder newVarHolder(name, type, defaultValue);
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
}
|
||||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::addConnector(String name, String elementName, String type)
|
||||
void CustomFeatureHLSL::addConnector(String name, String type, String elementName)
|
||||
{
|
||||
// grab connector texcoord register
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>(mComponentList[C_CONNECTOR]);
|
||||
// grab connector texcoord register
|
||||
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(mComponentList[C_CONNECTOR]);
|
||||
|
||||
//Get element
|
||||
S32 element = -1;
|
||||
//Get element
|
||||
S32 element = -1;
|
||||
|
||||
if (elementName == String("RT_POSITION"))
|
||||
element = RT_POSITION;
|
||||
else if (elementName == String("RT_NORMAL"))
|
||||
element = RT_NORMAL;
|
||||
else if (elementName == String("RT_BINORMAL"))
|
||||
element = RT_BINORMAL;
|
||||
else if (elementName == String("RT_TANGENT"))
|
||||
element = RT_TANGENT;
|
||||
else if (elementName == String("RT_TANGENTW"))
|
||||
element = RT_TANGENTW;
|
||||
else if (elementName == String("RT_COLOR"))
|
||||
element = RT_COLOR;
|
||||
else if (elementName == String("RT_TEXCOORD"))
|
||||
element = RT_TEXCOORD;
|
||||
else if (elementName == String("RT_VPOS"))
|
||||
element = RT_VPOS;
|
||||
else if (elementName == String("RT_SVPOSITION"))
|
||||
element = RT_SVPOSITION;
|
||||
else if (elementName == String("RT_BLENDINDICES"))
|
||||
element = RT_BLENDINDICES;
|
||||
else if (elementName == String("RT_BLENDWEIGHT"))
|
||||
element = RT_BLENDWEIGHT;
|
||||
if (elementName == String("RT_POSITION"))
|
||||
element = RT_POSITION;
|
||||
else if (elementName == String("RT_NORMAL"))
|
||||
element = RT_NORMAL;
|
||||
else if (elementName == String("RT_BINORMAL"))
|
||||
element = RT_BINORMAL;
|
||||
else if (elementName == String("RT_TANGENT"))
|
||||
element = RT_TANGENT;
|
||||
else if (elementName == String("RT_TANGENTW"))
|
||||
element = RT_TANGENTW;
|
||||
else if (elementName == String("RT_COLOR"))
|
||||
element = RT_COLOR;
|
||||
else if (elementName == String("RT_TEXCOORD"))
|
||||
element = RT_TEXCOORD;
|
||||
else if (elementName == String("RT_VPOS"))
|
||||
element = RT_VPOS;
|
||||
else if (elementName == String("RT_SVPOSITION"))
|
||||
element = RT_SVPOSITION;
|
||||
else if (elementName == String("RT_BLENDINDICES"))
|
||||
element = RT_BLENDINDICES;
|
||||
else if (elementName == String("RT_BLENDWEIGHT"))
|
||||
element = RT_BLENDWEIGHT;
|
||||
|
||||
if (element == -1)
|
||||
{
|
||||
Con::errorf("CustomShaderFeatureHLSL::addConnector - Invalid element type %s", elementName.c_str());
|
||||
return;
|
||||
}
|
||||
if (element == -1)
|
||||
{
|
||||
Con::errorf("CustomShaderFeatureHLSL::addConnector - Invalid element type %s", elementName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Var *connector = connectComp->getElement((RegisterType)element);
|
||||
connector->setName(name);
|
||||
VarHolder newVarHolder(name, type, "");
|
||||
|
||||
if (mOutputState == VertexOutput)
|
||||
connector->setStructName("OUT");
|
||||
else if(mOutputState == PixelOutput)
|
||||
connector->setStructName("IN");
|
||||
newVarHolder.elementId = element;
|
||||
|
||||
connector->setType(type);
|
||||
if (mOutputState == VertexOutput)
|
||||
newVarHolder.structName = "OUT";
|
||||
else if (mOutputState == PixelOutput)
|
||||
newVarHolder.structName = "IN";
|
||||
|
||||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef *argv)
|
||||
void CustomFeatureHLSL::addVertTexCoord(String name)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Vector<Var*> varList;
|
||||
bool declarationStatement = false;
|
||||
VarHolder newVarHolder(name, "", "");
|
||||
newVarHolder.texCoord = true;
|
||||
|
||||
for (U32 i = 0; i < argc; i++)
|
||||
{
|
||||
String varName = argv[i].getStringValue();
|
||||
Var *newVar = (Var*)LangElement::find(varName.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//ok, check our existing var holders, see if we just haven't utilized it yet
|
||||
for (U32 v = 0; v < mVars.size(); v++)
|
||||
{
|
||||
if (mVars[v].varName == varName)
|
||||
{
|
||||
Var* newDeclVar = new Var(mVars[v].varName, mVars[v].type);
|
||||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
|
||||
newDeclVar->arraySize = mVars[v].arraySize;
|
||||
newDeclVar->uniform = mVars[v].uniform;
|
||||
newDeclVar->sampler = mVars[v].sampler;
|
||||
newDeclVar->texture = mVars[v].texture;
|
||||
newDeclVar->constNum = mVars[v].constNum;
|
||||
newDeclVar->constSortPos = mVars[v].constSortPos;
|
||||
void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef * argv)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Vector<Var*> varList;
|
||||
bool declarationStatement = false;
|
||||
|
||||
if (!newDeclVar->uniform)
|
||||
{
|
||||
LangElement *newVarDecl = new DecOp(newDeclVar);
|
||||
newVar = (Var*)newVarDecl;
|
||||
for (U32 i = 0; i < argc; i++)
|
||||
{
|
||||
String varName = argv[i].getStringValue();
|
||||
Var* newVar = (Var*)LangElement::find(varName.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
//ok, check our existing var holders, see if we just haven't utilized it yet
|
||||
for (U32 v = 0; v < mVars.size(); v++)
|
||||
{
|
||||
if (mVars[v].varName == varName)
|
||||
{
|
||||
if (!mVars[v].texCoord)
|
||||
{
|
||||
if (mVars[v].elementId != -1)
|
||||
{
|
||||
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(mComponentList[C_CONNECTOR]);
|
||||
Var* newDeclVar = connectComp->getElement((RegisterType)mVars[v].elementId);
|
||||
newDeclVar->setName(mVars[v].varName);
|
||||
newDeclVar->setStructName(mVars[v].structName);
|
||||
newDeclVar->setType(mVars[v].type);
|
||||
|
||||
declarationStatement = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newVar = newDeclVar;
|
||||
}
|
||||
newVar = newDeclVar;
|
||||
}
|
||||
else
|
||||
{
|
||||
Var* newDeclVar = new Var(mVars[v].varName, mVars[v].type);
|
||||
|
||||
mVars.erase(v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
newDeclVar->arraySize = mVars[v].arraySize;
|
||||
newDeclVar->uniform = mVars[v].uniform;
|
||||
newDeclVar->sampler = mVars[v].sampler;
|
||||
newDeclVar->texture = mVars[v].texture;
|
||||
newDeclVar->constNum = mVars[v].constNum;
|
||||
newDeclVar->constSortPos = mVars[v].constSortPos;
|
||||
|
||||
if (!newVar)
|
||||
{
|
||||
//couldn't find that variable, bail out
|
||||
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!newDeclVar->uniform)
|
||||
{
|
||||
LangElement* newVarDecl = new DecOp(newDeclVar);
|
||||
newVar = (Var*)newVarDecl;
|
||||
|
||||
varList.push_back(newVar);
|
||||
}
|
||||
declarationStatement = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newVar = newDeclVar;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newVar = getVertTexCoord(mVars[v].varName);
|
||||
}
|
||||
|
||||
//not happy about it, but do a trampoline here to pass along the args
|
||||
mVars.erase(v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (varList.size())
|
||||
{
|
||||
case 0:
|
||||
meta->addStatement(new GenOp(format + "\n"));
|
||||
break;
|
||||
case 1:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0]));
|
||||
break;
|
||||
case 2:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1]));
|
||||
break;
|
||||
case 3:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2]));
|
||||
break;
|
||||
case 4:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3]));
|
||||
break;
|
||||
case 5:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3], varList[4]));
|
||||
break;
|
||||
}
|
||||
if (!newVar)
|
||||
{
|
||||
//couldn't find that variable, bail out
|
||||
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
varList.push_back(newVar);
|
||||
}
|
||||
|
||||
//not happy about it, but do a trampoline here to pass along the args
|
||||
|
||||
switch (varList.size())
|
||||
{
|
||||
case 0:
|
||||
meta->addStatement(new GenOp(format + "\n"));
|
||||
break;
|
||||
case 1:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0]));
|
||||
break;
|
||||
case 2:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1]));
|
||||
break;
|
||||
case 3:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2]));
|
||||
break;
|
||||
case 4:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3]));
|
||||
break;
|
||||
case 5:
|
||||
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3], varList[4]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomFeatureHLSL::hasFeature(String name)
|
||||
{
|
||||
for (U32 i = 0; i < mFeatureData.materialFeatures.getCount(); i++)
|
||||
{
|
||||
String featureName = mFeatureData.materialFeatures.getAt(i).getName();
|
||||
if (name == featureName)
|
||||
return true;
|
||||
}
|
||||
for (U32 i = 0; i < mFeatureData.materialFeatures.getCount(); i++)
|
||||
{
|
||||
String featureName = mFeatureData.materialFeatures.getAt(i).getName();
|
||||
if (name == featureName)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,99 +25,108 @@ class CustomShaderFeatureData;
|
|||
|
||||
class CustomFeatureHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
friend class CustomShaderFeatureData;
|
||||
friend class CustomShaderFeatureData;
|
||||
|
||||
struct VarHolder
|
||||
{
|
||||
String varName;
|
||||
String defaultValue;
|
||||
String type;
|
||||
bool uniform;
|
||||
bool sampler;
|
||||
bool texture;
|
||||
U32 constNum;
|
||||
ConstantSortPosition constSortPos;
|
||||
U32 arraySize;
|
||||
struct VarHolder
|
||||
{
|
||||
String varName;
|
||||
String type;
|
||||
String defaultValue;
|
||||
S32 elementId;
|
||||
bool uniform;
|
||||
bool sampler;
|
||||
bool texture;
|
||||
bool texCoord;
|
||||
U32 constNum;
|
||||
U32 arraySize;
|
||||
String structName;
|
||||
ConstantSortPosition constSortPos;
|
||||
|
||||
VarHolder() :
|
||||
varName(""),
|
||||
type(""),
|
||||
defaultValue(""),
|
||||
uniform(false),
|
||||
sampler(false),
|
||||
texture(false),
|
||||
constNum(0),
|
||||
arraySize(0),
|
||||
constSortPos(cspUninit)
|
||||
{
|
||||
}
|
||||
VarHolder() :
|
||||
varName(""),
|
||||
type(""),
|
||||
defaultValue(""),
|
||||
elementId(-1),
|
||||
uniform(false),
|
||||
sampler(false),
|
||||
texture(false),
|
||||
texCoord(false),
|
||||
constNum(0),
|
||||
arraySize(0),
|
||||
structName(""),
|
||||
constSortPos(cspUninit)
|
||||
{
|
||||
}
|
||||
|
||||
VarHolder(String _varName,String _type, String _defaultValue) :
|
||||
uniform(false), sampler(false), texture(false), constNum(0), arraySize(0), constSortPos(cspUninit)
|
||||
{
|
||||
varName = _varName;
|
||||
type = _type;
|
||||
defaultValue = _defaultValue;
|
||||
}
|
||||
};
|
||||
VarHolder(String _varName, String _type, String _defaultValue) :
|
||||
elementId(-1), uniform(false), sampler(false), texture(false), texCoord(false), constNum(0), arraySize(0), structName(""), constSortPos(cspUninit)
|
||||
{
|
||||
varName = _varName;
|
||||
type = _type;
|
||||
defaultValue = _defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
Vector<VarHolder> mVars;
|
||||
Vector<VarHolder> mVars;
|
||||
|
||||
enum outputState
|
||||
{
|
||||
NoOutput,
|
||||
VertexOutput,
|
||||
PixelOutput
|
||||
};
|
||||
Vector<VarHolder> mConnectorVars;
|
||||
|
||||
outputState mOutputState;
|
||||
enum outputState
|
||||
{
|
||||
NoOutput,
|
||||
VertexOutput,
|
||||
PixelOutput
|
||||
};
|
||||
|
||||
outputState mOutputState;
|
||||
|
||||
public:
|
||||
CustomShaderFeatureData* mOwner;
|
||||
CustomShaderFeatureData* mOwner;
|
||||
|
||||
Vector<ShaderComponent*> mComponentList;
|
||||
MaterialFeatureData mFeatureData;
|
||||
Vector<ShaderComponent*> mComponentList;
|
||||
MaterialFeatureData mFeatureData;
|
||||
|
||||
protected:
|
||||
MultiLine *meta;
|
||||
MultiLine* meta;
|
||||
|
||||
public:
|
||||
|
||||
//****************************************************************************
|
||||
// Accu Texture
|
||||
//****************************************************************************
|
||||
virtual void processVert(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
//****************************************************************************
|
||||
// Accu Texture
|
||||
//****************************************************************************
|
||||
virtual void processVert(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd);
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
virtual void processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd);
|
||||
|
||||
virtual Material::BlendOp getBlendOp() { return Material::LerpAlpha; }
|
||||
virtual Material::BlendOp getBlendOp() { return Material::LerpAlpha; }
|
||||
|
||||
virtual Resources getResources(const MaterialFeatureData &fd)
|
||||
{
|
||||
Resources res;
|
||||
res.numTex = 1;
|
||||
res.numTexReg = 1;
|
||||
return res;
|
||||
}
|
||||
virtual Resources getResources(const MaterialFeatureData& fd)
|
||||
{
|
||||
Resources res;
|
||||
res.numTex = 1;
|
||||
res.numTexReg = 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
virtual void setTexData(Material::StageData &stageDat,
|
||||
const MaterialFeatureData &fd,
|
||||
RenderPassData &passData,
|
||||
U32 &texIndex);
|
||||
virtual void setTexData(Material::StageData& stageDat,
|
||||
const MaterialFeatureData& fd,
|
||||
RenderPassData& passData,
|
||||
U32& texIndex);
|
||||
|
||||
virtual String getName()
|
||||
{
|
||||
return mOwner->getName();
|
||||
}
|
||||
virtual String getName()
|
||||
{
|
||||
return mOwner->getName();
|
||||
}
|
||||
|
||||
bool hasFeature(String name);
|
||||
bool hasFeature(String name);
|
||||
|
||||
void addUniform(String name, String type, String defaultValue, U32 arraySize = 0);
|
||||
void addVariable(String name, String type, String defaultValue);
|
||||
void addSampler(String name, String type, U32 arraySize = 0);
|
||||
void addTexture(String name, String type, String samplerState, U32 arraySize);
|
||||
void addConnector(String name, String elementName, String type);
|
||||
void writeLine(String format, S32 argc, ConsoleValueRef *argv);
|
||||
};
|
||||
void addUniform(String name, String type, String defaultValue, U32 arraySize = 0);
|
||||
void addVariable(String name, String type, String defaultValue);
|
||||
void addSampler(String name, String type, U32 arraySize = 0);
|
||||
void addTexture(String name, String type, String samplerState, U32 arraySize);
|
||||
void addConnector(String name, String type, String elementName);
|
||||
void addVertTexCoord(String name);
|
||||
void writeLine(String format, S32 argc, ConsoleValueRef* argv);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "shadergen/CustomShaderFeature.h"
|
||||
#include "shaderGen/HLSL/customFeatureHLSL.h"
|
||||
#include "shaderGen/GLSL/customFeatureGLSL.h"
|
||||
|
||||
#include "math/mathIO.h"
|
||||
#include "scene/sceneRenderState.h"
|
||||
|
|
@ -35,17 +36,17 @@
|
|||
IMPLEMENT_CONOBJECT(CustomShaderFeatureData);
|
||||
|
||||
ConsoleDocClass(CustomShaderFeatureData,
|
||||
"@brief An example scene object which renders using a callback.\n\n"
|
||||
"This class implements a basic SceneObject that can exist in the world at a "
|
||||
"3D position and render itself. Note that CustomShaderFeatureData handles its own "
|
||||
"rendering by submitting itself as an ObjectRenderInst (see "
|
||||
"renderInstance\renderPassmanager.h) along with a delegate for its render() "
|
||||
"function. However, the preffered rendering method in the engine is to submit "
|
||||
"a MeshRenderInst along with a Material, vertex buffer, primitive buffer, and "
|
||||
"transform and allow the RenderMeshMgr handle the actual rendering. You can "
|
||||
"see this implemented in RenderMeshExample.\n\n"
|
||||
"See the C++ code for implementation details.\n\n"
|
||||
"@ingroup Examples\n");
|
||||
"@brief An example scene object which renders using a callback.\n\n"
|
||||
"This class implements a basic SceneObject that can exist in the world at a "
|
||||
"3D position and render itself. Note that CustomShaderFeatureData handles its own "
|
||||
"rendering by submitting itself as an ObjectRenderInst (see "
|
||||
"renderInstance\renderPassmanager.h) along with a delegate for its render() "
|
||||
"function. However, the preffered rendering method in the engine is to submit "
|
||||
"a MeshRenderInst along with a Material, vertex buffer, primitive buffer, and "
|
||||
"transform and allow the RenderMeshMgr handle the actual rendering. You can "
|
||||
"see this implemented in RenderMeshExample.\n\n"
|
||||
"See the C++ code for implementation details.\n\n"
|
||||
"@ingroup Examples\n");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Object setup and teardown
|
||||
|
|
@ -63,128 +64,138 @@ CustomShaderFeatureData::~CustomShaderFeatureData()
|
|||
//-----------------------------------------------------------------------------
|
||||
void CustomShaderFeatureData::initPersistFields()
|
||||
{
|
||||
// SceneObject already handles exposing the transform
|
||||
Parent::initPersistFields();
|
||||
// SceneObject already handles exposing the transform
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
bool CustomShaderFeatureData::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
mFeatureHLSL = new CustomFeatureHLSL();
|
||||
mFeatureHLSL->mOwner = this;
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
{
|
||||
mFeatureHLSL = new CustomFeatureHLSL();
|
||||
mFeatureHLSL->mOwner = this;
|
||||
}
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
{
|
||||
mFeatureGLSL = new CustomFeatureGLSL();
|
||||
mFeatureGLSL->mOwner = this;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::onRemove()
|
||||
{
|
||||
Parent::onRemove();
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
||||
//Shadergen setup functions
|
||||
void CustomShaderFeatureData::addVariable(String name, String type, String defaultValue)
|
||||
{
|
||||
mFeatureHLSL->addVariable(name, type, defaultValue);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
mFeatureHLSL->addVariable(name, type, defaultValue);
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
mFeatureGLSL->addVariable(name, type, defaultValue);
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::addUniform(String name, String type, String defaultValue, U32 arraySize)
|
||||
{
|
||||
mFeatureHLSL->addUniform(name, type, defaultValue, arraySize);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
mFeatureHLSL->addUniform(name, type, defaultValue, arraySize);
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
mFeatureGLSL->addUniform(name, type, defaultValue, arraySize);
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::addSampler(String name, String type, U32 arraySize)
|
||||
{
|
||||
mFeatureHLSL->addSampler(name, type, arraySize);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
mFeatureHLSL->addSampler(name, type, arraySize);
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
mFeatureGLSL->addSampler(name, type, arraySize);
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::addTexture(String name, String type, String samplerState, U32 arraySize)
|
||||
{
|
||||
mFeatureHLSL->addTexture(name, type, samplerState, arraySize);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
mFeatureHLSL->addTexture(name, type, samplerState, arraySize);
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
mFeatureGLSL->addTexture(name, type, samplerState, arraySize);
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::addConnector(String name, String elementName, String type)
|
||||
void CustomShaderFeatureData::addConnector(String name, String type, String elementName)
|
||||
{
|
||||
mFeatureHLSL->addConnector(name, elementName, type);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
mFeatureHLSL->addConnector(name, type, elementName);
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
mFeatureGLSL->addConnector(name, type, elementName);
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::addVertTexCoord(String name)
|
||||
{
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
mFeatureHLSL->addVertTexCoord(name);
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
mFeatureGLSL->addVertTexCoord(name);
|
||||
}
|
||||
|
||||
bool CustomShaderFeatureData::hasFeature(String name)
|
||||
{
|
||||
return mFeatureHLSL->hasFeature(name);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
return mFeatureHLSL->hasFeature(name);
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
return mFeatureGLSL->hasFeature(name);
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValueRef *argv)
|
||||
void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValueRef* argv)
|
||||
{
|
||||
/*mOnObject = onObject;
|
||||
mArgc = argc;
|
||||
|
||||
mArgv = new ConsoleValueRef[argc];
|
||||
for (int i = 0; i<argc; i++)
|
||||
{
|
||||
mArgv[i].value = new ConsoleValue();
|
||||
mArgv[i].value->type = ConsoleValue::TypeInternalString;
|
||||
mArgv[i].value->init();
|
||||
if (argv)
|
||||
{
|
||||
mArgv[i].value->setStringValue((const char*)argv[i]);
|
||||
}
|
||||
}*/
|
||||
|
||||
mFeatureHLSL->writeLine(format, argc, argv);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
mFeatureHLSL->writeLine(format, argc, argv);
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
mFeatureGLSL->writeLine(format, argc, argv);
|
||||
}
|
||||
|
||||
/*//Actual shader processing
|
||||
void CustomShaderFeatureData::processVert(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
DefineEngineMethod(CustomShaderFeatureData, addVariable, void, (String name, String type, String defaultValue), ("", "", ""), "")
|
||||
{
|
||||
mFeatureHLSL.processVert(componentList, fd);
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
mFeatureHLSL.processPix(componentList, fd);
|
||||
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::setTexData(Material::StageData &stageDat,
|
||||
const MaterialFeatureData &fd,
|
||||
RenderPassData &passData,
|
||||
U32 &texIndex)
|
||||
{
|
||||
mFeatureHLSL.setTexData(stageDat, fd, passData, texIndex);
|
||||
}*/
|
||||
|
||||
DefineEngineMethod(CustomShaderFeatureData, addVariable, void, (String name, String type, String defaultValue), ("", "", ""), "")
|
||||
{
|
||||
object->addVariable(name, type, defaultValue);
|
||||
object->addVariable(name, type, defaultValue);
|
||||
}
|
||||
|
||||
DefineEngineMethod(CustomShaderFeatureData, addUniform, void, (String name, String type, String defaultValue, U32 arraySize), ("", "", "", 0), "")
|
||||
{
|
||||
object->addUniform(name, type, defaultValue, arraySize);
|
||||
object->addUniform(name, type, defaultValue, arraySize);
|
||||
}
|
||||
|
||||
DefineEngineMethod(CustomShaderFeatureData, addSampler, void, (String name, U32 arraySize), ("", 0), "")
|
||||
{
|
||||
object->addSampler(name, "", arraySize);
|
||||
object->addSampler(name, "", arraySize);
|
||||
}
|
||||
|
||||
DefineEngineMethod(CustomShaderFeatureData, addTexture, void, (String name, String type, String samplerState, U32 arraySize), ("", "", 0), "")
|
||||
{
|
||||
object->addTexture(name, type, samplerState, arraySize);
|
||||
object->addTexture(name, type, samplerState, arraySize);
|
||||
}
|
||||
|
||||
ConsoleMethod(CustomShaderFeatureData, writeLine, void, 3, 0, "( string format, string args... ) Dynamically call a method on an object.\n"
|
||||
"@param method Name of method to call.\n"
|
||||
"@param args Zero or more arguments for the method.\n"
|
||||
"@return The result of the method call.")
|
||||
DefineEngineMethod(CustomShaderFeatureData, addConnector, void, (String name, String type, String elementName), ("", "", ""), "")
|
||||
{
|
||||
object->writeLine(argv[2], argc - 3, argv + 3);
|
||||
object->addConnector(name, type, elementName);
|
||||
}
|
||||
|
||||
DefineEngineMethod(CustomShaderFeatureData, addVertTexCoord, void, (String name), (""), "")
|
||||
{
|
||||
object->addVertTexCoord(name);
|
||||
}
|
||||
|
||||
DefineEngineStringlyVariadicMethod(CustomShaderFeatureData, writeLine, void, 3, 0, "( string format, string args... ) Dynamically call a method on an object.\n"
|
||||
"@param method Name of method to call.\n"
|
||||
"@param args Zero or more arguments for the method.\n"
|
||||
"@return The result of the method call.")
|
||||
{
|
||||
object->writeLine(argv[2], argc - 3, argv + 3);
|
||||
}
|
||||
|
||||
DefineEngineMethod(CustomShaderFeatureData, hasFeature, bool, (String name), (""), "")
|
||||
{
|
||||
return object->hasFeature(name);
|
||||
}
|
||||
return object->hasFeature(name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#endif
|
||||
|
||||
class CustomFeatureHLSL;
|
||||
class CustomFeatureGLSL;
|
||||
|
||||
class CustomShaderFeatureData : public SimObject
|
||||
{
|
||||
|
|
@ -35,6 +36,7 @@ class CustomShaderFeatureData : public SimObject
|
|||
|
||||
public:
|
||||
CustomFeatureHLSL* mFeatureHLSL;
|
||||
CustomFeatureGLSL* mFeatureGLSL;
|
||||
|
||||
Vector<StringTableEntry> mAddedShaderConstants;
|
||||
|
||||
|
|
@ -64,8 +66,8 @@ public:
|
|||
void addUniform(String name, String type, String defaultValue, U32 arraySize);
|
||||
void addSampler(String name, String type, U32 arraySize);
|
||||
void addTexture(String name, String type, String samplerState, U32 arraySize);
|
||||
void addConnector(String name, String elementName, String type);
|
||||
|
||||
void addConnector(String name, String type, String elementName);
|
||||
void addVertTexCoord(String name);
|
||||
bool hasFeature(String name);
|
||||
|
||||
void writeLine(String format, S32 argc, ConsoleValueRef *argv);
|
||||
|
|
@ -81,4 +83,4 @@ public:
|
|||
U32 &texIndex);*/
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "core/module.h"
|
||||
|
||||
#include "shaderGen/HLSL/customFeatureHLSL.h"
|
||||
#include "shaderGen/GLSL/customFeatureGLSL.h"
|
||||
|
||||
MODULE_BEGIN( ShaderGen )
|
||||
|
||||
|
|
@ -290,23 +291,32 @@ void ShaderGen::_processVertFeatures( Vector<GFXShaderMacro> ¯os, bool macro
|
|||
{
|
||||
for (U32 i = 0; i < mCustomFeaturesData.size(); ++i)
|
||||
{
|
||||
mCustomFeaturesData[i]->mFeatureHLSL->processVert(mComponents, mFeatureData);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
{
|
||||
mCustomFeaturesData[i]->mFeatureHLSL->processVert(mComponents, mFeatureData);
|
||||
|
||||
String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str());
|
||||
mOutput->addStatement(new GenOp(line));
|
||||
String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str());
|
||||
mOutput->addStatement(new GenOp(line));
|
||||
|
||||
if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput())
|
||||
mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput());
|
||||
//ShaderFeatureHLSL feature = mCustomFeaturesData[i]->mHLSLFeature;
|
||||
//feature->setProcessIndex(index);
|
||||
if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput())
|
||||
mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput());
|
||||
|
||||
/*feature->processPixMacros(macros, mFeatureData);
|
||||
mCustomFeaturesData[i]->mFeatureHLSL->reset();
|
||||
mOutput->addStatement(new GenOp(" \r\n"));
|
||||
}
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
{
|
||||
mCustomFeaturesData[i]->mFeatureGLSL->processVert(mComponents, mFeatureData);
|
||||
|
||||
feature->setInstancingFormat(&mInstancingFormat);
|
||||
feature->processPix(mComponents, mFeatureData);*/
|
||||
String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureGLSL->getName().c_str());
|
||||
mOutput->addStatement(new GenOp(line));
|
||||
|
||||
mCustomFeaturesData[i]->mFeatureHLSL->reset();
|
||||
mOutput->addStatement(new GenOp(" \r\n"));
|
||||
if (mCustomFeaturesData[i]->mFeatureGLSL->getOutput())
|
||||
mOutput->addStatement(mCustomFeaturesData[i]->mFeatureGLSL->getOutput());
|
||||
|
||||
mCustomFeaturesData[i]->mFeatureGLSL->reset();
|
||||
mOutput->addStatement(new GenOp(" \r\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -355,23 +365,32 @@ void ShaderGen::_processPixFeatures( Vector<GFXShaderMacro> ¯os, bool macros
|
|||
{
|
||||
for (U32 i = 0; i < mCustomFeaturesData.size(); ++i)
|
||||
{
|
||||
mCustomFeaturesData[i]->mFeatureHLSL->processPix(mComponents, mFeatureData);
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
{
|
||||
mCustomFeaturesData[i]->mFeatureHLSL->processPix(mComponents, mFeatureData);
|
||||
|
||||
String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str());
|
||||
mOutput->addStatement(new GenOp(line));
|
||||
String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str());
|
||||
mOutput->addStatement(new GenOp(line));
|
||||
|
||||
if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput())
|
||||
mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput());
|
||||
//ShaderFeatureHLSL feature = mCustomFeaturesData[i]->mHLSLFeature;
|
||||
//feature->setProcessIndex(index);
|
||||
if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput())
|
||||
mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput());
|
||||
|
||||
/*feature->processPixMacros(macros, mFeatureData);
|
||||
mCustomFeaturesData[i]->mFeatureHLSL->reset();
|
||||
mOutput->addStatement(new GenOp(" \r\n"));
|
||||
}
|
||||
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
|
||||
{
|
||||
mCustomFeaturesData[i]->mFeatureGLSL->processPix(mComponents, mFeatureData);
|
||||
|
||||
feature->setInstancingFormat(&mInstancingFormat);
|
||||
feature->processPix(mComponents, mFeatureData);*/
|
||||
String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureGLSL->getName().c_str());
|
||||
mOutput->addStatement(new GenOp(line));
|
||||
|
||||
mCustomFeaturesData[i]->mFeatureHLSL->reset();
|
||||
mOutput->addStatement(new GenOp(" \r\n"));
|
||||
if (mCustomFeaturesData[i]->mFeatureGLSL->getOutput())
|
||||
mOutput->addStatement(mCustomFeaturesData[i]->mFeatureGLSL->getOutput());
|
||||
|
||||
mCustomFeaturesData[i]->mFeatureGLSL->reset();
|
||||
mOutput->addStatement(new GenOp(" \r\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue