Beispiel #1
0
void DefferedShadingDemo::CreateQuad()
{
	using namespace engine;
	struct Vertex
	{
		math::Vector3			pos;
		math::Vector2			uv;
	};

	Vertex verts[] = 
	{
		{ math::Vector3(-1, 1, 0), math::Vector2(0, 0),},
		{ math::Vector3(1, 1, 0), math::Vector2(1, 0),},
		{ math::Vector3(1, -1, 0), math::Vector2(1, 1),},
		{ math::Vector3(-1, 1, 0), math::Vector2(0, 0),},
		{ math::Vector3(1, -1, 0), math::Vector2(1, 1),},
		{ math::Vector3(-1, -1, 0), math::Vector2(0, 1),},
	};

	m_pQuadVB = m_pCore->GetSysGraphics()->CreateBuffer(BT_VERTEX_BUFFER, sizeof(Vertex) * 6, verts, true);


	m_pQuadMaterial = m_pCore->GetSysGraphics()->CreateMaterialFromFile("./assets/standard/material/ds2.fx");

	VertexElement vf[] = 
	{
		VertexElement(0, VertexElement::POSITION,G_FORMAT_R32G32B32_FLOAT),
		VertexElement(0, VertexElement::TEXCOORD,G_FORMAT_R32G32_FLOAT),
	};
	VertexFormat format;

	format.SetElement(vf, 2);

	m_pQuadMaterial->SetVertexFormat(format);
}
Beispiel #2
0
	bool PostEffect_SSAO::Initialize(RenderSystemPtr pRS)
	{
		
		m_pMaterial = pRS->CreateMaterialFromFile("./assets/standard/material/dr_render_ssao.fx");

		VertexElement vf[] = 
		{
			VertexElement(0, VertexElement::POSITION,G_FORMAT_R32G32B32_FLOAT),
		};
		VertexFormat format;

		format.SetElement(vf, 1);

		m_pMaterial->SetVertexFormat(format);

		m_pSSAORandomTex = pRS->CreateTextureFromFile("./assets/standard/texture/ssao_rand.jpg");
		
		m_pMaterial->SetTextureByName("tex_ssao_rand", m_pSSAORandomTex);


		int w = pRS->GetFrameBufferWidth();

		int h = pRS->GetFrameBufferHeight();
		G_FORMAT rt_format[1] = {G_FORMAT_R8G8B8A8_UNORM,};
		m_pGBlurTarget = pRS->CreateRenderTarget(1, w , h , rt_format);

		if(m_pGBlurTarget == nullptr)
		{
			return false;
		}

		m_pGBlurMaterial = pRS->CreateMaterialFromFile("./assets/standard/material/dr_render_BBlur.fx");

		if(m_pGBlurMaterial == nullptr)
		{
			return false;
		}
		
		m_pGBlurMaterial->SetVertexFormat(format);
		return true;
	}
bool PostEffect_GaussianBlur::Initialize(RenderSystemPtr pRS)
{
    m_pRS = pRS;

    m_pMaterial = pRS->CreateMaterialFromFile("./assets/standard/material/dr_render_GBlur.fx");

    if(m_pMaterial == nullptr)
    {
        return false;
    }
    VertexElement vf[] =
    {
        VertexElement(0, VertexElement::POSITION,G_FORMAT_R32G32B32_FLOAT),
    };
    VertexFormat format;

    format.SetElement(vf, 1);

    m_pMaterial->SetVertexFormat(format);


    return true;

}