Welcome, Guest.
Username: Password: Remember me

TOPIC: [SOLVED] Mipmaps and tex2D-functions

[SOLVED] Mipmaps and tex2D-functions 7 months 3 days ago #1

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! [ Click to expand ]


And the shader:
Warning: Spoiler! [ Click to expand ]



Maybe i did someting wrong and someone can clear things up. Thanks.
Last Edit: 7 months 3 days ago by Daodan.
The administrator has disabled public write access.

Mipmaps and tex2D-functions 7 months 3 days ago #2

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.
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Daodan

Mipmaps and tex2D-functions 7 months 3 days ago #3

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...
The administrator has disabled public write access.

Mipmaps and tex2D-functions 7 months 2 days ago #4

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.
Cheers, crosire =)
The administrator has disabled public write access.

Mipmaps and tex2D-functions 7 months 2 days ago #5

Ok. Thanks for the info.
I wasn't aware of the new release.
The administrator has disabled public write access.

Mipmaps and tex2D-functions 7 months 2 days ago #6

ReShade now checks for updates on startup, so from now on it's easier to spot ;)
Cheers, crosire =)
Last Edit: 7 months 2 days ago by crosire.
The administrator has disabled public write access.

Mipmaps and tex2D-functions 6 months 3 weeks ago #7

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?
The administrator has disabled public write access.