Welcome, Guest.
Username: Password: Remember me

TOPIC: Use uv or 0 for 1x1 texture reads?

Use uv or 0 for 1x1 texture reads? 3 months 1 week ago #1

Is there any notable difference between using regular coordinates or 0.0 in tex2D() when reading from a 1x1 texture?
I had heard some time ago that simple uv reads were more optimized than offset coordinates. Does that also apply to static coordinates?

And maybe someone will suggest tex2Dfetch(), that has never worked with me, throws errors on some compilers.
Likes to reinvent the wheel.

My shaders repository: www.github.com/luluco250/FXShaders
The administrator has disabled public write access.

Use uv or 0 for 1x1 texture reads? 3 months 1 week ago #2

iirc independent texture reads (constant value as offset) are almost for free. You can try this out by reading a texture a lot of times with a loop, a) only computing the offset with the loop variable (then you have fixed coordinates) and b) by adding texcoord to it so it's dependant. Compare performance of both.
The administrator has disabled public write access.

Use uv or 0 for 1x1 texture reads? 3 months 1 week ago #3

Well after testing it there seems to be absolutely no difference, at least not in DX9. I guess I'll go with 0 since it's quicker to write.
Likes to reinvent the wheel.

My shaders repository: www.github.com/luluco250/FXShaders
The administrator has disabled public write access.

Use uv or 0 for 1x1 texture reads? 3 months 1 week ago #4

tex2Dfetch would technically the best solution, since it skips interpolation, which has no effect on a 1x1 texture (only in Dx10+ and OpenGL). What sort of errors do you get with it.
Cheers, crosire =)
The administrator has disabled public write access.

Use uv or 0 for 1x1 texture reads? 3 months 1 week ago #5

crosire wrote:
tex2Dfetch would technically the best solution, since it skips interpolation, which has no effect on a 1x1 texture (only in Dx10+ and OpenGL). What sort of errors do you get with it.

Well ages ago when I tried to use it I got strange compiler errors, specially under OpenGL. Testing it now it works as long as the second argument is an explicit int4, if I just write 0 it doesn't work, complaining about "incorrect number of arguments to numeric-type constructor", but (int4)0 does, which is odd. This is happening under DX9, which according to you shouldn't have any effect anyway.
Likes to reinvent the wheel.

My shaders repository: www.github.com/luluco250/FXShaders
Last Edit: 3 months 1 week ago by luluco250.
The administrator has disabled public write access.

Use uv or 0 for 1x1 texture reads? 3 months 16 hours ago #6

tex2Dfetch works correctly in OpenGL now.
Cheers, crosire =)
The administrator has disabled public write access.