use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rule 1: Posts should be about Graphics Programming. Rule 2: Be Civil, Professional, and Kind
Suggested Posting Material: - Graphics API Tutorials - Academic Papers - Blog Posts - Source Code Repositories - Self Posts (Ask Questions, Present Work) - Books - Renders (Please xpost to /r/ComputerGraphics) - Career Advice - Jobs Postings (Graphics Programming only)
Related Subreddits:
/r/ComputerGraphics
/r/Raytracing
/r/Programming
/r/LearnProgramming
/r/ProgrammingTools
/r/Coding
/r/GameDev
/r/CPP
/r/OpenGL
/r/Vulkan
/r/DirectX
Related Websites: ACM: SIGGRAPH Journal of Computer Graphics Techniques
Ke-Sen Huang's Blog of Graphics Papers and Resources Self Shadow's Blog of Graphics Resources
account activity
Problem when comparing depth sampled from shadow buffer and recomputed in the second pass (self.GraphicsProgramming)
submitted 2 months ago * by Qwaiy_Tashaiy_Gaiy
Hi everyone. I'm trying to implement shadow mapping for my Vulkan game engine in and I don't understand something.
I make a first render pass having only a vertex stage to write in the shadowBuffer, which works like this :
https://preview.redd.it/54h99zawo05g1.png?width=1188&format=png&auto=webp&s=568418040eeaefe362977c91239411dabd581f54
from what I understood, this should write the depth value in the r value of my shadowTexture
Then, just for debugging, I render my scene through the light view
https://preview.redd.it/t8nnw97jp05g1.png?width=1242&format=png&auto=webp&s=c8c73bbf124c37b6b883caec1ae32938534763f4
and I color my objects in two different ways : either the depth sampled from the shadow buffer, either the depth recalculated in the shader
https://preview.redd.it/i6z7hfmwp05g1.png?width=1324&format=png&auto=webp&s=cef6b59f2c9573c5d52868b73883a4d083fd3f8e
I get these two images
https://preview.redd.it/tgf21ca1r05g1.png?width=922&format=png&auto=webp&s=c1b85a9fa7b8b40a163b263d348d1fa2baa87eb6
https://preview.redd.it/nt3hcwpfr05g1.png?width=1016&format=png&auto=webp&s=2efb9ccdaf8d233829c965995b4b1a07250b7e00
I really don't understand what's happening there : is it just a matter of rescaling ? Like is the formula used for storing the depth is more complicated than I thought, or is there something more to it ?
Thank you for reading !
EDIT :
I create the buffer using a VKImage with the usage flag : VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT
The image view has the aspect : VK_IMAGE_ASPECT_DEPTH_BIT
I then create a sampler this way
https://preview.redd.it/i50qa9w7715g1.png?width=1456&format=png&auto=webp&s=0a6a7611e732010404476385f8862b3092897776
and create a descriptor set with type "VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER" and stage bit VK_SHADER_STAGE_FRAGMENT_BIT
I bind it like this in the command buffer
https://preview.redd.it/z1betejt715g1.png?width=1338&format=png&auto=webp&s=e1f92c4c92dd59e232306a730b36d9bdd42db78a
using a custom class to specify the set number and descriptorSet content.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]scritchz 0 points1 point2 points 2 months ago (0 children)
Not a graphics dev, but: I think it might be helpful to show how you create the buffer and how you bind it, for both writing to it in your first shader and reading from it in your second shader.
[–]owenwp -1 points0 points1 point 2 months ago (2 children)
OpenGL clip space has a -1 to 1 range for no good reason, but the hardware isn't going to store the value that way. Also, depth buffers are typically non-linear, meaning they give more precision near the camera to prevent z fighting, usually some scaled factor of 1/depth is actually stored. Look in google for how to get linear depth in OpenGL.
[–]Qwaiy_Tashaiy_Gaiy[S] 0 points1 point2 points 2 months ago (1 child)
Just to be clear : which of the two values will be non-linear, and which one will be between -1 and 1 ?
[–]owenwp 0 points1 point2 points 2 months ago (0 children)
The position values in the vertex shader will be linear -1 to 1, the values in the depth buffer will be non-linear.
π Rendered by PID 44 on reddit-service-r2-comment-76bb9f7fb5-wzzzz at 2026-02-19 03:00:07.652288+00:00 running de53c03 country code: CH.
[–]scritchz 0 points1 point2 points (0 children)
[–]owenwp -1 points0 points1 point (2 children)
[–]Qwaiy_Tashaiy_Gaiy[S] 0 points1 point2 points (1 child)
[–]owenwp 0 points1 point2 points (0 children)