| 8 | #include "SMSceneEffect.h" |
| 9 | |
| 10 | SMSceneEffect::SMSceneEffect( |
| 11 | std::shared_ptr<ProgramFactory> const& factory, |
| 12 | std::string const& vsPath, |
| 13 | std::string const& psPath, |
| 14 | Geometry const& geometry, |
| 15 | LightColor const& lightColor, |
| 16 | std::shared_ptr<Texture2> const& baseTexture, |
| 17 | std::shared_ptr<Texture2> const& blurTexture, |
| 18 | std::shared_ptr<Texture2> const& projTexture) |
| 19 | : |
| 20 | mGeometryBuffer{}, |
| 21 | mLightColorBuffer{}, |
| 22 | mBaseTexture(baseTexture), |
| 23 | mBlurTexture(blurTexture), |
| 24 | mProjTexture(projTexture), |
| 25 | mSampler{} |
| 26 | { |
| 27 | mProgram = factory->CreateFromFiles(vsPath, psPath, ""); |
| 28 | LogAssert( |
| 29 | mProgram, |
| 30 | "Cannot compile " + vsPath + " or " + psPath); |
| 31 | |
| 32 | mGeometryBuffer = std::make_shared<ConstantBuffer>(sizeof(Geometry), true); |
| 33 | *mGeometryBuffer->Get<Geometry>() = geometry; |
| 34 | |
| 35 | mLightColorBuffer = std::make_shared<ConstantBuffer>(sizeof(LightColor), true); |
| 36 | *mLightColorBuffer->Get<LightColor>() = lightColor; |
| 37 | |
| 38 | mSampler = std::make_shared<SamplerState>(); |
| 39 | mSampler->filter = SamplerState::Filter::MIN_P_MAG_L_MIP_P; |
| 40 | mSampler->mode[0] = SamplerState::Mode::CLAMP; |
| 41 | mSampler->mode[1] = SamplerState::Mode::CLAMP; |
| 42 | |
| 43 | auto const& vshader = mProgram->GetVertexShader(); |
| 44 | vshader->Set("PVWMatrix", mPVWMatrixConstant); |
| 45 | vshader->Set("Geometry", mGeometryBuffer); |
| 46 | |
| 47 | auto const& pshader = mProgram->GetPixelShader(); |
| 48 | pshader->Set("LightColor", mLightColorBuffer); |
| 49 | pshader->Set("baseTexture", mBaseTexture, "baseSampler", mSampler); |
| 50 | pshader->Set("blurTexture", mBlurTexture, "blurSampler", mSampler); |
| 51 | pshader->Set("projTexture", mProjTexture, "projSampler", mSampler); |
| 52 | } |
| 53 | |
| 54 |
nothing calls this directly
no test coverage detected