So, I’m not sure how to go about extending the source to achieve this. I’m trying to implement a blocker search in the lighting shader for the shadow mapping, and my understanding is that I will need 2 sampler states, the traditional comparison state for analyzing depth and also a normal sampler state for reading the values to determine the blockers.
For the sake of api consistency (I’m assuming), the sampler states are created in the directx11 implementation per texture, 1 texture, 1 sampler state, bound equally to the 16 slots. I’m assuming to create a similar environment to dx9, where this was bundled together as the texture item.
Is there anyway I can create 2 states during the shadow pass, registering the 2nd state somewhere I will presume to be empty? I’ve tried various methods, and obviously I can get the sampler description created when a shadow texture is present, however when I attempt to interject the state somewhere along with original shadow sampler state using PSSetSamplers it always crashes urho. Thread attempting to read write a resource it doesn’t have access to. It compiles tho.
I assume I can create an additional texture just for the state, which seems wasteful, since I just need an additional state. And the renderer already has a dummy color texture setup for certain scenarios, I could probably extend this out to work. But I’d rather not, if I don’t have to.
I’ve tried accessing several of the other sampler state registers as well, but the ones I’ve tried give me an error of overlapping semantics not yet defined, I’m assuming they are not registered during that pass, which is why I think interjecting another sampler state in there should be possible.
Right now, I’ve scrapped the comparison state, and just perform a manual comparison in the shader with texture lookup, but I’d like the benefits of speed and texture filtering from the comparison state.
My use case doesn’t need compatibility with the other graphics apis, so I’ve thought about redesigning the entire way the states are registered to be more directx 11-esque, creating a new state for every texture when probably a huge majority of them are identical seems a bit redundant. And then I can possibly unbind them from being locked state to texture.
But any ideas on how to move forward with this would be appreciated.
Thanks!
Edit: I managed to get the sampler state added and registered without crashing, altho I would wager its far from safely handled. It works for this specific use case. However now I’m seeing that any sampler state that isn’t explicitly registered with the same texture unit as the as the texture itself does not work correctly in the shaders. I’m not sure what I’m not understanding here… I’ve set the sampler state descriptions to be identical for everything, hard coded values. However even with this, if I try to sample the diffuse texture with the normal map sampler state, I get nothing but black diffuse color. If I sample with the diffuse sampler state, it’s correct. If i have the texture hold 2 sampler states, but set the 2nd to a register different from the tu index, same thing. There are no errors, it runs. I’ve tried removing the calls in implementation where it sets the sampler states to null pointers, I’m not sure this really does anything cuz the sampler state references are tied to the texture itself.
Any ideas?