drtk.source_transmittance#

source_transmittance

Evaluate transmittance from a source camera or light to mesh points.

source_transmittance_texture

Evaluate source transmittance using a textured opacity field.

source_transmittance_mlp

Evaluate source transmittance from a feature texture and an appearance MLP.

source_transmittance_mlp_two_textures

Evaluate source transmittance from two feature textures and an appearance MLP.

sample_with_transmittance

Sample an image at surface points, attenuated by source transmittance.

source_transmittance_ref

Reference for source_transmittance(), with smooth gradients only.

source_transmittance_texture_ref

Reference for source_transmittance_texture(), with smooth gradients only.

source_transmittance_mlp_ref

Reference for source_transmittance_mlp(), with smooth gradients only.

source_transmittance_mlp_two_textures_ref

Reference for source_transmittance_mlp_two_textures(), with smooth gradients only.

sample_with_transmittance_ref

Reference for sample_with_transmittance(), supporting CPU and float64.

Evaluate transmittance from a source camera or light to points on a mesh. The outputs retain the original query order, including points on layers behind other surfaces. Use their weights to evaluate shadows or to sample image features with attenuation. Gradients propagate to deformation, material opacity, appearance textures and MLP parameters, and sampled features.

See Differentiable visibility for an example. For repeated calls, see Avoiding CPU synchronization for capacity selection.

Evaluating transmittance#

indices, weights, _, _ = source_transmittance(
    v_pix, faces, query_faces, query_barycentrics, height, width,
    vertex_opacity=opacity,
)
transmittance = weights.sum(-1)

The result is bilinearly filtered transmittance at each receiving point. It includes the fraction of the sampling footprint inside the image and receiving surface. For unit illumination from a light, it gives the shadow intensity on that surface.

Opacity models#

Choose the transmittance function that matches the mesh’s appearance:

Appearance

Transmittance function

Matching renderer

Vertex opacity

source_transmittance()

Material-opacity input

RGB or RGBA texture

source_transmittance_texture()

render_transparent()

Feature texture and MLP

source_transmittance_mlp()

render_transparent_mlp()

Two feature textures and MLP

source_transmittance_mlp_two_textures()

render_transparent_mlp_two_textures()

The textured variants evaluate appearance alpha at each occluding fragment and multiply it by interpolated vertex opacity. They use the renderer’s perspective-correct UVs, filtering, padding, and alpha activation. Supply the same appearance parameters in both calls. RGB channels do not affect transmittance, and the receiving face’s own alpha remains excluded. Texture resolution is independent of the source image resolution.

For an RGBA texture whose alpha values are already in \([0,1]\):

indices, weights, _, _ = source_transmittance_texture(
    v_pix, faces, uv, rgba_texture, query_faces, query_barycentrics,
    height, width, vertex_opacity=opacity, alpha_activation="clamp",
)

All variants return the same four-item tuple and work with sample_with_transmittance().

Sampling features#

source_transmittance() computes the four source texels and weights for each surface query. sample_with_transmittance() gathers their features:

indices, weights, _, _ = source_transmittance(
    v_pix, faces, query_faces, query_barycentrics, height, width,
    vertex_opacity=opacity,
)
sampled, confidence = sample_with_transmittance(features, indices, weights)

A query is specified by a face ID and 3D barycentric coordinates. Each bilinear tap must lie on the query’s local surface. The surface continues through shared manifold edges and ends at cuts, projected folds, and nonmanifold junctions. Occlusion is evaluated at each tap, including self-occlusion within a connected mesh.

The same indices and weights can sample several feature maps with matching batch and spatial dimensions. Recompute them when the geometry, topology, material opacity, appearance parameters, or source camera changes.

Transmittance and confidence#

For a receiving face \(r\), transmittance at source pixel \(p\) is

\[T_r(p)=\prod_{f\prec r}\left(1-\alpha_f(p)\right).\]

Faces are ordered by mean camera-space vertex depth, with face index breaking ties, as in drtk.transparent_render. This approximates visibility for small triangles; intersecting or depth-crossing triangles can require a different order at different pixels. The receiving face’s own opacity is excluded from the product.

With bilinear coefficients \(b_{qj}\) and source features \(F_j\), the sampling weights, feature sum, and confidence are

\[w_{qj}=b_{qj}T_{qj},\qquad S_q=\sum_{j=1}^{4}w_{qj}F_j,\qquad c_q=\sum_{j=1}^{4}w_{qj}.\]

Invalid taps have zero weight. The feature sum is unnormalized: a fully hidden query returns zero features and zero confidence. For example, an existing surface feature \(A_q\) can fill the missing contribution as \(S_q+(1-c_q)A_q\).

Opacity may come from vertex values, a texture, or an appearance MLP. Its inputs must be available before feature sampling: predicting opacity from the features sampled using that same opacity would create a circular dependency. Partial visibility supplies a confidence value; features already mixed by transparency or a neural receptive field remain mixed.

Gradients#

Smooth derivatives propagate through projection, bilinear interpolation, material opacity, appearance textures and MLP parameters, and sampled feature values. source_transmittance() clamps material opacity to [0, 1] with the interior derivative at zero and one. The textured variants follow their corresponding renderer, including its final zero-alpha ReLU subgradient and the opacity gradient at exactly one. Gradients are zero outside the material clamp. Coverage boundaries use DRTK’s edge estimator, enabled by edge_gradients=True. For upstream feature and confidence gradients \(g_S,g_c\), its weight derivative is

\[\frac{\partial L}{\partial w_{qj}} =\langle g_{S_q},F_j\rangle+g_{c_q}.\]

The estimator combines this derivative with the visibility change across an edge to obtain a geometry gradient. In-image taps retain their indices even at zero weight, allowing this change to account for features revealed by boundary motion. Ordinary shared tessellation edges, zero-opacity occluders, and fully hidden edges contribute zero boundary jump.

Call loss.backward() on the downstream loss. Applying edge_grad_estimator() again would count the source boundary contribution twice. A target-view renderer computes its own boundary contribution.

Quantity

Gradient

Vertices, query barycentrics, source features, material opacity, UVs, textures, MLP parameters

Smooth derivatives for fixed coverage and ordering.

Occlusion and receiving-surface boundaries

Estimated geometry derivatives from boundary motion.

Face IDs, connectivity, ordering, and surface-continuation decisions

Discrete. Use bernoulli_render_loss() for sampled topology, recomputing transmittance weights for each sample.

Second derivatives

Unsupported.

The reference functions support CPU tensors and smooth derivatives. The boundary estimator is available in all CUDA transmittance variants.

Coordinates and data types#

v_pix contains source pixel XY and positive camera Z. Integer XY denotes pixel centers. For 3D barycentrics \(\beta\), a query projects to

\[z_q=\sum_i\beta_i z_i,\qquad p_q=\frac{\sum_i\beta_i z_i p_i}{z_q}.\]

For a feature map resized from \(W\times H\) to \(W_f\times H_f\), transform pixel coordinates as x_f = (x + 0.5) * W_f / W - 0.5 and similarly for Y. return_queries=True returns normalized UV coordinates compatible with grid_sample(..., align_corners=False) and camera Z.

The transmittance operation requires float32 CUDA geometry and produces float32 weights. Sampling accepts float16, bfloat16, and float32 CUDA features, with arbitrary channel counts and strides. Accumulation uses float32. Backward may be nondeterministic. The transmittance operations do not support CUDA graph capture.

Functions#

drtk.source_transmittance(v_pix, vi, query_face_ids, query_barycentrics, height, width, *, vertex_opacity=None, edge_gradients=True, return_queries=False, tile_capacity=None)[source]#

Evaluate transmittance from a source camera or light to mesh points.

Return bilinear image indices and weights for each point. Summing its four weights gives filtered transmittance, including the valid sampling footprint. Under unit illumination, this is the shadow intensity on the receiving surface.

Each query is attached to a face by 3D barycentric coordinates. Its four image taps follow the receiving surface through shared manifold edges, stopping at cuts, projected folds, or nonmanifold junctions. Each valid tap is weighted by transmittance from faces preceding its receiver in (mean triangle camera Z, face index) order.

Outputs retain the query order. For queries attached to an original surface grid, reshape the outputs into that grid after deformation. Queries projecting to the same camera pixel can have different transmittances when they lie on different surface layers.

Apply the result to a feature image with sample_with_transmittance(). Feature maps with matching batch and spatial dimensions can share the same indices and weights. Recompute them when geometry, topology, material opacity, or the source camera changes.

Parameters:
  • v_pix (Tensor) – Float32 CUDA vertices, (N, V, 3). XY are source pixel coordinates, with integer values at pixel centers. Z is positive camera depth. Use the feature image’s pixel grid.

  • vi (Tensor) – Int32 CUDA faces, (F, 3) or (N, F, 3). Faces with invalid indices, nonfinite vertices, nonpositive depth, or zero projected area are ignored. Shared indices define connectivity; coincident vertices with separate indices remain separate.

  • query_face_ids (Tensor) – Int32 CUDA receiving-face IDs, (N, Q). -1 denotes an unused query. At a shared vertex, choose an incident face on the intended side of the surface.

  • query_barycentrics (Tensor) – Float32 CUDA 3D barycentrics, (N, Q, 3). Entries must be nonnegative and sum to one. Invalid queries have zero weights and diagnostics, with tap indices set to -1.

  • height (int) – Source feature-image height.

  • width (int) – Source feature-image width.

  • vertex_opacity (Optional[Tensor]) – Float32 CUDA material opacity, (N, V), clamped to [0, 1]. Defaults to one. The receiving face’s own opacity is excluded from visibility. Opacity must be available before sampling; predicting it from these same sampled features creates a circular dependency.

  • edge_gradients (bool) – Estimate geometry gradients at visibility and receiving-surface boundaries. Default: True.

  • return_queries (bool) – Return each query’s projected UV and camera Z. Default: False.

  • tile_capacity – Optional maximum tile/triangle intersections across the batch, including the boundary-query halo. Keeps bin counts on the GPU and permits CUDA graph capture. Insufficient capacity raises an asynchronous CUDA error. None uses exact-sized bins.

Returns:

(tap_indices, tap_weights, query_uv, query_depth).

tap_indices is int32 (N, Q, 4), ordered top-left, top-right, bottom-left, bottom-right. Each entry is flattened as y * width + x. Out-of-image and unused-query taps have index -1. In-image indices remain valid at zero weight to support boundary gradients.

tap_weights is float32 (N, Q, 4): bilinear coefficients times source transmittance. Taps outside the receiving surface have zero weight. The weights are unnormalized.

query_uv is (N, Q, 2) in normalized align_corners=False coordinates; query_depth is (N, Q) camera Z. Both are None unless requested. Unused queries have zero diagnostics.

Return type:

Tuple[Tensor, Tensor, Optional[Tensor], Optional[Tensor]]

Gradients:

Smooth gradients reach vertices, query barycentrics, and material opacity. The opacity clamp uses the interior derivative at zero and one. Coverage boundaries use DRTK’s edge-motion estimator. Ordinary tessellation edges and zero-opacity occluders have zero boundary jump. An additional edge_grad_estimator() call would count this contribution twice.

Face IDs, topology, and ordering are discrete. To optimize topology logits, use bernoulli_render_loss() with fresh transmittance weights for each sampled mesh. Only first derivatives are supported. Backward may be nondeterministic.

Note

Geometry and weights remain float32 under autocast. CUDA graph capture requires tile_capacity. source_transmittance_ref() supports CPU inputs and smooth derivatives.

Visibility weights describe geometric access to the source image. Features mixed by transparency or a feature extractor’s receptive field remain mixed.

Example:

