FansOfAll
Josef Pelz
Josef Pelz

patreon


T3D | Version 1.8.1 small bug fixes

This version contain's minor bug fixes and small new features.

Comments

Hi Scott, Thanks for your question. You're on a good track with reorder. But make sure that the pixel format allows for alpha. You might have a 32bit mono there that doesn't have alpha. With the most recent version 1.8.1 of T3D, you can also direcly set fill and background color of the SOPtoT3D. Best, Josef

Josef Pelz

Hi Josef- Loving the tools! I have a question that I posed in a video: https://www.dropbox.com/scl/fi/ebvbrgiu23oi4pf5xei4l/T3DQuestion.mp4?rlkey=2wvdeujbqzti0jlo5ktgjdqt5&dl=0

Scott Mann

Thanks for your answer Josef, I've been digging into it and I wrote this script but after hours of research and struggle I somehow always get a bug with my sample function. Touch designer keeps telling me that my arguments are a tuple when it's two floats argument separated by a comma. Here is my python script : import math def onCook(scriptOp): # 1) References t3dTOP = op('null1') # Flattened T3D texture debug("t3dTOP.name:", t3dTOP.name) debug("t3dTOP.type:", t3dTOP.type) debug("t3dTOP.family:", t3dTOP.family) Nx, Ny, Nz = 8, 8, 8 # Example 3D dims # 2) Grid for slices C = math.ceil(math.sqrt(Nz)) R = math.ceil(Nz / C) totalWidth = Nx * C totalHeight = Ny * R # 3) Check input inputChop = scriptOp.inputs[0] if not inputChop: # No input? Just bail or define your own samples scriptOp.numSamples = 0 return numSamples = inputChop.numSamples # 4) Prepare Script CHOP’s output scriptOp.clear() scriptOp.numSamples = numSamples scriptOp.appendChan('R') scriptOp.appendChan('G') scriptOp.appendChan('B') scriptOp.appendChan('A') # We need 4 channels for RGBA #scriptOp.setChannelNames(['R','G','B','A']) # 5) Loop over each sample for i in range(numSamples): u3D = inputChop['u'][i] v3D = inputChop['v'][i] w3D = inputChop['w'][i] zFloat = w3D * (Nz - 1) z_i = int(round(zFloat)) z_i = max(0, min(z_i, Nz - 1)) col = z_i % C row = z_i // C x_in_slice = u3D * (Nx - 1) y_in_slice = v3D * (Ny - 1) X_2D = (col * Nx) + x_in_slice Y_2D = (row * Ny) + y_in_slice U = X_2D / (totalWidth - 1) V = Y_2D / (totalHeight - 1) # You can sample as a tuple of 4: debug("U:", U, "type:", type(U)) debug("V:", V, "type:", type(V)) r, g, b, a = t3dTOP.sample(U, V) # or separately: # r = t3dTOP.sample(U, V, c=0) # g = t3dTOP.sample(U, V, c=1) # b = t3dTOP.sample(U, V, c=2) # a = t3dTOP.sample(U, V, c=3) scriptOp[0, i] = r scriptOp[1, i] = g scriptOp[2, i] = b scriptOp[3, i] = a return I know this is not a support channel but if something quickly comes to your mind it would be appreciated.

Sébastien Galera

Hi Sébastien, Thanks for your message! I personally would solve this with a scriptCHOP. You can use the sample function on any TOP (hence also on the output of T3Ds) to get values at any location given by xyz pixel coordinates or uvw coordinates.

Josef Pelz

Hi, first thank you for this awesome toolset, I'm working on a project where I want to sample the 3d texture at a specific 3d Coordinate. For this I started by converting the t3d to top and then sampling the texture with a top to chop. All good on this side, I managed to get my rgba channel as chop. Now where I'm struggling is that I need a conversion method to go from the normalized 3d coordinates to the corresponding top coordinates. This would enable me to effectively sample the t3d into chops. Do you have a documentation where you explain how the t3d slices are composed into a top format ? I can then do the math to transpose the 3d coordinate into 2d coordinates. Thanks a lot !

Sébastien Galera


More Creators