| 11 | using namespace gte; |
| 12 | |
| 13 | AreaLightEffect::AreaLightEffect(std::shared_ptr<ProgramFactory> const& factory, |
| 14 | std::shared_ptr<Texture2> const& baseTexture, |
| 15 | std::shared_ptr<Texture2> const& normalTexture, SamplerState::Filter filter, |
| 16 | SamplerState::Mode mode0, SamplerState::Mode mode1) |
| 17 | : |
| 18 | mBaseTexture(baseTexture), |
| 19 | mNormalTexture(normalTexture) |
| 20 | { |
| 21 | int32_t api = factory->GetAPI(); |
| 22 | mProgram = factory->CreateFromSources(*msVSSource[api], *msPSSource[api], ""); |
| 23 | if (mProgram) |
| 24 | { |
| 25 | // Create the shader constants. These must be initialized by the |
| 26 | // application before the first use of the effect. |
| 27 | mMaterialConstant = std::make_shared<ConstantBuffer>(sizeof(Material), true); |
| 28 | mCameraConstant = std::make_shared<ConstantBuffer>(sizeof(Vector4<float>), true); |
| 29 | mAreaLightConstant = std::make_shared<ConstantBuffer>(sizeof(Parameters), true); |
| 30 | |
| 31 | mCommonSampler = std::make_shared<SamplerState>(); |
| 32 | mCommonSampler->filter = filter; |
| 33 | mCommonSampler->mode[0] = mode0; |
| 34 | mCommonSampler->mode[1] = mode1; |
| 35 | |
| 36 | std::shared_ptr<Shader> vshader = mProgram->GetVertexShader(); |
| 37 | std::shared_ptr<Shader> pshader = mProgram->GetPixelShader(); |
| 38 | vshader->Set("PVWMatrix", mPVWMatrixConstant); |
| 39 | pshader->Set("Material", mMaterialConstant); |
| 40 | pshader->Set("Camera", mCameraConstant); |
| 41 | pshader->Set("AreaLight", mAreaLightConstant); |
| 42 | pshader->Set("baseTexture", mBaseTexture, "baseSampler", mCommonSampler); |
| 43 | pshader->Set("normalTexture", mNormalTexture, "normalSampler", mCommonSampler); |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | LogError("Failed to compile shader programs."); |
| 48 | } |
| 49 | |
| 50 | } |
| 51 | |
| 52 | void AreaLightEffect::SetPVWMatrixConstant(std::shared_ptr<ConstantBuffer> const& buffer) |
| 53 | { |
nothing calls this directly
no test coverage detected