-
Notifications
You must be signed in to change notification settings - Fork 15
Hlsl path tracer #224
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
base: master
Are you sure you want to change the base?
Hlsl path tracer #224
Conversation
| const float32_t2 unpacked = hlsl::unpackHalf2x16(pc.packedSplattingParams); | ||
| rwmc::SplattingParameters splattingParameters = rwmc::SplattingParameters::create(unpacked[0], unpacked[1]); | ||
| accumulator_type accumulator = accumulator_type::create(splattingParameters); |
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.
add a get and set method to RenderRWMCPushConstants
| float32_t3 color = resolve(accessor, int16_t2(coords.x, coords.y)); | ||
|
|
||
| //float32_t3 color = rwmc::reweight<rwmc::ResolveAccessorAdaptor<float> >(pc.resolveParameters, cascade, coords); | ||
| //float32_t3 color = rwmc::reweight<ResolveAccessorAdaptor<float> >(pc.resolveParameters, cascade, coords); |
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.
whats this commented out code, if not used then remove it
31_HLSLPathTracer/main.cpp
Outdated
| float32_t2 packParams = float32_t2(rwmcBase, rwmcStart); | ||
| rwmcPushConstants.packedSplattingParams = hlsl::packHalf2x16(packParams); |
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.
we need a setter method for the packed params
| #ifndef _NBL_HLSL_PATHTRACING_INCLUDED_ | ||
| #define _NBL_HLSL_PATHTRACING_INCLUDED_ | ||
|
|
||
| #include <nbl/builtin/hlsl/colorspace/EOTF.hlsl> | ||
| #include <nbl/builtin/hlsl/colorspace/encodeCIEXYZ.hlsl> | ||
| #include <nbl/builtin/hlsl/math/functions.hlsl> | ||
| #include <nbl/builtin/hlsl/sampling/basic.hlsl> | ||
| #include <nbl/builtin/hlsl/bxdf/bxdf_traits.hlsl> | ||
| #include <nbl/builtin/hlsl/sampling/quantized_sequence.hlsl> | ||
| #include <nbl/builtin/hlsl/vector_utils/vector_traits.hlsl> | ||
| #include "concepts.hlsl" | ||
|
|
||
| namespace nbl | ||
| { | ||
| namespace hlsl | ||
| { | ||
| namespace path_tracing | ||
| { | ||
|
|
||
| template<class RandGen, class RayGen, class Intersector, class MaterialSystem, /* class PathGuider, */ class NextEventEstimator, class Accumulator, class Scene | ||
| NBL_PRIMARY_REQUIRES(concepts::RandGenerator<RandGen> && concepts::RayGenerator<RayGen> && | ||
| concepts::Intersector<Intersector> && concepts::MaterialSystem<MaterialSystem> && | ||
| concepts::NextEventEstimator<NextEventEstimator> && concepts::Accumulator<Accumulator> && | ||
| concepts::Scene<Scene>) | ||
| struct Unidirectional | ||
| { | ||
| using this_t = Unidirectional<RandGen, RayGen, Intersector, MaterialSystem, NextEventEstimator, Accumulator, Scene>; |
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.
all this needs to go to Nabla repo
| template<typename RNG> | ||
| struct Uniform1D | ||
| { | ||
| using rng_type = RNG; | ||
| using return_type = uint32_t; | ||
|
|
||
| static Uniform1D<RNG> construct(uint32_t2 seed) | ||
| { | ||
| Uniform1D<RNG> retval; | ||
| retval.rng = rng_type::construct(seed); | ||
| return retval; | ||
| } | ||
|
|
||
| return_type operator()() | ||
| { | ||
| return rng(); | ||
| } | ||
|
|
||
| rng_type rng; | ||
| }; | ||
|
|
||
| template<typename RNG> | ||
| struct Uniform3D | ||
| { | ||
| using rng_type = RNG; | ||
| using return_type = uint32_t3; | ||
|
|
||
| static Uniform3D<RNG> construct(uint32_t2 seed) | ||
| { | ||
| Uniform3D<RNG> retval; | ||
| retval.rng = rng_type::construct(seed); | ||
| return retval; | ||
| } | ||
|
|
||
| return_type operator()() | ||
| { | ||
| return return_type(rng(), rng(), rng()); | ||
| } | ||
|
|
||
| rng_type rng; | ||
| }; |
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.
these need also static return_type __call(NBL_REF_ARG(rng_type) rng)
AND to be in Nabla repo
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.
We have this sort of thing in DimAdaptorRecursive and it's been changed to this in pr 980
https://github.com/Devsh-Graphics-Programming/Nabla/blob/minor_adjustments_to_bxdf_and_path_tracing_stuff/include/nbl/builtin/hlsl/random/dim_adaptor_recursive.hlsl
So change once that's been merged? Also randgen concept will use __call instead then?
| static this_t create(NBL_CONST_REF_ARG(vector2_type) pixOffsetParam, NBL_CONST_REF_ARG(vector3_type) camPos, NBL_CONST_REF_ARG(vector4_type) NDC, NBL_CONST_REF_ARG(matrix4x4_type) invMVP) | ||
| { | ||
| this_t retval; | ||
| retval.pixOffsetParam = pixOffsetParam; | ||
| retval.camPos = camPos; | ||
| retval.NDC = NDC; | ||
| retval.invMVP = invMVP; | ||
| return retval; | ||
| } |
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.
again, lets not make useless psedo-constructors
| // #if POLYGON_METHOD==2 | ||
| // ray._immutable.normalAtOrigin = vec3(0.0,0.0,0.0); | ||
| // ray._immutable.wasBSDFAtOrigin = false; | ||
| // #endif | ||
|
|
||
| ray.payload.accumulation = (vector3_type)0.0; | ||
| ray.payload.otherTechniqueHeuristic = 0.0; // needed for direct eye-light paths | ||
| ray.payload.throughput = (vector3_type)1.0; | ||
| // #ifdef KILL_DIFFUSE_SPECULAR_PATHS | ||
| // ray._payload.hasDiffuse = false; | ||
| // #endif |
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.
payload shouldn't be initialized by raygen, just the direction
| // apply stochastic reconstruction filter | ||
| const float gaussianFilterCutoff = 2.5; | ||
| const float truncation = nbl::hlsl::exp(-0.5 * gaussianFilterCutoff * gaussianFilterCutoff); | ||
| vector2_type remappedRand = randVec.xy; | ||
| remappedRand.x *= 1.0 - truncation; | ||
| remappedRand.x += truncation; | ||
| nbl::hlsl::sampling::BoxMullerTransform<scalar_type> boxMuller; | ||
| boxMuller.stddev = 1.5; | ||
| tmp.xy += pixOffsetParam * boxMuller(remappedRand); |
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.
wrap this up in another struct, this is a Stochastic Reconstruction Filter of which one can have Tent, Box, etc. this one is Gaussian
| #ifndef _NBL_HLSL_EXT_RAYGEN_INCLUDED_ | ||
| #define _NBL_HLSL_EXT_RAYGEN_INCLUDED_ | ||
|
|
||
| #include <nbl/builtin/hlsl/sampling/box_muller_transform.hlsl> | ||
|
|
||
| #include "common.hlsl" | ||
|
|
||
| namespace RayGen | ||
| { | ||
|
|
||
| template<class Ray> | ||
| struct Basic | ||
| { | ||
| using this_t = Basic<Ray>; | ||
| using ray_type = Ray; | ||
| using scalar_type = typename Ray::scalar_type; | ||
| using vector3_type = typename Ray::vector3_type; | ||
|
|
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.
this looks useful put it in the path_tracing namespace and builtin directory as DefaultRayGen or BasicRayGen
@keptsecret after you merge
masteragain, you'll probably have the UI mess up and show changed from the merge commit, so close and reopen againTODO