Edvin
Edvin

Reputation: 2011

Does a shadowmap have to cover the whole scene?

My example is that I have a sponza model and want the sun to shine through the roof as shown in the picture. What happens if I set the shadowmap to only cover a section of a scene? In this example only cover the hole in the roof and set everything else to be in shadow. My thought process is that limiting the shadowmap to only cover the hole in the roof would lead to a higher resolution in the shadowmap and thus better quality of the shadows.

What happens when I read outside the texture in the fragment shader? e.g:

float depthTextureValue = texture(shadowMap, shadowCoordinate.xy).x;

Whould the texture-method return 0? -1?

Upvotes: 0

Views: 359

Answers (1)

Colonel Thirty Two
Colonel Thirty Two

Reputation: 26589

It depends on the texture's (or sampler's) wrapping mode, which is settable using the glTexParamter* functions for each axis using the constants GL_TEXTURE_WRAP_[STR].

The two most common modes are GL_REPEAT, which causes the texture to wrap around, or GL_CLAMP_TO_EDGE, which repeats the edges of the texture.

Upvotes: 1

Related Questions