0
$\begingroup$

I am trying to do shadow mapping in vulkan however, the result I am getting is not correct. For shadow mapping we can use a sampler2DShadow and textureProj which is what I am doing but the result comes out incorrect.

I have verified that my LightSpaceMatrix is correct. I have implemented shadow mapping my doing the depth comparisons myself and the result was correct but I want to use textureProj and a sampler2DShadow for smaller code for shadow mapping.

Wondering if anyone might know what is causing the shadows to come out incorrect

layout(set = 0, binding = 0) uniform sampler2DShadow shadowMap;float compute_shadow(vec3 worldPos){    vec4 fragposLightSpace = Light.LightSpaceMatrix * vec4(worldPos, 1.0);    float shadow = textureProj(shadowMap, fragposLightSpace);    return shadow;}// SamplerVkSamplerCreateInfo samplerInfo{};samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;samplerInfo.magFilter = VK_FILTER_LINEAR;samplerInfo.minFilter = VK_FILTER_LINEAR;samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;samplerInfo.minLod = 0.0f;samplerInfo.maxLod = VK_LOD_CLAMP_NONE;samplerInfo.mipLodBias = 0.f;samplerInfo.maxAnisotropy = 16.0; samplerInfo.anisotropyEnable = VK_TRUE;samplerInfo.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;samplerInfo.compareEnable = VK_TRUE;samplerInfo.compareOp = VK_COMPARE_OP_LESS;

Result:enter image description here

askedDec 29, 2024 at 14:58
Nexi's user avatar
$\endgroup$

0

Know someone who can answer? Share a link to thisquestion viaemail,Twitter, orFacebook.

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.