indices, weights, _, _ = source_transmittance(
    v_pix, faces, query_faces, query_barycentrics, H, W
)
sampled, confidence = sample_with_transmittance(features, indices, weights)
prediction = model(anchor_features, sampled, confidence)
loss_fn(prediction, target).backward()
drtk.source_transmittance_texture(v_pix, vi, uv, texture, query_face_ids, query_barycentrics, height, width, *, vertex_opacity=None, mode='bilinear', padding_mode='border', alpha_activation='relu_density', edge_gradients=True, return_queries=False, tile_capacity=None)[source]#

Evaluate source transmittance using a textured opacity field.

Uses the same perspective-correct UV interpolation, texture filtering, and alpha activation as render_transparent(). With an RGBA texture, the fourth channel supplies appearance alpha; an RGB texture supplies alpha one. Interpolated vertex opacity multiplies this appearance alpha.

Occluders follow mean-triangle-depth order, with face index breaking ties. Queries and surface connectivity follow source_transmittance(). Sum the returned weights for transmittance, or pass them to sample_with_transmittance() to gather attenuated source features.

Parameters:
  • v_pix – Float32 CUDA vertices (N, V, 3) in source pixel XY and positive camera Z. Integer XY denotes pixel centers.

  • vi – Int32 faces (F, 3) or (N, F, 3). Shared indices define connectivity; invalid or degenerate faces are ignored.

  • uv – Per-vertex texture coordinates (V, 2), (1, V, 2), or (N, V, 2) in [0, 1].

  • texture – RGB or RGBA texture (N or 1, 3 or 4, Ht, Wt). RGB channels do not affect visibility. Alpha activation follows texture filtering.

  • query_face_ids – Int32 receiving-face IDs (N, Q); -1 marks unused queries. The receiving face’s own alpha is excluded.

  • query_barycentrics – Float32 3D barycentrics (N, Q, 3). Values must be nonnegative and sum to one; invalid queries have zero weights.

  • height – Source feature-image height, independent of texture size.

  • width – Source feature-image width, independent of texture size.

  • vertex_opacity – Optional float32 material opacity (N, V), clamped to [0, 1] and multiplied by appearance alpha. Defaults to one.

  • mode – Texture filtering: "bilinear", "nearest", or "bicubic".

  • padding_mode – Texture padding: "border", "zeros", or "reflection". Sampling uses align_corners=False.

  • alpha_activation – "relu_density" (default) computes 1 - exp(-max(a, 0)). Alternatives are "shifted_sigmoid" (sigmoid(a - 0.5)), "exp_density" (1 - exp(-exp(min(a, 15)))), and "clamp" (clamp(a, 0, 1)).

  • edge_gradients – Estimate geometry gradients at occlusion and receiving-surface boundaries. Defaults to True. Shared tessellation edges and zero-alpha edge traces have no boundary jump.

  • return_queries – Also return query UV in normalized [-1, 1] image coordinates and camera depth. Defaults to False.

  • tile_capacity – Optional maximum tile/triangle intersections across the batch, including the boundary-query halo. Keeps bin counts on the GPU and permits CUDA graph capture. Insufficient capacity raises an asynchronous CUDA error. None uses exact-sized bins.

Returns:

(tap_indices, tap_weights, query_uv, query_depth). Indices are int32 (N, Q, 4) and weights are float32 (N, Q, 4), ordered top-left, top-right, bottom-left, bottom-right. Each weight is a bilinear coefficient times transmittance; invalid taps have zero weight. Indices are flattened as y * width + x; out-of-image or unused-query taps have index -1. Query UV (N, Q, 2) and depth (N, Q) are None unless requested.

Gradients:

Smooth derivatives reach vertices, query barycentrics, UVs, material opacity, and appearance parameters. RGB output channels do not affect transmittance. Coverage boundaries contribute geometry gradients when enabled; do not apply edge_grad_estimator() again to this result. Face IDs, connectivity, and depth ordering are discrete. Second derivatives are unsupported.

The alpha activations and endpoint derivatives match the corresponding transparent renderer. In particular, final zero alpha has zero smooth gradient, while exactly opaque fragments retain their opacity gradient unless another opaque fragment blocks the query.

