diff --git a/zeno/src/nodes/mtl/ShaderFinalize.cpp b/zeno/src/nodes/mtl/ShaderFinalize.cpp index d76ffd260a..e25749a4fc 100644 --- a/zeno/src/nodes/mtl/ShaderFinalize.cpp +++ b/zeno/src/nodes/mtl/ShaderFinalize.cpp @@ -55,9 +55,10 @@ struct ShaderFinalize : INode { {1, "mat_specTrans"}, {3, "mat_transColor"}, - {1, "mat_clarity"}, - {3, "mat_transParam"}, - {1, "mat_transDepth"}, + {3, "mat_transTint"}, + {1, "mat_transTintDepth"}, + {1, "mat_transDistance"}, + {3, "mat_transScatterColor"}, {1, "mat_ior"}, {1, "mat_flatness"}, @@ -107,9 +108,10 @@ struct ShaderFinalize : INode { get_input("specTrans", std::make_shared(float(0.0f))), get_input("transColor", std::make_shared(vec3f(1.0f))), - get_input("clarity", std::make_shared(float(1.0f))), - get_input("transParam", std::make_shared(vec3f(1.0f))), - get_input("transDepth", std::make_shared(float(1.0f))), + get_input("transTint", std::make_shared(vec3f(1.0f))), + get_input("transTintDepth", std::make_shared(float(1.0f))), + get_input("transDistance", std::make_shared(float(1.0f))), + get_input("transScatterColor", std::make_shared(vec3f(1.0f))), get_input("ior", std::make_shared(float(1.5f))), get_input("flatness", std::make_shared(float(0.0f))), @@ -276,9 +278,10 @@ ZENDEFNODE(ShaderFinalize, { {"float", "specTrans", "0.0"}, {"vec3f", "transColor", "1.0,1.0,1.0"}, - {"float", "clarity", "0.0"}, - {"vec3f", "transParam", "1.0,1.0,1.0"}, - {"float", "transDepth", "0.0"}, + {"vec3f", "transTint", "1.0,1.0,1.0"}, + {"float", "transTintDepth", "0.0"}, + {"float", "transDistance", "10.0"}, + {"vec3f", "transScatterColor", "1.0,1.0,1.0"}, {"float", "ior", "1.5"}, {"float", "flatness", "0.0"}, diff --git a/zenovis/xinxinoptix/DeflMatShader.cu b/zenovis/xinxinoptix/DeflMatShader.cu index 5a12e53a7a..8a9f79413d 100644 --- a/zenovis/xinxinoptix/DeflMatShader.cu +++ b/zenovis/xinxinoptix/DeflMatShader.cu @@ -72,9 +72,10 @@ static __inline__ __device__ MatOutput evalMat(cudaTextureObject_t zenotex[], fl float mat_specTrans = 0.0f; vec3 mat_transColor = vec3(1.0f,1.0f,1.0f); - float mat_clarity = 0.0f; - vec3 mat_transParam = vec3(1.0f,1.0f,1.0f); - float mat_transDepth = 0.0f; + vec3 mat_transTint = vec3(1.0f,1.0f,1.0f); + float mat_transTintDepth = 0.0f; + float mat_transDistance = 0.0f; + vec3 mat_transScatterColor = vec3(1.0f,1.0f,1.0f); float mat_ior = 1.0f; float mat_flatness = 0.0f; @@ -123,9 +124,10 @@ static __inline__ __device__ MatOutput evalMat(cudaTextureObject_t zenotex[], fl mats.specTrans = clamp(mat_specTrans, 0.0f, 1.0f); mats.transColor = mat_transColor; - mats.clarity = clamp(mat_clarity,0.0f,1.0f); - mats.transParam = mat_transParam; - mats.transDepth = max(0.0f,mat_transDepth); + mats.transTint = mat_transTint; + mats.transTintDepth = max(0.0f,mat_transTintDepth); + mats.transDistance = max(mat_transDistance,0.1f); + mats.transScatterColor = mat_transScatterColor; mats.ior = max(0.0f,mat_ior); @@ -662,7 +664,7 @@ extern "C" __global__ void __closesthit__radiance() bool next_ray_is_going_inside = false; mats.sssParam = mats.subsurface>0 ? mats.subsurface*mats.sssParam : mats.sssParam; - mats.subsurface = mats.subsurface>0 ? 1 : 0; + //mats.subsurface = mats.subsurface>0 ? 1 : 0; /* MODME */ @@ -912,7 +914,7 @@ extern "C" __global__ void __closesthit__radiance() vec3 channelPDF = vec3(1.0f/3.0f); prd->pushMat(extinction); prd->isSS = false; - prd->scatterDistance = 1000.0f * mats.clarity * mats.clarity; + prd->scatterDistance = mats.transDistance; prd->maxDistance = mats.scatterStep>0.5f? DisneyBSDF::SampleDistance(prd->seed, prd->scatterDistance) : 1e16f; } else { diff --git a/zenovis/xinxinoptix/DisneyBSDF.h b/zenovis/xinxinoptix/DisneyBSDF.h index bcbf50d82f..df80e14f9f 100644 --- a/zenovis/xinxinoptix/DisneyBSDF.h +++ b/zenovis/xinxinoptix/DisneyBSDF.h @@ -164,9 +164,10 @@ namespace DisneyBSDF{ } static __inline__ __device__ - vec3 CalculateExtinction(vec3 apparantColor, float scatterDistance) + vec3 CalculateExtinction(vec3 apparantColor, float scaler) { - return 1.0/(max(apparantColor * scatterDistance,vec3(0.000001))); + // return 1.0/(max(apparantColor * scaler,vec3(0.000001))); + return (1.0f - apparantColor) * scaler; } static __inline__ __device__ @@ -694,7 +695,7 @@ namespace DisneyBSDF{ wi = normalize(refract(wo, wm, entering?1.0f/mat.ior:mat.ior)); flag = transmissionEvent; isTrans = true; - extinction = CalculateExtinction(mat.transParam, mat.transDepth); + extinction = CalculateExtinction(mat.transTint, mat.transTintDepth); extinction = entering? extinction : vec3(0.0f); } diff --git a/zenovis/xinxinoptix/IOMat.h b/zenovis/xinxinoptix/IOMat.h index 73a49a9796..c3e4213981 100644 --- a/zenovis/xinxinoptix/IOMat.h +++ b/zenovis/xinxinoptix/IOMat.h @@ -29,9 +29,12 @@ struct MatOutput { float specTrans; vec3 transColor; - vec3 transParam; - float clarity; - float transDepth; + vec3 transTint; + float transTintDepth; + float transDistance; + vec3 transScatterColor; + + float subsurface; vec3 sssColor; diff --git a/zenovis/xinxinoptix/PTKernel.cu b/zenovis/xinxinoptix/PTKernel.cu index 8a21e9f327..fa0e086eba 100644 --- a/zenovis/xinxinoptix/PTKernel.cu +++ b/zenovis/xinxinoptix/PTKernel.cu @@ -110,7 +110,7 @@ extern "C" __global__ void __raygen__rg() float r0 = r01.x * 2.0f * M_PIf; float r1 = r01.y * aperture * aperture; - r1 = sqrt(r1); + r1 = sqrtf(r1); float3 eye_shake = r1 * ( cosf(r0)* normalize(cam.right) + sinf(r0)* normalize(cam.up)); // Camera local space float3 ray_origin = cam.eye + eye_shake; diff --git a/zenovis/xinxinoptix/volume.cu b/zenovis/xinxinoptix/volume.cu index 75a716a0bb..c25ef58382 100644 --- a/zenovis/xinxinoptix/volume.cu +++ b/zenovis/xinxinoptix/volume.cu @@ -409,7 +409,7 @@ extern "C" __global__ void __closesthit__radiance_volume() testPRD.vol_t1 = _FLT_MAX_; testPRD.test_distance = true; testPRD.isSS = false; - testPRD.opacity = 0.0f; + uint16_t _mask_ = EverythingMask ^ VolumeMatMask;