Shadowmaps Sample

This topic contains 1 reply, has 2 voices, and was last updated by  Arron 5 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30910

    xyzwrgba
    Member

    Hi all, I am following the shadow course in the latest SDK for windows emulation which I want to use later on, on android and ios.

    First of all, is this tutorial just the code or is there some theory text accompanying it?
    I understand like 80% of it and have most of the stuff coded up its just that my entire scene ends up being in shadow.
    In another book it says that we must use specific border settigns like this:
    GLfloat Border[] = {1.0f, 0.0f, 0.0f, 0.0f};
        glGenTextures(1, &ZONE_DEPTH);
        glBindTexture(GL_TEXTURE_2D, ZONE_DEPTH);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, ZoneShadowmapSizeX, ZoneShadowmapSizeY, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
        glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, Border);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
    The author says that this is absolutely necessary otherwise the whole scene will end up in shadow. I am just wondering how does the sample actually account for this and make everything work?
    Also can we use linear depth texture values when doing the final comparison?
    #35971

    Arron
    Member

    Hi,

    It looks like you’re using – or attempting to use – the EXT_shadow_samplers extension? In this case, yes, it is necessary to alter the ‘border’ of the shadow map texture in order to correct the artefacts that you’re seeing. This can also be done by altering the viewport of your shadow texture to something like:

    glViewport(1, 1, m_ui32ShadowMapSize-2, m_ui32ShadowMapSize-2);
    and set the wrapping of the texture to GL_CLAMP_TO_EDGE.

    The EXT_shadow_samplers extension allows for a linear sample of the depth texture, and will return some value in the range of 0.0 to 1.0.

    Arron2012-07-05 16:30:24

Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.