🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectX9 Texture problem

Started by
4 comments, last by JoeJ 2 years, 3 months ago

Hi, I have a question about DirectX9:
I created a 512x512 shadow texture, and I don't want to render the center part on my Terrain. Can something like this be done? I didn't find anything on the internet about this

Shadow texture example 512x512

(Example as in the picture).
(I want to do this because I want to have a different texture in the center. If I don't cut it, it blends with my second, and I will have texture0 + texture1.)
If I don't blend the textures, I will have texture0 or texture1..

Thanks.

Advertisement

any idea ? xD

I want to cut the center of my texture.

You could apply a pixel shader to your terrain rendering, and discard fragments which end up in the center region.

But why exactly do you want to do this? Maybe there is an overall better solution…

Hi Joe, I have 2 ShadowMaps.

ShadowMap1 = the big texture

ShadowMap2 = the small texture

those textures will follow the main character in my game, rendering the shadow in those squares.

They will be 2048x2048 textures, but because one is smaller and one is larger, the smaller one will be more dense => more quality.

Texture1, the big one, will render near the entire visible map, in distance will not metter that is pixelated.

Texture2, will replace the pixelated texture with a good one.

=> no performance problems

But now, my textures are blending (Texture1+Texture2), I don't want to have the pixelated and the good quality one at the same time in the center. I don't know how to delete the big one, only where my smaller one is (center).

I hope you understand my idea (CS:GO is using that concept)

eduard_ionut said:
But now, my textures are blending (Texture1+Texture2), I don't want to have the pixelated and the good quality one at the same time in the center. I don't know how to delete the big one, only where my smaller one is (center). I hope you understand my idea (CS:GO is using that concept)

Ah yes. So you want ‘cascaded shadow maps’. Usually that's implemented so the larger maps miss a corner, not the center. This works because they are placed considering the frustum like so:

I've never done this, but afaik people use at least 3 cascades and often more. This implies they select from a set of SMs according to distance. So no discarding or blending on texture level is needed, instead you can blend two fetched results from two maps to hide the seam of switching detail.

In this OpenGL tutorial they use Array Textures. https://learnopengl.com/Guest-Articles/2021/CSM
I guess DX9 has this too, but not sure. Using 2, 3 or more textures and selecting them with branches would also work.
DX9 tutorials should be still to find, as this always was a difficult topic with people having issues like from swimming shadows, caused from not quantizing the SMs movement to their texel grids.

Discarding fragments which are never fetched would be still an performance optimization idea. But that's not necessary to make it work.
Usually the main optimization is to update only one or two of those textures per frame. Cutting edge stuff even reprojects SMs for frames lacking the update.

This topic is closed to new replies.

Advertisement