Ogre Version: :14.3.4:
Operating System: :Linux:
Render System: :GL3Plus:
Hi, I have been trying to understand how I would go about to add my own "extension" to the rtshader_system.
I have a .material file like this:
Code: Select all
material island5_water.glbdummyMat0
{
technique
{
pass
{
rtshader_system
{
DepthFoam
}
}
}
}
And then I have
Code: Select all
class DepthFoam : public Ogre::RTShader::SubRenderState
{
public:
static constexpr Ogre::String Type = "DepthFoam";
DepthFoam() = default;
~DepthFoam() = default;
float foamWidth = 1.0f;
float foamSharpness = 1.5f;
Ogre::ColourValue foamColor {1.0f, 1.0f, 1.0f, 1.0f};
const Ogre::String& getType() const override { return Type; }
int getExecutionOrder() const override { return Ogre::RTShader::FFP_PS_COLOUR_BEGIN + 10; }
void copyFrom(const Ogre::RTShader::SubRenderState& rhs) override {
const auto& o = static_cast<const DepthFoam&>(rhs);
}
bool createCpuSubPrograms(Ogre::RTShader::ProgramSet* programSet) override;
};
class DepthFoamShaderFactory: public Ogre::RTShader::SubRenderStateFactory
{
public:
const Ogre::String& getType() const override { return DepthFoam::Type; }
Ogre::RTShader::SubRenderState* createInstance() override {
return OGRE_NEW DepthFoam();
}
Ogre::RTShader::SubRenderState* createInstance(Ogre::ScriptCompiler* compiler, Ogre::PropertyAbstractNode* prop, Ogre::Pass* pass, Ogre::RTShader::SGScriptTranslator* translator) override
{
return OGRE_NEW DepthFoam();
}
Ogre::RTShader::SubRenderState* createInstanceImpl() override {
return OGRE_NEW DepthFoam();
}
};
And during initialization i do the following:
Code: Select all
OgreBites::ApplicationContext::setup();
addInputListener(this);
auto* root = getRoot();
auto* scnMgr = root->createSceneManager();
auto* shaderGen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
shaderGen->addSceneManager(scnMgr);
shaderGen->addSubRenderStateFactory(OGRE_NEW DepthFoamShaderFactory);
...........
But I never see that it calls createCpuSubPrograms in the DepthFoam subrenderstate.
I don't really understand if it's related to some SCHEMA thing? I don't want the shader to be applied to everything. Only the mesh that uses island5_water.glbdummyMat0
Any points are much appreciated!
Best regards

