-
Notifications
You must be signed in to change notification settings - Fork 43
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
Is it possible to extend a UInt with additional values ? #207
Comments
Hi @viswaravi You're trying to change the vectorization width mid-way through your computation. Let's say you're rendering with 32 rays, once you reach the BSDF For completeness, it is possible to change the kernel width. But it will break the kernel into two separate ones. We support this mode of execution and refer to it as "wavefront" mode (as opposed to "megakernel" mode). You can read more about how to turn it on and its implications here: mitsuba-renderer/mitsuba3#586 |
Thank you very much for your response. I want each sample to handle more than 3 indices which would mean index list has n values like start_index = (y*128 + x) * self.n start_index = UInt(start_index) indexes = [ start_index, start_index +1 , ... , start_index + n ] as I need to gather n values from my TensorXf.
indexes = UInt([0,1,2]) it brings the Cannot gather from placeholder value Error My goal is to propagate gradients from rendering back to my TensorXf Values. As the n gathered values would be converted to mi.Color3f and returned from BSDF eval function. If you have any other suggestion to achieve this in megakernel mode itself, please let me know. |
I think I'm missing a step. If you keep Let me clarify the following: a |
The purpose of merging N mi.Float values into a single TensorXf is that, I have BSDF characterstics encoded in a Texture (TensorXf) with N channels. I want to query them based on U,V paramaters and finally convert the N channels into Color3f as a output of custom BSDF plugin. So my requirement is to convert list[mi.Float] into a single mi.Float As you have suggested I can perform N seperate gathers and have list[mi.Float], is it possible to convert the list[mi.Float] into single flat mi.Float so that it can be converted to TensorXf later ? A= mi.Float(1) B = mi.Float(2) c = [1,2] # Required result or alternatively, If I gather values through multiple Array3f, can I merge them into single flat mi.Float A=Array3f( [0,1,2] ) B=Array3f( [3,4,5] ) C = [0,1,2,3,4,5] # Required result Note: As I want to use Megakernel mode, I can't use scatter function to achieve this as the variable target to scatter won't be evaluated outside the rendering loop. |
Hi again @viswaravi Sorry for the delay, we've been busy with a new release.
As I said in my previous message, this is only possible in wavefront mode as it changes the vectorization width. The same holds for your second example with the
None of this requires a bsdf_characteristics: list[mi.TensorXf] = (...) # N items of shape U x V
uv_start_index: mi.UInt32 = compute_start_index(si.uv)
all_uv_indices = [uv_start_index]
for i in range(N -1 ):
all_uv_indices.append(next_index_from_current_index(all_uv_indices[i]))
# Now we have all_uv_incies as a N-sized list of mi.UInt32 objects
characterisitics = []
for i in range(N):
characteristics.append(dr.gather(mi.Float, bsdf_characteristics[i], all_uv_indices[i])
output = characteristics_to_color3f(characterisitics) # Some function that converts N mi.Float objects into a single mi.Color3f I thing you're getting vectorization widht and array lenghts confused. An easy way to write code is to just assume you have a vectorization of 1, then what would the code look like? Most likely it will be close to what I wrote above. By trying to merge together |
I am trying to gather multiple values from a TensorXf type inside custom BSDF Plugin. To create dynamic number of Index values I only have the starting Index in UInt type. Can I add additional numbers/index to my UInt type.
If I query them seperately as Float, I can't be able to combine them into a single TensorXf
Eval function of Custom BSDF Plugin which queries values from TensorXf
The text was updated successfully, but these errors were encountered: