Skip to content

Commit

Permalink
Merge pull request #1687 from zenustech/hairScattering
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
zhxx1987 authored Jan 3, 2024
2 parents 6d2fd20 + 73f018a commit 62ff774
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions zenovis/xinxinoptix/DeflMatShader.cu
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ extern "C" __global__ void __closesthit__radiance()
ShadowPRD shadowPRD {};
shadowPRD.seed = prd->seed;
shadowPRD.attanuation = make_float3(1.0f, 1.0f, 1.0f);
shadowPRD.nonThinTransHit = (mats.thin == false && mats.specTrans > 0) ? 1 : 0;
shadowPRD.nonThinTransHit = (mats.thin < 0.5f && mats.specTrans > 0) ? 1 : 0;

shadowPRD.origin = rtgems::offset_ray(P, prd->geometryNormal); // camera space
auto shadingP = rtgems::offset_ray(P + params.cam.eye, prd->geometryNormal); // world space
Expand All @@ -884,7 +884,7 @@ extern "C" __global__ void __closesthit__radiance()
prd->done = true;
}

if(mats.thin<0.5f || mats.doubleSide<0.5f){
if(mats.thin<0.5f && mats.doubleSide<0.5f){
prd->origin = rtgems::offset_ray(P, (next_ray_is_going_inside)? -prd->geometryNormal : prd->geometryNormal);
}
else {
Expand Down
10 changes: 5 additions & 5 deletions zenovis/xinxinoptix/DisneyBSDF.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ namespace DisneyBSDF{
{

vec3 d = BRDFBasics::EvalDisneyDiffuse(thin? mat.basecolor:mix(mat.basecolor,mat.sssColor,mat.subsurface), mat.subsurface, mat.roughness, mat.sheen,
Csheen, wo, wi, wm, tmpPdf) * dielectricWt * illum;
Csheen, wo, wi, wm, tmpPdf) * dielectricWt;
dterm = dterm + d;
f = f + d;
fPdf += tmpPdf * diffPr ;
Expand All @@ -403,7 +403,7 @@ namespace DisneyBSDF{
float ax, ay;
BRDFBasics::CalculateAnisotropicParams(mat.roughness,mat.anisotropic,ax,ay);
vec3 s = BRDFBasics::EvalMicrofacetReflection(ax, ay, wo, wi, wm,
mix(Cspec0, vec3(1.0f), F) * mat.specular, tmpPdf) * dielectricWt * illum;
mix(Cspec0, vec3(1.0f), F) * mat.specular, tmpPdf) * dielectricWt;
sterm = sterm + s;
f = f + s;
fPdf += tmpPdf * dielectricPr;
Expand All @@ -413,7 +413,7 @@ namespace DisneyBSDF{
vec3 F = mix(mat.basecolor, vec3(1.0), BRDFBasics::SchlickWeight(HoV));
float ax, ay;
BRDFBasics::CalculateAnisotropicParams(mat.roughness,mat.anisotropic,ax,ay);
vec3 s = BRDFBasics::EvalMicrofacetReflection(ax, ay, wo, wi, wm, F, tmpPdf) * metalWt * illum;
vec3 s = BRDFBasics::EvalMicrofacetReflection(ax, ay, wo, wi, wm, F, tmpPdf) * metalWt;
sterm = sterm + s;
f = f + s;
fPdf += tmpPdf * metalPr;
Expand Down Expand Up @@ -451,7 +451,7 @@ namespace DisneyBSDF{
wo, wi, wm,
vec3(F), tmpPdf);

vec3 t = brdf * glassWt * illum;
vec3 t = brdf * glassWt;
tterm = tterm + t;
f = f + t;
fPdf += tmpPdf * glassPr * (1.0 - F);
Expand All @@ -464,7 +464,7 @@ namespace DisneyBSDF{
{
vec3 wm = normalize(wi + wo);
vec3 s = BRDFBasics::EvalClearcoat(mat.clearcoatRoughness, wo, wi,
wm, tmpPdf) * 0.25 * mat.clearcoat * illum;
wm, tmpPdf) * 0.25 * mat.clearcoat;
sterm = sterm + s;
f = f + s;
fPdf += tmpPdf * clearCtPr;
Expand Down
12 changes: 6 additions & 6 deletions zenovis/xinxinoptix/TraceStuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ struct RadiancePRD
}

void offsetUpdateRay(float3& P, float3 new_dir) {
double x = (double)(P.x) - (double)(this->camPos.x);
double y = (double)(P.y) - (double)(this->camPos.y);
double z = (double)(P.z) - (double)(this->camPos.z);
double x = (double)(P.x);
double y = (double)(P.y);
double z = (double)(P.z);
auto beforeOffset = make_float3(x, y, z);
//this->origin = P;
this->direction = new_dir;
offsetRay(beforeOffset, new_dir);
double x2 = (double)(beforeOffset.x) + (double)(this->camPos.x);
double y2 = (double)(beforeOffset.y) + (double)(this->camPos.y);
double z2 = (double)(beforeOffset.z) + (double)(this->camPos.z);
double x2 = (double)(beforeOffset.x);
double y2 = (double)(beforeOffset.y);
double z2 = (double)(beforeOffset.z);
this->origin = make_float3(x2, y2, z2);
}

Expand Down

0 comments on commit 62ff774

Please sign in to comment.