-
Notifications
You must be signed in to change notification settings - Fork 0
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
Draft Material in core #4
base: material-in-core
Are you sure you want to change the base?
Conversation
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.
Thanks for this first submission. We need to discuss in front of a white board to improve your code and to make the design more efficient.
About the random engine. Despite the fact that my getter is bad, David didn't want to have a new random engine for each call. That's why we thought about a static member. With your solution, do you want to make a new one each time the user doesn't provide a generator ? |
No, even if the generators from std:: is very cheap to construct, if the user does not provide a generator, the same will be used for each material. Even if you have a static member, right now, as your getter returns a copy of the generator, you'll create one each time you call What I've in mind is something similar to what I propose (but only for uniform pdf) in the We will define a set of
we use these in a 'Sampler' adapters that generates xD point distributed according to a given probability function
In the MaterialModel class, we give the user the ability to set the default 2D Generator (sampling a bsdf need at least 2D random numbers and, if more are needed, the generator will be call more than once for a given sample) to use when sampling, and, if no default is given by the user, we use a std::mt19937 to generate sequence of 2D points (or a simple but better Hamersley2D) Then the sample method in MaterialModel is overloaded so that the user can call the method with our without a reference to a Generator. If called with such a reference, the given generator will be used by the sampling adapter, if called without, the default will be used by the adapter. We'll discuss about this on the white board on our monday meeting. |
Yesterday we talked about precomputed tangent and bitangent. I can't access these data from the material (or bsdf) class. |
For some materials (e.g. anisotropic materials), accessing the local frame should be mandatory. So, perhaps we can add this local frame as parameter for the bsdf eval, sample and pdf methods. |
Should the local frame be the canonical one ? i.e. (1,0,0), (0,1,0), (0,0,1) for textures |
Well, My writings seems quite obscure. The texture coordinates uv is used to access local bsdf parameter from textures and their derivatives du and dv are used to filter the texture (mip-maping or anisotropic filtering). These derivatives are computed by the ray-tracing engine using ray-differentials (see siggraph '99 paper https://graphics.stanford.edu/papers/trd/ ) and are used in the implementation of the initial ray-tracing plugin. In pbrt, the sample interaction is a kind of closure that stores partial functions and data that should be computed once per interaction. In this "closure" (see file core/interaction.h in the pbrt source code), you'll find all the informations needed to process an interaction point. This notion of closure is also managed by OpenShadingLangage and in many ray-tracing systems. I have implemented such an approach (first, compute a closure on an interaction point, then use the closure for subsequent computations) in the glsl implementation of GLTF material system. So right now, and for the work of @grandch, I propose to just take all needed data as parameters of the corresponding function. On my side (and this will be merged with the current work easily once valldated) I'm experimenting something like :
|
At this point I have a few questions. I have a ImportanceSampler base class from which derives SphereSampler but I can't figure what interface it should have. Where does the user provide the random generator ? At the sampler level or at the material/bsdf level ? Do you have preferences about how you want me to deal with static virtual methods ? I read several workarouds to achieve this. |
~UniformSphereSampler() {}; | ||
|
||
static std::pair<Vector2, Scalar> getPointImplem( UniformGenerator* generator ); | ||
static std::pair<Vector3, Scalar> getDirImplem( UniformGenerator* generator ); |
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.
static std::pair<Vector3, Scalar> getDirImplem( UniformGenerator* generator ); | |
static std::pair<Vector3, Scalar> getDir( UniformGenerator* generator ); |
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 getDirImplem method is here for the CRTP SphereSampler in order to have both static methods AND polymorphism.
static std::pair<Vector2, Scalar> getPointImplem( UniformGenerator* generator ); | ||
static std::pair<Vector3, Scalar> getDirImplem( UniformGenerator* generator ); | ||
|
||
static Scalar pdfImplem( Vector3 dir, Vector3 normal ); |
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.
static Scalar pdfImplem( Vector3 dir, Vector3 normal ); | |
static Scalar pdf( Vector3 dir, Vector3 normal ); |
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 pdfImplem method is here for the CRTP SphereSampler in order to have both static methods AND polymorphism.
Pull Request Desription
declare (and implement) bsdf specific interface in material model (according to STORM-IRIT/Radium-Engine/pull/1050 :
TODO
Move std::minstd_rand randomEngine into a class member to avoid initializing it each call
Move math methods into Math.hpp or LinearAlgebra.hpp
improve class Core::Tex to manage texture, or rely on openimageio
Check if you branch history is PR compatible
git fetch origin
if origin is this remotescripts/is-history-pr-compatible.sh
These checks are enforced by github workflow actions
Please refer to the corresponding log in case of failure
UPDATE the form below to describe your PR
Please check if the PR fulfills these requirements
Be aware that the PR request cannot be accepted if it doesn't pass the Continuous Integration tests.
What kind of change does this PR introduce?
What is the current behavior? (You can also link to an open issue here)
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
Other information: