Ejemplo n.º 1
0
bool SDFShadowDemo::Init()
{
    Log::Get().Open();
    if (!Application::Init())
        return false;

    // Init the world matrix
    m_worldMat = Matrix4f::Identity();
    // Build the view matrix.
    Vector3f pos = Vector3f(0.0f, 1.0f, -5.0f);
    Vector3f target;
    target.MakeZero();
    Vector3f up = Vector3f(0.0f, 1.0f, 0.0f);
    m_viewMat = Matrix4f::LookAtLHMatrix(pos, target, up);
    // Build the projection matrix
    m_projMat = Matrix4f::PerspectiveFovLHMatrix(0.5f * Pi, AspectRatio(), 0.01f, 100.0f);

    BufferConfigDX11 cbConfig;
    cbConfig.SetDefaultConstantBuffer(sizeof(CBufferType), true);
    m_constantBuffer = m_pRender->CreateConstantBuffer(&cbConfig, 0);

    LoadSDFBuffer();
    BuildShaders();
    BuildQuad();
    LoadGeometry();

    SamplerStateConfigDX11 sampConfig;
    m_samplerID = m_pRender->CreateSamplerState(&sampConfig);

    return true;
}
Ejemplo n.º 2
0
void SDFShadowDemo::UpdateScene(f32 /*dt*/)
{
    auto frames = (f32)mTimer.FrameCount() / 1000;
    //m_worldMat = Matrix4f::RotationMatrixY(frames);
    m_worldMat = Matrix4f::Identity();

    Matrix4f viewRot = Matrix4f::RotationMatrixY(frames);
    // Build the view matrix.
    m_cameraPos = Vector4f(0.0f, 1.0f, -5.0f, 1.0f);
    m_cameraPos = viewRot * m_cameraPos;
    Vector3f target;
    target.MakeZero();
    Vector3f up = Vector3f(0.0f, 1.0f, 0.0f);
    m_viewMat = Matrix4f::LookAtLHMatrix(m_cameraPos.xyz(), target, up);
}
Ejemplo n.º 3
0
//----------------------------------------------------------------------------------------------------
Vector3f Vector3f::operator/ ( float fScalar ) const
{
	Vector3f quot;
	if ( fScalar != 0.0f )
	{
		float fInvScalar = 1.0f / fScalar;
		quot.x = x * fInvScalar;
		quot.y = y * fInvScalar;
		quot.z = z * fInvScalar;
	}
	else
	{
		quot.MakeZero();
	}

	return( quot );
}