drtk.source_transmittance_mlp(v_pix, vi, uv, texture, weights, biases, query_face_ids, query_barycentrics, height, width, *, vertex_opacity=None, negative_slope=0.2, mode='bilinear', padding_mode='border', alpha_activation='shifted_relu_density', edge_gradients=True, return_queries=False, tile_capacity=None)[source]#

Evaluate source transmittance from a feature texture and an appearance MLP.

Uses the alpha output of the appearance model from render_transparent_mlp(). Features are sampled at perspective-correct UVs before MLP evaluation. Use the same appearance inputs, vertex opacity, and activation in visibility and rendering to obtain consistent attenuation.

Occluders follow mean-triangle-depth order, with face index breaking ties. Queries and surface connectivity follow source_transmittance(). Sum the returned weights for transmittance, or pass them to sample_with_transmittance() to gather attenuated source features. The appearance textures must be available before this sampling step; they cannot depend on features sampled using the same transmittance.

Parameters:
  • v_pix – Float32 CUDA vertices (N, V, 3) in source pixel XY and positive camera Z. Integer XY denotes pixel centers.

  • vi – Int32 faces (F, 3) or (N, F, 3). Shared indices define connectivity; invalid or degenerate faces are ignored.

  • uv – Per-vertex texture coordinates (V, 2), (1, V, 2), or (N, V, 2) in [0, 1].

  • texture – Feature texture (N or 1, C, Ht, Wt), with 1 <= C <= 32.

  • weights – Four or five affine weight tensors, with hidden width eight and a final (4, 8) RGBA layer. Hidden layers use LeakyReLU.

  • biases – One bias per weight; the final bias has shape (4,).

  • query_face_ids – Int32 receiving-face IDs (N, Q); -1 marks unused queries. The receiving face’s own alpha is excluded.

  • query_barycentrics – Float32 3D barycentrics (N, Q, 3). Values must be nonnegative and sum to one; invalid queries have zero weights.

  • height – Source feature-image height, independent of texture size.

  • width – Source feature-image width, independent of texture size.

  • vertex_opacity – Optional float32 material opacity (N, V), clamped to [0, 1] and multiplied by appearance alpha. Defaults to one.

  • negative_slope – Hidden LeakyReLU slope, in [0, 1]. Defaults to 0.2.

  • mode – Texture filtering: "bilinear", "nearest", or "bicubic".

  • padding_mode – Texture padding: "border", "zeros", or "reflection". Sampling uses align_corners=False.

  • alpha_activation – "shifted_relu_density" (default) computes 1 - exp(-max(x + 0.5, 0)) from the fourth MLP output. Alternatives are "sigmoid", "exp_density" (1 - exp(-exp(min(x, 15)))), and "shifted_clamp" (clamp(x + 0.5, 0, 1)).

  • edge_gradients – Estimate geometry gradients at occlusion and receiving-surface boundaries. Defaults to True. Shared tessellation edges and zero-alpha edge traces have no boundary jump.

  • return_queries – Also return query UV in normalized [-1, 1] image coordinates and camera depth. Defaults to False.

  • tile_capacity – Optional maximum tile/triangle intersections across the batch, including the boundary-query halo. Keeps bin counts on the GPU and permits CUDA graph capture. Insufficient capacity raises an asynchronous CUDA error. None uses exact-sized bins.

Returns:

(tap_indices, tap_weights, query_uv, query_depth). Indices are int32 (N, Q, 4) and weights are float32 (N, Q, 4), ordered top-left, top-right, bottom-left, bottom-right. Each weight is a bilinear coefficient times transmittance; invalid taps have zero weight. Indices are flattened as y * width + x; out-of-image or unused-query taps have index -1. Query UV (N, Q, 2) and depth (N, Q) are None unless requested.

Gradients:

