VOGONS


First post, by Franky212

User metadata
Rank Newbie
Rank
Newbie

Hi Dege, thanks for reading this post and also for your hard work. I ran into a problem. I'm making mods for two games that have a large open world but low draw distance. To create new maps for these games, I plan to increase the draw distance. But I can't disable LOD textures. I need to improve the quality of the textures away from the camera so that the quality of the textures is the same at any distance. And also I need to turn off the fog.
* I have tried setting HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{5BC4AFCA-C164-4109-83E8-062D382B5F97}\0000\UMD\LodAdj (String). But it doesn't work with dgVoodoo, only with DirectX 9, and it can only degrade the quality of far textures, not improve (weird behaviour).
* I tried to change the Lod Bias in the Radeon Pro program, but this program can only worsen the texture quality, not improve it.
* I did not find any settings in the game at all that could improve the quality of objects away from the camera.
* In all cases, I configured dgVoodoo, and enabled the setting DisableMipmapping = true. But it did not give any effect, the quality of the textures still deteriorates when I move away from them. The textures in my game are created using CreateSurface in DirectDraw. Next, rendering takes place in DirectX 7.
I'm asking for your help, please make changes to the dgVoodoo code, and disable the following features, or add a setting to disable features.
DirectDraw and D3DIMM:
D3DRENDERSTATE_FOGENABLE - disable
D3DPRASTERCAPS_MIPMAPLODBIAS - always max quality
D3DTSS_MIPMAPLODBIAS - always max quality
DirectX 7, 8, 9, 10 and 11:
Change all other Lod Bias settings so that there is always the maximum texture quality.

I want to add that in DirectX 7 there is a DirectDrawSurface7.SetLOD(long) function, you can take it as a sample for disabling LOD.

To better understand this issue, I recorded debug information using the dgVoodoo debug layer. When creating the log, I first placed an object on a surface in the game, waited 30 seconds, and then moved away from the object to change the quality of the textures. I couldn't find any mention of LOD and mipmap in the debug info.

Filename
soa_dgvoodoo_debug.log.zip
File size
3.28 MiB
Downloads
41 downloads
File license
Public domain

Microsoft DirectX 7.0 Documentation and SDK

Reply 2 of 4, by Franky212

User metadata
Rank Newbie
Rank
Newbie
Dege wrote on 2023-08-07, 16:43:

I think I could build such a version for you but I don't want to put it into the releases along with an option.

It would be great if you can do it. Any help in this matter is welcomed by me. You are the author, so you can decide for yourself which features can and cannot be published.

Reply 3 of 4, by Dege

User metadata
Rank l33t
Rank
l33t

Looking into this again:

There is no mention of LOD and mipmap in the log because the game probably just creates texture mipmaps that are logged like this:

[dgVoodoo] INFO: DirectDraw (03180188)::CreateSurface: Texture is created, head DirectDrawSurface (088F0268).	

Mipmaps are complex surface chains, only the head object is dumped in the log but no any info about how long the chain is (how many mipmaps). LOD bias must be the default 0 on the d3d device, that's why no mention about LOD.
DirectDrawSurface7::SetLOD seems to be only a hint to the texture manager but has no effect on 3D rendering:

Applications can call this method only for managed textures (those that were created with the DDSCAPS2_TEXTUREMANAGE flag). Calling this method on a nonmanaged texture causes the method to fail and return DDERR_INVALIDOBJECT.

This method communicates to the Direct3D texture manager the most detailed mipmap in this chain that it should load into local video memory. For example, in a five-level mipmap chain, setting dwMaxLOD to 2 indicates that the texture manager should load only mipmap levels 2 through 4 into local video memory at any given time. Likewise, if the most detailed mipmap in the chain has the dimensions 256×256, setting the maximum level to 2 means that the largest mipmap ever present in video memory has dimensions 64×64.

Max mipmap level (0 is the most detailed) can be set by D3DTSS_MAXMIPLEVEL, to disable lower size mipmap elements, but this is also unused in the game, I couldn't find it in the log.

What is weird for me why option DisableMipmapping does not work. It should, I've just tried it.

Reply 4 of 4, by Franky212

User metadata
Rank Newbie
Rank
Newbie
Dege wrote on 2023-08-15, 18:52:
Looking into this again: […]
Show full quote

Looking into this again:

There is no mention of LOD and mipmap in the log because the game probably just creates texture mipmaps that are logged like this:

[dgVoodoo] INFO: DirectDraw (03180188)::CreateSurface: Texture is created, head DirectDrawSurface (088F0268).	

Mipmaps are complex surface chains, only the head object is dumped in the log but no any info about how long the chain is (how many mipmaps). LOD bias must be the default 0 on the d3d device, that's why no mention about LOD.
DirectDrawSurface7::SetLOD seems to be only a hint to the texture manager but has no effect on 3D rendering:

Applications can call this method only for managed textures (those that were created with the DDSCAPS2_TEXTUREMANAGE flag). Calling this method on a nonmanaged texture causes the method to fail and return DDERR_INVALIDOBJECT.

This method communicates to the Direct3D texture manager the most detailed mipmap in this chain that it should load into local video memory. For example, in a five-level mipmap chain, setting dwMaxLOD to 2 indicates that the texture manager should load only mipmap levels 2 through 4 into local video memory at any given time. Likewise, if the most detailed mipmap in the chain has the dimensions 256×256, setting the maximum level to 2 means that the largest mipmap ever present in video memory has dimensions 64×64.

Max mipmap level (0 is the most detailed) can be set by D3DTSS_MAXMIPLEVEL, to disable lower size mipmap elements, but this is also unused in the game, I couldn't find it in the log.

What is weird for me why option DisableMipmapping does not work. It should, I've just tried it.

Hello. Thank you for your attention to this issue. I also tried to solve it issue for 2 weeks in a row, I found a function through IDA Pro that creates textures on the ground surface, but there were no hints of LODs and Mipmaps. Only such a hint "Turn down the landscape detail level. detail: %f patches: %d max". I used to think that this function only affects the detail of the shape of the objects, but not the texture. But now it is clear that most likely the game uses a self-implemented LOD system. But I still haven't been able to find a place in the code that creates low quality textures. The only thing I noticed is that the texture resolution is always 256x256. The further I move away from the texture, the more adjacent textures are merged into one texture with a resolution of 256x256, the objects also become merged. This happens automatically until the entire landscape becomes a single blurry texture, a huge object.

I think it's worth stopping trying to look for standard implementations of LODs (if you could not find them). There are only 2 ways to solve the problem:
1st way - reverse engineering the game, but I still haven't found the right place in the code to disable the merging of adjacent textures into one.
2nd way - a complex Python script that will automatically move the camera to trick the game and make it draw each segment at the same time. This method turned out to be the only one that worked.