Initial implementation of Custom Shader Features.

This commit is contained in:
Areloch 2017-10-05 17:04:51 -05:00
parent f9b7f66571
commit dc5e502dec
12 changed files with 595 additions and 9 deletions

View file

@ -483,6 +483,9 @@ void Material::initPersistFields()
endGroup( "Behavioral" );
addProtectedField("customShaderFeature", TypeRealString, NULL, &protectedSetCustomShaderFeature, &defaultProtectedGetFn,
"Do not modify, for internal use.", AbstractClassRep::FIELD_HideInInspectors);
Parent::initPersistFields();
}
@ -500,6 +503,19 @@ bool Material::writeField( StringTableEntry fieldname, const char *value )
return Parent::writeField( fieldname, value );
}
bool Material::protectedSetCustomShaderFeature(void *object, const char *index, const char *data)
{
Material *material = static_cast< Material* >(object);
CustomShaderFeatureData* customFeature;
if (!Sim::findObject(data, customFeature))
return false;
material->mCustomShaderFeatures.push_back(customFeature);
return false;
}
bool Material::onAdd()
{
if (Parent::onAdd() == false)

View file

@ -41,6 +41,9 @@
#include "console/dynamicTypes.h"
#endif
#ifndef CUSTOMSHADERFEATURE_H
#include "shaderGen/customShaderFeature.h"
#endif
class CubemapData;
class SFXTrack;
@ -49,7 +52,7 @@ class FeatureSet;
class FeatureType;
class MaterialSoundProfile;
class MaterialPhysicsProfile;
class CustomShaderFeatureData;
/// The basic material definition.
class Material : public BaseMaterialDefinition
@ -343,6 +346,8 @@ public:
F32 mDirectSoundOcclusion; ///< Amount of volume occlusion on direct sounds.
F32 mReverbSoundOcclusion; ///< Amount of volume occlusion on reverb sounds.
Vector<CustomShaderFeatureData*> mCustomShaderFeatures;
///@}
String mMapTo; // map Material to this texture name
@ -380,6 +385,8 @@ public:
virtual void inspectPostApply();
virtual bool writeField( StringTableEntry fieldname, const char *value );
static bool protectedSetCustomShaderFeature(void *object, const char *index, const char *data);
//
// ConsoleObject interface
//

View file

@ -81,6 +81,8 @@ public:
MaterialFeatureData mFeatureData;
Vector<CustomShaderFeatureData*> mCustomShaderFeatureData;
bool mGlow;
Material::BlendOp mBlendOp;

View file

@ -654,7 +654,7 @@ bool ProcessedShaderMaterial::_addPass( ShaderRenderPassData &rpd,
// Generate shader
GFXShader::setLogging( true, true );
rpd.shader = SHADERGEN->getShader( rpd.mFeatureData, mVertexFormat, &mUserMacros, samplers );
rpd.shader = SHADERGEN->getShader( rpd.mFeatureData, mMaterial->mCustomShaderFeatures, mVertexFormat, &mUserMacros, samplers );
if( !rpd.shader )
return false;
rpd.shaderHandles.init( rpd.shader );