Smooth derivatives reach vertices, query barycentrics, UVs, material opacity, and appearance parameters. RGB output channels do not affect transmittance. Coverage boundaries contribute geometry gradients when enabled; do not apply edge_grad_estimator() again to this result. Face IDs, connectivity, and depth ordering are discrete. Second derivatives are unsupported.

The alpha activations and endpoint derivatives match the corresponding transparent renderer. In particular, final zero alpha has zero smooth gradient, while exactly opaque fragments retain their opacity gradient unless another opaque fragment blocks the query.

drtk.source_transmittance_mlp_two_textures(v_pix, vi, uv0, uv1, texture0, texture1, weights, biases, query_face_ids, query_barycentrics, height, width, *, vertex_opacity=None, negative_slope=0.2, mode='bilinear', padding_mode='border', alpha_activation='shifted_relu_density', edge_gradients=True, return_queries=False, tile_capacity=None)[source]#

Evaluate source transmittance from two feature textures and an appearance MLP.

Samples both textures with their own perspective-correct UVs, concatenates the features, and uses the alpha output of render_transparent_mlp_two_textures()’s appearance model. Use the same textures, UVs, MLP, vertex opacity, and activation in visibility and rendering to obtain consistent attenuation.

Occluders follow mean-triangle-depth order, with face index breaking ties. Queries and surface connectivity follow source_transmittance(). Sum the returned weights for transmittance, or pass them to sample_with_transmittance() to gather attenuated source features. The appearance textures must be available before this sampling step; they cannot depend on features sampled using the same transmittance.

Parameters:
  • v_pix – Float32 CUDA vertices (N, V, 3) in source pixel XY and positive camera Z. Integer XY denotes pixel centers.

  • vi – Int32 faces (F, 3) or (N, F, 3). Shared indices define connectivity; invalid or degenerate faces are ignored.

  • uv0 – First texture coordinates (V, 2), (1, V, 2), or (N, V, 2) in [0, 1].

  • uv1 – Second texture coordinates, with the same shape conventions.

  • texture0 – First feature texture (N or 1, C0, H0, W0).

  • texture1 – Second feature texture (N or 1, C1, H1, W1). The combined channel count must be in [1, 32]; resolutions may differ.

  • weights – Four or five affine weight tensors, with hidden width eight and a final (4, 8) RGBA layer. Hidden layers use LeakyReLU.

  • biases – One bias per weight; the final bias has shape (4,).

  • query_face_ids – Int32 receiving-face IDs (N, Q); -1 marks unused queries. The receiving face’s own alpha is excluded.

  • query_barycentrics – Float32 3D barycentrics (N, Q, 3). Values must be nonnegative and sum to one; invalid queries have zero weights.

  • height – Source feature-image height, independent of texture size.

  • width – Source feature-image width, independent of texture size.

  • vertex_opacity – Optional float32 material opacity (N, V), clamped to [0, 1] and multiplied by appearance alpha. Defaults to one.

  • negative_slope – Hidden LeakyReLU slope, in [0, 1]. Defaults to 0.2.

  • mode – Texture filtering: "bilinear", "nearest", or "bicubic".

  • padding_mode – Texture padding: "border", "zeros", or "reflection". Sampling uses align_corners=False.

  • alpha_activation – "shifted_relu_density" (default) computes 1 - exp(-max(x + 0.5, 0)) from the fourth MLP output. Alternatives are "sigmoid", "exp_density" (1 - exp(-exp(min(x, 15)))), and "shifted_clamp" (clamp(x + 0.5, 0, 1)).

  • edge_gradients – Estimate geometry gradients at occlusion and receiving-surface boundaries. Defaults to True. Shared tessellation edges and zero-alpha edge traces have no boundary jump.

  • return_queries – Also return query UV in normalized [-1, 1] image coordinates and camera depth. Defaults to False.

  • tile_capacity – Optional maximum tile/triangle intersections across the batch, including the boundary-query halo. Keeps bin counts on the GPU and permits CUDA graph capture. Insufficient capacity raises an asynchronous CUDA error. None uses exact-sized bins.

Returns:

