SO3Engine
|
SO3RtssCustom.cpp
Go to the documentation of this file.
23 AdvancedCookTorranceLighting::AdvancedCookTorranceLighting() : mUseOcclusion(false), mLightCount(0), mMRMapSamplerIndex(0), mLtcLUT1SamplerIndex(-1) {}
26 const Ogre::String& AdvancedCookTorranceLighting::getType() const { return SRS_ADV_COOK_TORRANCE_LIGHTING; }
43 auto vsOutTexcoord = vsMain->getOutputParameter(Ogre::RTShader::Parameter::SPC_TEXTURE_COORDINATE0, Ogre::GCT_FLOAT2); // allow override by others
47 vsInTexcoord = vsMain->resolveInputParameter(Ogre::RTShader::Parameter::SPC_TEXTURE_COORDINATE0, Ogre::GCT_FLOAT2);
48 vsOutTexcoord = vsMain->resolveOutputParameter(Ogre::RTShader::Parameter::SPC_TEXTURE_COORDINATE0, Ogre::GCT_FLOAT2);
53 auto vsInPosition = vsMain->getLocalParameter(Ogre::RTShader::Parameter::SPC_POSITION_OBJECT_SPACE);
55 vsInPosition = vsMain->resolveInputParameter(Ogre::RTShader::Parameter::SPC_POSITION_OBJECT_SPACE);
56 auto vsOutViewPos = vsMain->resolveOutputParameter(Ogre::RTShader::Parameter::SPC_POSITION_VIEW_SPACE);
58 auto worldViewMatrix = vsProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_WORLDVIEW_MATRIX);
92 auto worldViewITMatrix = vsProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_NORMAL_MATRIX);
96 auto sceneCol = psProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_DERIVED_SCENE_COLOUR);
98 auto diffuse = psProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
118 fstage.mul(Ogre::RTShader::In(ambientColor).xyz(), Ogre::RTShader::In(mrSample).x(), Ogre::RTShader::Out(ambientColor).xyz());
122 auto specular = psProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_SURFACE_SPECULAR_COLOUR);
128 fstage.mul(Ogre::RTShader::In(diffuse).xyz(), Ogre::RTShader::In(outDiffuse).xyz(), Ogre::RTShader::Out(baseColor).xyz());
131 fstage.mul(Ogre::RTShader::In(diffuse).w(), Ogre::RTShader::In(outDiffuse).w(), Ogre::RTShader::Out(outDiffuse).w());
132 fstage.callFunction("PBR_MakeParams", { Ogre::RTShader::In(baseColor).xyz(), Ogre::RTShader::In(mrparams), Ogre::RTShader::InOut(pixelParams) });
134 fstage = psMain->getStage(Ogre::RTShader::FFP_PS_COLOUR_END + 60); // make gap to inject IBL here
137 auto lightPos = psProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_LIGHT_POSITION_VIEW_SPACE_ARRAY, mLightCount);
138 auto lightDiffuse = psProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR_POWER_SCALED_ARRAY, mLightCount);
139 auto pointParams = psProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_LIGHT_ATTENUATION_ARRAY, mLightCount);
140 auto spotParams = psProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_SPOTLIGHT_PARAMS_ARRAY, mLightCount);
141 auto lightDirView = psProgram->resolveParameter(Ogre::GpuProgramParameters::ACT_LIGHT_DIRECTION_VIEW_SPACE_ARRAY, mLightCount);
143 std::vector<Ogre::RTShader::Operand> params = { Ogre::RTShader::In(viewNormal), Ogre::RTShader::In(viewPos), Ogre::RTShader::In(ambientColor), Ogre::RTShader::In(lightPos),
144 Ogre::RTShader::In(lightDiffuse), Ogre::RTShader::In(pointParams), Ogre::RTShader::In(lightDirView), Ogre::RTShader::In(spotParams),
149 auto ltcLUT1 = psProgram->resolveParameter(Ogre::GCT_SAMPLER2D, "ltcLUT1Sampler", mLtcLUT1SamplerIndex);
169 const AdvancedCookTorranceLighting& rhsLighting = static_cast<const AdvancedCookTorranceLighting&>(rhs);
176 bool AdvancedCookTorranceLighting::preAddToRenderState(const Ogre::RTShader::RenderState* renderState, Ogre::Pass* srcPass, Ogre::Pass* dstPass)
195 bool AdvancedCookTorranceLighting::setParameter(const Ogre::String& name, const Ogre::String& value)
212 const Ogre::String& AdvancedCookTorranceLightingFactory::getType() const { return SRS_ADV_COOK_TORRANCE_LIGHTING; }
215 Ogre::RTShader::SubRenderState* AdvancedCookTorranceLightingFactory::createInstance(Ogre::ScriptCompiler* compiler, Ogre::PropertyAbstractNode* prop,
248 void AdvancedCookTorranceLightingFactory::writeInstance(Ogre::MaterialSerializer* ser, Ogre::RTShader::SubRenderState* subRenderState, Ogre::Pass* srcPass,
262 Ogre::RTShader::SubRenderState* AdvancedCookTorranceLightingFactory::createInstanceImpl() { return OGRE_NEW AdvancedCookTorranceLighting; }
void writeInstance(Ogre::MaterialSerializer *ser, Ogre::RTShader::SubRenderState *subRenderState, Ogre::Pass *srcPass, Ogre::Pass *dstPass) override
Definition SO3RtssCustom.cpp:248
const Ogre::String & getType() const override
Definition SO3RtssCustom.cpp:212
Ogre::RTShader::SubRenderState * createInstance(Ogre::ScriptCompiler *compiler, Ogre::PropertyAbstractNode *prop, Ogre::Pass *pass, Ogre::RTShader::SGScriptTranslator *translator) override
Definition SO3RtssCustom.cpp:215
Ogre::RTShader::SubRenderState * createInstanceImpl() override
Definition SO3RtssCustom.cpp:262
const Ogre::String & getType() const override
Definition SO3RtssCustom.cpp:26
bool createCpuSubPrograms(Ogre::RTShader::ProgramSet *programSet) override
Definition SO3RtssCustom.cpp:28
AdvancedCookTorranceLighting()
Definition SO3RtssCustom.cpp:23
bool preAddToRenderState(const Ogre::RTShader::RenderState *renderState, Ogre::Pass *srcPass, Ogre::Pass *dstPass) override
Definition SO3RtssCustom.cpp:176
void copyFrom(const Ogre::RTShader::SubRenderState &rhs) override
Definition SO3RtssCustom.cpp:167
bool setParameter(const Ogre::String &name, const Ogre::String &value) override
Definition SO3RtssCustom.cpp:195
Definition SO3DataScol.h:38
const Ogre::String SRS_ADV_COOK_TORRANCE_LIGHTING
Definition SO3RtssCustom.cpp:20
Generated by 1.9.8