Welcome, Guest.
Username: Password: Remember me

TOPIC: ReShade FX bitwise operations

ReShade FX bitwise operations 4 years 2 days ago #1

Be aware, this post is intended for shader developers using the ReShade FX shader programming language.

It is probably relativly unknown, but ReShade FX supports bitwise integer operations even on targets which don't have native support for them (like shader model 3). They are emulated there. As this was requested, here is a list of high level code transformations (in pseudocode) ReShade applies for that emulation. It's no rocket science, but still useful to know and could provide as base for optimizations.
!a         =>     (4294967295 - a)

a & b      =>     if (is_pow2(b))          =>     (((a / b) % 2) * b)
                  else if (is_pow2(b + 1)) =>     ((b + 1) * frac(a / (b + 1)))
                  else                     =>     error

a | b      =>     error

a ^ b      =>     error

a << b     =>     (a * exp2(b))

a >> b     =>     (floor(a / exp2(b)))
Cheers, crosire =)
Last Edit: 4 years 2 days ago by crosire.
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick, Marty McFly, GroinShooter, Quentin-Tarantino

ReShade FX bitwise operations 3 years 11 months ago #2

  • Wicked Sick
  • Wicked Sick's Avatar
  • Offline
  • Die young or suffer (Forgive my poor English)
You got me at "optimizations" ^^
Finding relief somewhere between a tree's branch and its shade.
The administrator has disabled public write access.