Hi. I’m recently trying to build upon the SimplePBR render pipeline and am trying to implement point lights with shadows. I’ve looked through many forums and even checked GitHub where someone had the same issue but is wasn’t resolved.
I’ve gotten up to a point where i get this error:
:display:gsg:glgsg(warning): Program undefined behavior warning: The current GL state uses a sampler (1) that has depth comparisons disabled, with a texture object (0) with a non-depth format, by a shader that samples it with a shadow sampler. This will result in undefined behavior.
I’m not actually sure if it’s even possible to combine samplerCubeShadow shadowCubeMap; and sampler2DShadow shadowMap; in the same structure but it gave me no error when I did when I removed the “point_shadow_caster_contrib” function.
As described in the linked thread, Panda doesn’t enable shadow filtering on the cube map texture by default, but your shader is using a shadow sampler. Those two settings need to match.
Set this in Config.prc:
shadow-cube-map-filter true
Alternative is to change your shader to just use samplerCube and do the shadow comparison yourself.
I think the principles of the shader data generator are a bit clunky. It would be nice to have an analyzer that, in the context of shaders, would simply add data from the scene, and the user himself would fill in the structures he needed in the shader. For example, the analyzer would collect all the lighting nodes in a list.
I mean, this is how you can achieve the shader data generator and provide custom shaders with data. For example, you can use the cube map generation method directly in the geometric shader.
ERROR::display:gsg:glgsg(error): p3d_LightSource[].shadowMapCube should be float or vec :display:gsg:glgsg(error): p3d_LightSource[].shadowMapCube should be float or vec :display:gsg:glgsg(error): p3d_LightSource[].shadowMapCube should be float or vec :display:gsg:glgsg(error): p3d_LightSource[].shadowMapCube should be float or vec :display:gsg:glgsg(error): p3d_LightSource[].shadowMapCube should be float or vec :display:gsg:glgsg(error): p3d_LightSource[].shadowMapCube should be float or vec :display:gsg:glgsg(error): p3d_LightSource[].shadowMapCube should be float or vec :display:gsg:glgsg(error): p3d_LightSource[].shadowMapCube should be float or vec :display:gsg:glgsg(error): GL_INVALID_OPERATION error generated. State(s) are invalid: program texture usage.
code for calculation was taken from the mentioned forums posts:
As you say, they cannot coexist unfortunately. You get that error because shadowMapCube is not a recognised name. It must be named shadowMap
The way around this is to pass the point light as a separate variable rather than via the setLight mechanism (which reads them into p3d_LightSource array). You can just pass the PointLight NodePath directly to a named shader input with setShaderInput, and use a different struct definition with cube shadow map to read in that shader input in the shader.