Last active
December 18, 2015 13:59
-
-
Save selfshadow/5794173 to your computer and use it in GitHub Desktop.
Quick Beckmann HLSL test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float Beckmann1(float3 n, float3 h, float m) | |
{ | |
float ndoth = saturate(dot(n, h)); | |
float cos2 = ndoth*ndoth; | |
return exp((cos2 - 1)/(cos2*m*m)); | |
} | |
// mul r0.x, cb0[2].x, cb0[2].x | |
// dp3_sat r0.y, cb0[0].xyzx, cb0[1].xyzx | |
// mul r0.z, r0.y, r0.y | |
// mad r0.y, r0.y, r0.y, l(-1.000000) | |
// mul r0.x, r0.z, r0.x | |
// div r0.x, r0.y, r0.x | |
// mul r0.x, r0.x, l(1.442695) | |
// exp o0.x, r0.x | |
float Beckmann2(float3 n, float3 h, float m) | |
{ | |
float ndoth = saturate(dot(n, h)); | |
float cos2 = ndoth*ndoth; | |
return exp((1 - 1/cos2)/(m*m)); | |
} | |
// dp3_sat r0.x, cb0[0].xyzx, cb0[1].xyzx | |
// mul r0.x, r0.x, r0.x | |
// div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x | |
// add r0.x, -r0.x, l(1.000000) | |
// mul r0.y, cb0[2].x, cb0[2].x | |
// div r0.x, r0.x, r0.y | |
// mul r0.x, r0.x, l(1.442695) | |
// exp o0.x, r0.x | |
float Beckmann3(float3 n, float3 h, float m) | |
{ | |
float ndoth = saturate(dot(n, h)); | |
float cos2 = ndoth*ndoth; | |
float d = ndoth*m; | |
return exp((cos2 - 1)/(d*d)); | |
} | |
// dp3_sat r0.x, cb0[0].xyzx, cb0[1].xyzx | |
// mul r0.y, r0.x, cb0[2].x | |
// mad r0.x, r0.x, r0.x, l(-1.000000) | |
// mul r0.y, r0.y, r0.y | |
// div r0.x, r0.x, r0.y | |
// mul r0.x, r0.x, l(1.442695) | |
// exp o0.x, r0.x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment