[SOLVED] Mipmaps and tex2D-functions

  • Daodan
  • Topic Author
More
6 years 1 week ago - 6 years 1 week ago #1 by Daodan [SOLVED] Mipmaps and tex2D-functions was created by Daodan
Hi,

i'm having a couple of issues with the tex2D-functions when using mipmaps.

First, when using tex2D() with a biased ("MipLODBias = xyz") sampler the resulting mipmap differs between d3d9 and d3d11. With the exact same shader, the mipmap in d3d9 has a considerably lower resolution than in d3d11 (see topmost images in picture).

Second, the tex2Dfetch() function. According to the reference this function takes an int4 as second parameter, but what values do i pass to these 4 ints?
Is the following assumption (as i assumed it in the test shader below) correct?

tex2Dfetch(sampler, int4(position.xy, <unused/doesn't matter>, miplevel))

Now, there are two problems:
1) OpenGL throws an error: implicit cast from "ivec4" to "ivec2"; incompatible type for parameter #2
2) In d3d9 tex2Dfetch behaves really weird:
If you pass the correct int4 as parameter #2 the screen just gets one uniform color.
If you pass an float4 it looks the same as tex2Dlod.


Here's the image that illustrates the issues:
I guess the the left and right image in every row should look the same?
Warning: Spoiler!


And the shader:
Warning: Spoiler!



Maybe i did someting wrong and someone can clear things up. Thanks.
Last edit: 6 years 1 week ago by Daodan.

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 1 week ago #2 by crosire Replied by crosire on topic Mipmaps and tex2D-functions
D3D9 has no concept to limit mipmap generation to a fixed amount of levels if automatic mipmap generation is used. The "MipLevels" option is effectivly ignored. That's why you see a lower resolution in your first image:
tex2D() accesses mip level at index 0 + lod bias 5 = 5. Keep in mind that the index is zero based, so this actually accesses the sixth image in the mipmap chain. But in D3D11 only 5 mip levels exist (since you created the texture with "MipLevels = 5"), so it's clamped down and uses the mip map at index 4 instead. In D3D9 there is no limit, so it can read the mip map at index 5, which is obviously half the resolution of the one at index 4, hence the blurrier result.

Your assumption on tex2Dfetch is correct. The input takes the following ranges:
x : [0, texture width)
y : [0, texture height)
z : ignored
w: [0, texture miplevels)

1) Is a bug. Fixed in github.com/crosire/reshade/commit/2f6bed...4cce768a8462eb2b8725 .
2) That's a bug too. Fixed in github.com/crosire/reshade/commit/d13ab1...c3d525c169143df2a5d8 .
The following user(s) said Thank You: Daodan

Please Log in or Create an account to join the conversation.

  • Daodan
  • Topic Author
More
6 years 1 week ago #3 by Daodan Replied by Daodan on topic Mipmaps and tex2D-functions
Thanks alot!

I have one additional observation/question on the clamped mip map index in D3D11:
Is the mip level always clamped when accessing mipmaps?
If you pass a mip level index to tex2Dfetch that exceeds the amount of mip levels (for example "MipLevels=3" and "coords.w=3") the result doesn't stay at "coords.w=2", but just vanishes (black screen).

Is there a release cycle for ReShade, or do your release it when there are enough bugs fixed/features added?
I guess, for the fun of it, i download Visual Studio and build ReShade myself...

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 1 week ago #4 by crosire Replied by crosire on topic Mipmaps and tex2D-functions
I usually release when I feel like enough stuff happened to warrant one. Those two fixes were released in v3.2.1 already though.

Mip level access is clamped for everything but tex2Dfetch, since that intrinsic should most of the time resolve to a direct memory load without any side-effects.

Please Log in or Create an account to join the conversation.

  • Daodan
  • Topic Author
More
6 years 1 week ago #5 by Daodan Replied by Daodan on topic Mipmaps and tex2D-functions
Ok. Thanks for the info.
I wasn't aware of the new release.

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 1 week ago - 6 years 1 week ago #6 by crosire Replied by crosire on topic Mipmaps and tex2D-functions
ReShade now checks for updates on startup, so from now on it's easier to spot ;)
Last edit: 6 years 1 week ago by crosire.

Please Log in or Create an account to join the conversation.

  • mindu
More
5 years 11 months ago #7 by mindu Replied by mindu on topic Mipmaps and tex2D-functions

crosire wrote: ReShade now checks for updates on startup, so from now on it's easier to spot ;)

is there any way to disable this check, please?

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.