Hi, I’m currently developing some post processing shaders that require a sampler2DShadowArray to be accessed as a normal sampler2DArray so I can get the raw depth values. My forward pass shader requires the depth comparison texture while my post processing shader requires the depth values and not the comparison. Is there any way to accomplish this. Currently I’m having undefined behaviour where I can just force the bind with depth comparison mode on my desktop with it working, but this fails when on other driver like my laptop.
Is there a way to dual bind possibly? or maybe something like switching the component type before setting the shader input?
Oh wait never mind. The smart developers are one step ahead and have already implemented this feature with a shader input Option. with anyone that has the same issue you can pass a sampler state along with a texture as so:
self.directionallight_shadow_array = p3d.Texture('directional shadow texture')
self.directionallight_shadow_array.setup_2d_texture_array(
application.max_shadow_resolution,
application.max_shadow_resolution,
self.MAX_DIRECTIONALLIGHTS * (application.cascades_per_light+1) + 1,
p3d.Texture.T_float,
p3d.Texture.FDepthComponent
)
self.directionallight_shadow_array.setMagfilter(p3d.Texture.FTLinear)
self.directionallight_shadow_array.setMinfilter(p3d.Texture.FTLinear)
self.directionallight_shadow_array.setWrapU(p3d.SamplerState.WMClamp)
self.directionallight_shadow_array.setWrapV(p3d.SamplerState.WMClamp)
self.raw_depth_sampler_state = p3d.SamplerState()
self.raw_depth_sampler_state.setMinfilter(p3d.Texture.FTShadow)
self.raw_depth_sampler_state.setMagfilter(p3d.Texture.FTShadow)
self.raw_depth_sampler_state.setWrapU(p3d.SamplerState.WMClamp)
self.raw_depth_sampler_state.setWrapV(p3d.SamplerState.WMClamp)
'''
I chose to use a ShaderInput Variable for cleanliness in case I want to pass this to some other shader later
'''
self.directional_light_shadow_shader_input = p3d.ShaderInput("DirectionalLightShadows", self.directionallight_shadow_array, self.raw_depth_sampler_state)
render.setShaderInput(self.directional_light_shadow_shader_input)
Where the directional light texture is set as a normal sampler and I feed the texture with depth comparison mode to the render pipeline. you can have it in whatever order you want (like setting the texture up with FTShadow and making a Sampler with FTLinear).
1 Like