(tap_indices, tap_weights, query_uv, query_depth). Indices are int32 (N, Q, 4) and weights are float32 (N, Q, 4), ordered top-left, top-right, bottom-left, bottom-right. Each weight is a bilinear coefficient times transmittance; invalid taps have zero weight. Indices are flattened as y * width + x; out-of-image or unused-query taps have index -1. Query UV (N, Q, 2) and depth (N, Q) are None unless requested.

Gradients:

Smooth derivatives reach vertices, query barycentrics, UVs, material opacity, and appearance parameters. RGB output channels do not affect transmittance. Coverage boundaries contribute geometry gradients when enabled; do not apply edge_grad_estimator() again to this result. Face IDs, connectivity, and depth ordering are discrete. Second derivatives are unsupported.

The alpha activations and endpoint derivatives match the corresponding transparent renderer. In particular, final zero alpha has zero smooth gradient, while exactly opaque fragments retain their opacity gradient unless another opaque fragment blocks the query.

drtk.sample_with_transmittance(image, tap_indices, tap_weights)[source]#

Sample an image at surface points, attenuated by source transmittance.

Use the indices and weights returned by source_transmittance(). For image values \(F_j\) and weights \(w_{qj}\), returns \(S_q=\sum_j w_{qj}F_j\) and transmittance \(c_q=\sum_j w_{qj}\). The weighted sum retains attenuation: a unit light image returns transmitted illumination. For feature images, transmittance can serve as confidence. For example, sampled + (1 - confidence) * anchor blends the observations with an existing surface feature where visibility is incomplete.

Parameters:
  • image (Tensor) – CUDA (N, C, H, W), float16, bfloat16, or float32. Arbitrary nonnegative strides, including channels-last and sliced images, are supported. The grid and batch must match the weights.

  • tap_indices (Tensor) – Int32 CUDA (N, Q, 4) from source_transmittance(). -1 and out-of-range indices contribute zero. Indices have no gradient.

  • tap_weights (Tensor) – Float32 CUDA (N, Q, 4) from source_transmittance().

Returns:

(sampled, transmittance). Samples have shape (N, C, Q) and the image dtype, with float32 accumulation. Transmittance is float32 (N, 1, Q). Gradients reach the image and weights, including zero weights with valid indices.

Return type:

Tuple[Tensor, Tensor]

Note

Only first derivatives are supported. Backward may be nondeterministic. sample_with_transmittance_ref() supports CPU and float64 inputs.

drtk.source_transmittance_ref(v_pix, vi, query_face_ids, query_barycentrics, height, width, *, vertex_opacity=None, edge_gradients=False, return_queries=False)[source]#

Reference for source_transmittance(), with smooth gradients only.

drtk.source_transmittance_texture_ref(v_pix, vi, uv, texture, query_face_ids, query_barycentrics, height, width, *, vertex_opacity=None, mode='bilinear', padding_mode='border', alpha_activation='relu_density', edge_gradients=False, return_queries=False)[source]#

Reference for source_transmittance_texture(), with smooth gradients only.

drtk.source_transmittance_mlp_ref(v_pix, vi, uv, texture, weights, biases, query_face_ids, query_barycentrics, height, width, *, vertex_opacity=None, negative_slope=0.2, mode='bilinear', padding_mode='border', alpha_activation='shifted_relu_density', edge_gradients=False, return_queries=False)[source]#

Reference for source_transmittance_mlp(), with smooth gradients only.

drtk.source_transmittance_mlp_two_textures_ref(v_pix, vi, uv0, uv1, texture0, texture1, weights, biases, query_face_ids, query_barycentrics, height, width, *, vertex_opacity=None, negative_slope=0.2, mode='bilinear', padding_mode='border', alpha_activation='shifted_relu_density', edge_gradients=False, return_queries=False)[source]#

Reference for source_transmittance_mlp_two_textures(), with smooth gradients only.

drtk.sample_with_transmittance_ref(image, tap_indices, tap_weights)[source]#

Reference for sample_with_transmittance(), supporting CPU and float64.