Exemplo n.º 1
0
	void Render(const RenderParam& param, RenderParamOut* paramOut){
		if (mSelf->HasObjFlag(SceneObjectFlag::Hide))
			return;

		if (mBlendingSkySphere && mBlendingSkySphere->GetAlpha() == 1.0f){
			mBlendingSkySphere->Render(param, paramOut);
			return;
		}

		if (!mMaterial)
		{
			assert(0);
			return;
		}

		auto& renderer = Renderer::GetInstance();
		renderer.SetPrimitiveTopology(PRIMITIVE_TOPOLOGY_TRIANGLELIST);
		renderer.UnbindInputLayout();
		renderer.UnbindVertexBuffers();
		if (mMaterialOCC && param.mRenderPass == RENDER_PASS::PASS_GODRAY_OCC_PRE)
		{
			RenderEventMarker mark("SkySphere_OCC");
			mMaterialOCC->Bind(false);
			renderer.Draw(3, 0);
		}
		else if (param.mRenderPass == RENDER_PASS::PASS_NORMAL)
		{
			RenderEventMarker mark("SkySphere");			
			mMaterial->Bind(false);
			if (mUseAlphaBlend)
			{
				renderer.GetResourceProvider()->BindBlendState(ResourceTypes::BlendStates::AlphaBlend);
			}
			renderer.Draw(3, 0);
		}

		if (mBlendingSkySphere && mBlendingSkySphere->GetAlpha() != 0.f){
			mBlendingSkySphere->Render(param, paramOut);
		}
	}
	void Render(const RenderParam& param, RenderParamOut* paramOut){
		RenderEventMarker mark("ParticleRenderObject");
		if (mMapped)
		{
			mVertexBuffer->Unmap(0);
			mMapped = 0;
		}

		if (param.mRenderPass != RENDER_PASS::PASS_NORMAL || !mVertexBuffer || mBatches.empty())
			return;

		auto& renderer = Renderer::GetInstance();
		mMaterial->Bind(true);
		mVertexBuffer->Bind();
		renderer.SetPrimitiveTopology(PRIMITIVE_TOPOLOGY_POINTLIST);

		/*for (auto batch : mBatches){
		++sNumDrawCalls;
		pRenderer->Draw(batch.second, batch.first);
		sNumDrawPrimitives += batch.second;
		}*/

		//draw
		UINT num = 0;
		UINT start = mBatches[0].first;
		for(const auto& it : mBatches)
		{
			if (start > it.first)
			{
				// draw
				assert(start + num <= mMaxVertices);
				renderer.Draw(num, start);
				++sNumDrawCalls;
				sNumDrawPrimitives += num;
				start = it.first;
				num = 0;
			}
			num += it.second;
		}
		if (num)
		{
			assert(num < mMaxVertices);
			renderer.Draw(num, start);
			++sNumDrawCalls;
			sNumDrawPrimitives += num;
		}
		mMaterial->Unbind();
	}
Exemplo n.º 3
0
	void BeforeUIRendering(HWindowId hwndId, HWindow hwnd) {
		if (mMaterial) {
			auto& renderer = Renderer::GetInstance();
			auto cam = renderer.GetCamera();			
			OBJECT_CONSTANTS objConstants = {
				Mat44::IDENTITY,
				cam->GetMatrix(ICamera::MatrixType::View),
				cam->GetMatrix(ICamera::MatrixType::ViewProj),
			};
			renderer.UpdateObjectConstantsBuffer(&objConstants);

			mSphere.Bind();
			mMaterial->Bind();
			
			renderer.BindSystemTexture(SystemTextures::Permutation);
			renderer.BindSystemTexture(SystemTextures::ValueNoise);
			renderer.DrawIndexed(mSphere.mIndexBuffer->GetNumIndices(), 0, 0);						
		}		
	}