Beispiel #1
0
void ShadowMap::setResolution(ID3D11Device* device, UINT width, UINT height)
{	
	// Release old SRV and DSV
	ReleaseCOM(mDepthMapSRV);
	ReleaseCOM(mDepthMapDSV);

	createShadowMap(device, width, height);
}
Beispiel #2
0
void ShadowMap::setResolution(ID3D11Device* device, UINT width, UINT height)
{	
	// Release old SRV and DSV
	mDepthMapSRV->Release();
	mDepthMapDSV->Release();
	mDepthMapDSV = NULL;
	mDepthMapSRV = NULL;

	createShadowMap(device, width, height);
}
////////////////////////////////////////////////////////////////////////////////
// SoftShadowsRenderer::initRendering()
////////////////////////////////////////////////////////////////////////////////
void SoftShadowsRenderer::initRendering()
{
    GLint depthBits;
    glGetIntegerv(GL_DEPTH_BITS, &depthBits);
    LOGI("depth bits = %d\n", depthBits);

    // Setup the eye's view parameters
    initCamera(
        NvCameraXformType::MAIN,
        nv::vec3f(-0.644995f, 0.614183f, 0.660632f) * 1.5f, // position
        nv::vec3f(0.0f, 0.0f, 0.0f));                       // look at point

    // Setup the light's view parameters
    initCamera(
        NvCameraXformType::SECONDARY,
        nv::vec3f(3.57088f, 6.989f, 5.19698f) * 1.5f, // position
        nv::vec3f(0.0f, 0.0f, 0.0f));                 // look at point

    // Generate the samplers
    glGenSamplers(5, m_samplers);
    CHECK_GL_ERROR();
    for (GLuint unit = 0; unit < NumTextureUnits; ++unit)
    {
        glBindSampler(unit, m_samplers[unit]);
    }

    // Create resources
    createShadowMap();
    createGeometry();
    createTextures();
    createShaders();

    // Set states that don't change
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glDepthFunc(GL_LESS);
    glCullFace(GL_BACK);
    glDisable(GL_BLEND);

    glClearColor(
        m_backgroundColor.x,
        m_backgroundColor.y,
        m_backgroundColor.z,
        m_backgroundColor.w);
    glClearDepthf(1.0f);

    for (GLuint unit = 0; unit < NumTextureUnits; ++unit)
    {
        glBindSampler(unit, 0);
    }
}
Beispiel #4
0
ShadowMap::ShadowMap(ID3D11Device* device, UINT width, UINT height)
	: mDepthMapDSV(0), mDepthMapSRV(0)
{
	createShadowMap(device, width, height);
}
Beispiel #5
0
void DynamicLight::updateShadowMap(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated)
{
    createOcclusionMap();
    createShadowMap(renderer, transform, transformUpdated);
}