Quantcast
Channel: Questions in topic: "hlsl"
Viewing all articles
Browse latest Browse all 206

Bitwise operations in hlsl, is there an alternative method?

$
0
0
So, i'm writing a shader, and part of this shader involved IBL. I'm trying to find a good way to sample from a hemisphere (cubemap) using importance sampling, and part of that involves using the Hammersley Point method, referenced here: http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html the code in question is this, which is GLSL: float radicalInverse_VdC(uint bits) { bits = (bits << 16u) | (bits >> 16u); bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); return float(bits) * 2.3283064365386963e-10; // / 0x100000000 } //The ith point xi is then computed by vec2 Hammersley(uint i, uint N) { return vec2(float(i)/float(N), radicalInverse_VdC(i)); } the problem is, the rest of the shader is written in HLSL, and i don't want to rewrite it in GLSL. since bitwise operations are a shader model 4.0 and above feature, i'm wondering why i can't just do it in HLSL anyway. but that's not really the question here (although, if anyone can answer that would be great!). the question is - is there an alternate method of producing the same results? cheers, Lee.

Viewing all articles
Browse latest Browse all 206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>