when do we create a separate renderpass in vulkan for same scene? if we have to implement shadow mapping, can't we create 2 subpasses and FBO with 3 attachments first being for depth pass and rest of the 2 for normal scene rendering? I saw some tutorials which are using separate renderpass for shadow mapping, but i couldn't understand why?
1 Answer
You cannot sample arbitrarily from an input attachment. This means that in the fragment shader you can only get the sample values from the input attachment corresponding to the fragment you are shading.
If you want to sample from another location you cannot use it as an attachment inside the same renderpass.
2 Comments
debonair
so the only case where we can use sub-passes are deferred shading? we cann't even use it for post processing effect?
Sascha Willems
As long as the post processing does not sample from a differing (fragment) position you can still use sub-passes, but if you need to sample from neighboring (or arbitrary) fragments then no, you can't use sub-passes for that. But there are several use-cases other than deferred shading that sub-passes can be used for, e.g. multi-pass stuff like OIT, passes that read depth for comparison, etc.