-
Notifications
You must be signed in to change notification settings - Fork 65
Hlsl bxdfs 4 #916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Hlsl bxdfs 4 #916
Conversation
This file contains hidden or 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
Comment on lines
+21
to
+89
namespace impl | ||
{ | ||
struct sincos_accumulator | ||
{ | ||
using this_t = sincos_accumulator; | ||
|
||
static this_t create() | ||
{ | ||
this_t retval; | ||
retval.tmp0 = 0; | ||
retval.tmp1 = 0; | ||
retval.tmp2 = 0; | ||
retval.tmp3 = 0; | ||
retval.tmp4 = 0; | ||
retval.tmp5 = 0; | ||
return retval; | ||
} | ||
|
||
static this_t create(float cosA, float cosB, float cosC, float sinA, float sinB, float sinC) | ||
{ | ||
this_t retval; | ||
retval.tmp0 = cosA; | ||
retval.tmp1 = cosB; | ||
retval.tmp2 = cosC; | ||
retval.tmp3 = sinA; | ||
retval.tmp4 = sinB; | ||
retval.tmp5 = sinC; | ||
return retval; | ||
} | ||
|
||
float getArccosSumofABC_minus_PI() | ||
{ | ||
const bool AltminusB = tmp0 < (-tmp1); | ||
const float cosSumAB = tmp0 * tmp1 - tmp3 * tmp4; | ||
const bool ABltminusC = cosSumAB < (-tmp2); | ||
const bool ABltC = cosSumAB < tmp2; | ||
// apply triple angle formula | ||
const float absArccosSumABC = acos<float>(clamp<float>(cosSumAB * tmp2 - (tmp0 * tmp4 + tmp3 * tmp1) * tmp5, -1.f, 1.f)); | ||
return ((AltminusB ? ABltC : ABltminusC) ? (-absArccosSumABC) : absArccosSumABC) + ((AltminusB || ABltminusC) ? numbers::pi<float> : (-numbers::pi<float>)); | ||
} | ||
|
||
static void combineCosForSumOfAcos(float cosA, float cosB, float biasA, float biasB, NBL_REF_ARG(float) out0, NBL_REF_ARG(float) out1) | ||
{ | ||
const float bias = biasA + biasB; | ||
const float a = cosA; | ||
const float b = cosB; | ||
const bool reverse = abs<float>(min<float>(a, b)) > max<float>(a, b); | ||
const float c = a * b - sqrt<float>((1.0f - a * a) * (1.0f - b * b)); | ||
|
||
if (reverse) | ||
{ | ||
out0 = -c; | ||
out1 = bias + numbers::pi<float>; | ||
} | ||
else | ||
{ | ||
out0 = c; | ||
out1 = bias; | ||
} | ||
} | ||
|
||
float tmp0; | ||
float tmp1; | ||
float tmp2; | ||
float tmp3; | ||
float tmp4; | ||
float tmp5; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #899 (comment)
Also no need for this to stay in impl
Comment on lines
+57
to
+64
static vector_t3 generate(vector_t3 _sample) | ||
{ | ||
vector_t3 retval = hemisphere_t::generate(_sample.xy); | ||
const bool chooseLower = _sample.z > T(0.5); | ||
retval.z = chooseLower ? (-retval.z) : retval.z; | ||
if (chooseLower) | ||
_sample.z -= T(0.5); | ||
_sample.z *= T(2.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this to work the _sample
needs to be taken as NBL_REF_ARG
This was referenced Sep 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Continuing #811 due to GH UI messing up diffs again
Testing
TODO list: