14 std::vector<float>
const& reflectances)
17 mReflectances(reflectances),
18 mPlaneOrigins(planes.
size()),
19 mPlaneNormals(planes.
size())
21 unsigned int const numPlanes =
static_cast<unsigned int>(
mPlanes.size());
22 for (
unsigned int i = 0; i < numPlanes; ++i)
24 std::shared_ptr<Visual> plane =
mPlanes[i];
34 std::shared_ptr<VertexBuffer> vbuffer = plane->GetVertexBuffer();
35 unsigned int vstride = vbuffer->GetElementSize();
36 std::set<DFType> required;
39 char const* positions = vbuffer->GetChannel(
VA_POSITION, 0, required);
49 std::shared_ptr<IndexBuffer> ibuffer = plane->GetIndexBuffer();
50 IPType primitiveType = ibuffer->GetPrimitiveType();
53 LogError(
"Expecting triangle topology.");
61 if (ibuffer->IsIndexed())
63 ibuffer->GetTriangle(i, v[0], v[1], v[2]);
81 for (
int j = 0; j < 3; ++j)
84 p[j] = HLift<3, float>(temp, 1.0f);
110 mDSPass0 = std::make_shared<DepthStencilState>();
111 mDSPass0->depthEnable =
true;
114 mDSPass0->stencilEnable =
true;
118 mDSPass0->frontFace.comparison = DepthStencilState::ALWAYS;
120 mDSPass1 = std::make_shared<DepthStencilState>();
122 mDSPass1->writeMask = DepthStencilState::MASK_ALL;
123 mDSPass1->comparison = DepthStencilState::ALWAYS;
130 mDSPass2 = std::make_shared<DepthStencilState>();
132 mDSPass2->writeMask = DepthStencilState::MASK_ALL;
145 std::shared_ptr<BlendState> saveBState = engine->GetBlendState();
146 std::shared_ptr<DepthStencilState> saveDSState = engine->GetDepthStencilState();
147 std::shared_ptr<RasterizerState> saveRState = engine->GetRasterizerState();
151 float minDepth, maxDepth;
152 engine->GetDepthRange(minDepth, maxDepth);
155 std::shared_ptr<Camera> camera = pvwMatrices.
GetCamera();
159 if (saveRState->cullMode == RasterizerState::CULL_BACK)
173 unsigned int const numPlanes =
static_cast<unsigned int>(
mPlanes.size());
176 std::shared_ptr<Visual> plane =
mPlanes[i];
188 engine->SetDepthStencilState(
mDSPass0);
202 engine->SetDepthStencilState(
mDSPass1);
203 engine->SetDefaultBlendState();
204 engine->SetDepthRange(maxDepth, maxDepth);
206 engine->SetDepthRange(minDepth, maxDepth);
222 #if defined(GTE_USE_MAT_VEC) 232 engine->SetDefaultDepthStencilState();
234 for (
auto const& visual : visibleSet)
236 engine->Draw(visual);
238 engine->SetRasterizerState(saveRState);
251 engine->SetDepthStencilState(
mDSPass2);
257 engine->SetBlendState(saveBState);
258 engine->SetDepthStencilState(saveDSState);
259 engine->SetRasterizerState(saveRState);
262 for (
auto const& visual : visibleSet)
264 engine->Draw(visual);
void SetReflectance(int i, float reflectance)
std::vector< Visual * > VisibleSet
std::pair< Vector4< float >, Vector4< float > > GetPlane(int i) const
Vector< N, Real > UnitCross(Vector< N, Real > const &v0, Vector< N, Real > const &v1, bool robust=false)
std::shared_ptr< DepthStencilState > mDSPass0
std::vector< float > mReflectances
std::shared_ptr< Visual > GetPlaneVisual(int i) const
std::vector< Vector4< float > > mPlaneOrigins
std::vector< Vector4< float > > mPlaneNormals
virtual void Draw(std::shared_ptr< GraphicsEngine > const &engine, VisibleSet const &visibleSet, PVWUpdater &pvwMatrices)
GLfixed GLfixed GLint GLint GLfixed GLfixed GLint vstride
#define LogError(message)
std::shared_ptr< DepthStencilState > mDSPass2
std::shared_ptr< DepthStencilState > mDSPass1
std::shared_ptr< Camera > const & GetCamera() const
Matrix4x4< Real > MakeReflection(Vector4< Real > const &origin, Vector4< Real > const &normal)
std::vector< std::shared_ptr< Visual > > mPlanes
Real Normalize(GVector< Real > &v, bool robust=false)
std::shared_ptr< BlendState > mNoColorWrites
std::shared_ptr< BlendState > mReflectanceBlend
std::shared_ptr< RasterizerState > mCullReverse
PlanarReflectionEffect(std::vector< std::shared_ptr< Visual >> const &planes, std::vector< float > const &reflectances)
float GetReflectance(int i) const