Esempio n. 1
0
	void Shadow::Do(Texture * depthTex)
	{
		RenderSystem * render = RenderSystem::Instance();

		RenderTarget * oldRt = render->GetRenderTarget(0);
		DepthStencil * oldDs = render->GetDepthStencil();

		_updateCamera();

		/*for (int i = 0; i < 4; ++i)
		{
		Mat4 matCrop = _calcuCropMatrix(i);
		mCascadedViewProjMatrix[i] = mLightCamera->GetViewProjMatrix() * matCrop;
		}*/

		_impVisibleCull();

		{
			RS_RenderEvent(ShadowMap);

			for (int i = 0; i < K_NumShadowLayers; ++i)
			{
				_calcuCascadedMatrix(i);
				_renderDepth(i);
				_genShadowMap(i, depthTex);
			}
		}

		render->SetRenderTarget(0, oldRt);
		render->SetDepthStencil(oldDs);
	}
Esempio n. 2
0
	void Water::_renderRelfection()
	{
		if (WaterManager::Instance()->IsUnderWater())
			return ;

		mRenderRefl = true;

		RenderSystem * render = RenderSystem::Instance();

		Plane mirrorPlane = Plane(Vec3(0, 1, 0), -mHeight);

		RenderTarget * oldRT = render->GetRenderTarget(0);
		DepthStencil * oldDS = render->GetDepthStencil();

		// ---> Bind RenderTarget
		render->SetRenderTarget(0, mRT_Refl.c_ptr());
		render->SetRenderTarget(1, NULL);
		render->SetRenderTarget(2, NULL);
		render->SetRenderTarget(3, NULL);
		render->SetDepthStencil(mDepthStencil.c_ptr());

		// ---> clear buffer
		render->ClearBuffer(NULL, true, true, false, Color::Black, 1, 0);

		Color4 deepColor = Environment::Instance()->GetEvParam()->WaterParam.reflColor;

		RenderRegister::Instance()->SetMirrorColor(deepColor);

		Engine::Instance()->GetRenderScheme()->RenderInMirror(mirrorPlane);

		mRT_Refl->Stretch(mTex_Refl.c_ptr());

		render->SetRenderTarget(0, oldRT);
		render->SetDepthStencil(oldDS);

		mRenderRefl = false;
	}