drtk.transparent_render#

render_transparent

Render depth-sorted transparent textured triangles.

render_transparent_mlp

Render transparent triangles from one neural feature texture.

render_transparent_mlp_two_textures

Render transparent triangles from two neural feature textures.

render_transparent_ref

Pure-PyTorch correctness reference for render_transparent().

render_transparent_mlp_ref

Pure-PyTorch correctness reference for render_transparent_mlp().

render_transparent_mlp_two_textures_ref

Pure-PyTorch correctness reference for render_transparent_mlp_two_textures().

These functions render arbitrary triangle meshes with depth-sorted transparency. Covered fragments are evaluated from front to back and composited into color, alpha, and depth images. Each function returns (rgb, alpha, depth).

Ordering uses each triangle’s mean vertex depth, not a per-pixel depth sort. This approximation suits small triangles with locally consistent ordering; intersecting or depth-crossing triangles can require a different order at different pixels and will not composite exactly. Subdivide or resolve such intersections upstream.

render_transparent samples an RGB or RGBA texture directly. render_transparent_mlp samples one feature texture before evaluating a small per-fragment appearance network, while render_transparent_mlp_two_textures samples two textures at independent uv0 and uv1 coordinates and concatenates their features. The combined MLP input may contain up to 32 channels.

When constructing textures from source images, use source_feature_stencil() and sample_feature_stencil() to account for occlusion. The rendering functions sample the supplied texture values at their UV coordinates.

All variants support nearest, bilinear, and bicubic filtering together with zeros, border, and reflection padding. Texture coordinates use align_corners=False semantics. They differentiate compositing, perspective-correct interpolation, texture sampling, vertex opacity, and interior vertex motion. Triangle topology and depth ordering remain discrete. All CUDA entry points add transparent silhouette gradients to vertex X/Y motion by default. Set edge_gradients=False to disable the boundary estimator. The forward image, compositing order, and appearance gradients are unchanged.

Depth outputs#

Each fragment contributes its perspective-correct interpolated camera Z. This is neither distance along the viewing ray nor the triangle-center Z used for sorting. Define foreground weights, accumulated depth, and opacity as

\[T_i=\prod_{j<i}(1-\alpha_j),\qquad S=\sum_i T_i\alpha_i z_i,\qquad A=\sum_i T_i\alpha_i.\]

All rendering functions and their reference counterparts accept these depth modes:

depth_mode

Output

Empty or insufficient-opacity pixel

"expected" (default)

\(S+T_{\mathrm{end}}z_{\mathrm{background}}\)

Background depth

"accumulated"

Unnormalized foreground sum \(S\)

Zero

"foreground_mean"

\(S/A\), when \(A\) exceeds depth_alpha_threshold

Background depth

"median"

First fragment where cumulative foreground opacity reaches 0.5

Background depth if no fragment reaches 0.5

The expected-depth background is an opaque final layer: its weight is the remaining transmittance, so no alpha normalization is needed. Set background_depth to a finite positive camera Z appropriate for the scene. The default is 1000 in the same units as vertex Z. This setting is independent of the RGB background, and the returned alpha always remains foreground opacity. A very distant background produces stronger depth-loss gradients at opacity changes and silhouettes.

Foreground mean defaults to depth_alpha_threshold=1e-6. Pixels at or below that threshold return background depth with zero smooth depth gradient, avoiding division by very small opacity.

Expected, accumulated, and valid foreground-mean depth have smooth geometry and opacity gradients while coverage and ordering are fixed. Median has only the selected fragment’s smooth depth gradient: its threshold decision does not provide a smooth opacity derivative. Mean-depth validity is also a hard decision. The silhouette estimator includes the selected depth mode, including median; it does not differentiate depth-order swaps or median selection changes caused by opacity alone.

rgb, alpha, depth = drtk.render_transparent(
    v, vi, uv, texture, height, width,
    depth_mode="expected", background_depth=100.0,
)

Transparent edge gradients#

This estimator extends Rasterized Edge Gradients to transparent compositing. It averages the two neighboring pixels’ loss-weighted insertion/removal effects at each geometric edge crossing. Each pixel supplies its own foreground attenuation and suffix composite at the queried triangle’s position in the existing sort order. Final RGB/alpha alone cannot recover this information. A depth loss also compares the two ordered depth composites, including normalization or median selection where requested.

Common indexed edges between triangles on opposite projected sides are ordinary tessellation and produce no boundary term. Incident triangles that fold onto the same side move together at their shared edge; their alpha interaction is evaluated jointly. Material opacity and sampled appearance are evaluated at the geometric edge. A zero-alpha edge therefore contributes zero even if nearby interior samples have nonzero alpha. Saturating an opacity activation does not suppress a nonzero silhouette gradient.

Only vertex X/Y gradients receive this extra term. There are no derivatives of per-triangle ordering, topology, triangle intersections, or clipping at the image boundary. Separate coincident vertices remain separate geometry; callers should share indices where they intend a continuous, jointly moving edge. The reference functions support smooth/interior derivatives only.

Appearance activations#

Direct textures and neural appearance outputs use separate activation contracts because their natural parameter ranges differ.

For direct RGB or RGBA textures, RGB defaults to max(x, 0) ("relu"). The alternatives are "identity", "shifted_sigmoid" (sigmoid(x - 0.5)), and "clamp". Texture alpha defaults to 1 - exp(-max(x, 0)) ("relu_density"). Its alternatives are "shifted_sigmoid", "exp_density" (1 - exp(-exp(x))), and "clamp". An RGB texture has implicit alpha one. Use rgb_activation="identity" and alpha_activation="clamp" for a conventional RGBA texture whose channels already represent display color and opacity.

For direct texture rendering, activation occurs after texture filtering. Consequently, neighboring texels on opposite sides of the ReLU boundary can produce an active interpolated value. Backpropagation through that filtered sample distributes gradient to all contributing texels, including a texel whose value would be in the dead region if sampled alone. The MLP variants likewise activate only after feature filtering and the final affine layer.

The MLP output is naturally centered near zero. MLP RGB therefore defaults to max(x + 0.5, 0) ("shifted_relu"), and also supports "shifted_identity" (x + 0.5), "sigmoid", and "shifted_clamp" (clamp(x + 0.5, 0, 1)). MLP alpha defaults to 1 - exp(-max(x + 0.5, 0)) ("shifted_relu_density"), and also supports "sigmoid", "exp_density", and "shifted_clamp". Thus a raw MLP RGB value of zero maps to 0.5 for every bounded or shifted RGB option. A raw MLP alpha value of zero maps to 1 - exp(-0.5) for the default density mapping or 0.5 for sigmoid and shifted clamp.

The density mappings interpret a nonnegative value as optical density and convert it to opacity. They are mathematically below one without the two-sided saturation of a sigmoid. In particular, the ReLU zero set can describe complex contours in a learned field, which is the level-set behavior highlighted by ReLU Fields: The Little Non-linearity That Could. The half-unit shifts and density-to-opacity mapping are this renderer’s parameterization choices. Here optical density means per-fragment optical thickness; no world-space path length is integrated. "exp_density" corresponds to an exponential density followed by the density-to-opacity conversion used by Instant-NGP-style volume models. Its raw input is capped at 15 before exponentiation to avoid overflow. At sufficiently large density, float32 can still round the resulting opacity to exactly one; the fragment alpha cap below handles that case before compositing.

Final fragment alpha is capped slightly below one after multiplying appearance alpha by interpolated vertex opacity. This fixed numerical limit is not a material parameter. Gradients remain defined even when the returned image alpha rounds to one.

Appearance, material-opacity, and upper safety clamps use a unit subgradient at an exact endpoint and zero outside the interval. This is an explicit DRTK convention shared by the native operators and reference functions; it does not depend on the installed PyTorch build’s scalar-clamp convention. ReLU uses zero gradient at zero, including the lower bound on final fragment alpha.

Differentiable rendering of depth-sorted transparent triangles.

The optimized operators in this module combine triangle coverage, perspective-correct attribute interpolation, texture/feature sampling, and front-to-back alpha compositing. Keeping those operations together avoids materializing a fragment buffer whose size is proportional to overdraw.

Sorting uses mean vertex depth for each triangle. It is an approximation for small triangles with consistent local ordering, not a per-pixel depth sort: intersecting or depth-crossing triangles can composite in the wrong order. Independent feature UV sets do not perform visibility/provenance gating; callers must reject samples from unrelated surfaces before appearance shading.

The *_ref functions are intentionally simple PyTorch implementations. They are correctness oracles for tests and small experiments, not production renderers: their complexity is O(batch * faces * height * width).

Appearance and opacity clamps use a unit subgradient at their endpoints and zero outside the interval. This convention is explicit in the references, independent of the installed PyTorch build. ReLU retains zero gradient at zero, including the lower bound on final fragment alpha.

drtk.render_transparent(v, vi, uv, texture, height, width, opacity=None, background=None, mode='bilinear', padding_mode='border', transmittance_epsilon=0.0, rgb_activation='relu', alpha_activation='relu_density', edge_gradients=True, *, depth_mode='expected', background_depth=1000.0, depth_alpha_threshold=1e-06)[source]#

Render depth-sorted transparent textured triangles.

Triangles are composited front-to-back in stable mean-camera-depth order, with face index breaking ties. Interpolation is perspective-correct. Intersecting or depth-crossing triangles can composite in the wrong order; per-pixel sorting is not supported.

Gradients propagate through texture sampling, interpolation, opacity, and compositing. Visibility-boundary gradients are enabled by default through edge_gradients=True. Ordinary shared tessellation edges and zero-alpha borders contribute no boundary term. Set transmittance_epsilon only for inference: nonzero values permit early termination.

This function requires CUDA. render_transparent_ref() is available for CPU use and supports smooth gradients only.

Parameters:
  • v – Screen-space vertices [N, V, 3]. X/Y use DRTK pixel coordinates and smaller positive Z values are nearer.

  • vi – Int32 triangle indices [F, 3], [1, F, 3], or [N, F, 3].

  • uv – Per-vertex normalized texture coordinates in [0, 1].

  • texture – RGB or RGBA texture [N or 1, 3 or 4, Ht, Wt].

  • height – Output image height.

  • width – Output image width.

  • opacity – Optional per-vertex material opacity [N or 1, V].

  • background – Optional RGB background [3] or [N or 1, 3].

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

  • padding_mode – Texture padding mode: "zeros", "border", or "reflection". Texture coordinates always use align_corners=False semantics.

  • transmittance_epsilon – Optional inference-only early-termination threshold. It must be zero when gradients are enabled.

  • rgb_activation – Activation applied to filtered RGB. The default "relu" computes max(x, 0). Alternatives are "identity", "shifted_sigmoid" (sigmoid(x - 0.5)), and "clamp".

  • alpha_activation – Activation applied to filtered texture alpha. The default "relu_density" computes 1 - exp(-max(x, 0)). Alternatives are "shifted_sigmoid" (sigmoid(x - 0.5)), Instant-NGP-style "exp_density" (1 - exp(-exp(x)), with x capped at 15 before exponentiation), and "clamp".

  • edge_gradients – Add transparent coverage-boundary gradients to vertex X/Y motion. Defaults to True; set to False to disable. This is a filtered-surrogate estimator, not the pointwise derivative of hard coverage. It uses the same mean-triangle-depth order and adds no inference work. Indexed shared tessellation edges and zero-alpha edge traces are suppressed; folded shared boundaries are composited as a bundle. The reference functions retain smooth/interior gradients only.

  • depth_mode – "expected" (default) composites camera-space Z with an opaque background at background_depth. "accumulated" returns only the foreground sum of transmittance * alpha * Z. "foreground_mean" divides that sum by foreground alpha only above depth_alpha_threshold; other pixels return background depth with zero smooth depth gradient. "median" selects the first fragment whose cumulative foreground alpha reaches 0.5, or the background if no fragment does. All modes use the same stable mean-triangle-depth order as RGB, without per-pixel sorting.

  • background_depth – Positive finite background camera Z, in the same units as v[..., 2]. Defaults to 1000. Set it to an appropriate far depth for the scene; it is independent of RGB background. Infinity is not supported. A distant background increases the depth-loss signal for opacity and silhouette changes.

  • depth_alpha_threshold – Minimum foreground alpha for a valid mean depth. Defaults to 1e-6. The division is not evaluated through small or zero alpha; invalid pixels have zero smooth depth gradient. This threshold only affects "foreground_mean".

Returns:

A tuple (rgb, alpha, depth) with shapes [N, 3, H, W], [N, 1, H, W], and [N, 1, H, W]. RGB is premultiplied unless a background is supplied. Alpha always describes foreground opacity, even when depth includes an opaque background. Fragment depth is perspective-correct interpolated camera Z, not ray distance or the triangle-center depth used for sorting.

Expected, accumulated, and valid foreground-mean depth differentiate geometry and opacity. Median differentiates the selected fragment’s depth, with no smooth opacity gradient through its discrete selection. Ordering and the foreground-mean validity test are also discrete. Boundary gradients include the chosen depth output when edge_gradients=True; reference implementations retain only smooth derivatives with coverage fixed.

drtk.render_transparent_mlp(v, vi, uv, texture, weights, biases, height, width, opacity=None, background=None, negative_slope=0.2, mode='bilinear', padding_mode='border', transmittance_epsilon=0.0, rgb_activation='shifted_relu', alpha_activation='shifted_relu_density', edge_gradients=True, *, depth_mode='expected', background_depth=1000.0, depth_alpha_threshold=1e-06)[source]#

Render transparent triangles from one neural feature texture.

Samples texture at each fragment’s interpolated uv and evaluates an appearance MLP to obtain RGBA. The MLP must have four or five affine layers, hidden width eight, and LeakyReLU hidden activations. Gradients propagate to geometry, UVs, texture, opacity, background, weights, and biases.

rgb_activation defaults to "shifted_relu", which computes max(x + 0.5, 0). It also accepts "shifted_identity" (x + 0.5), "sigmoid" (sigmoid(x)), and "shifted_clamp" (clamp(x + 0.5, 0, 1)). alpha_activation defaults to "shifted_relu_density", which computes 1 - exp(-max(x + 0.5, 0)). It also accepts "sigmoid", "exp_density" (1 - exp(-exp(x)), with x capped at 15 before exponentiation), and "shifted_clamp". The shifts make a zero-centered MLP output represent a useful mid-range value. Activation follows feature filtering and MLP evaluation.

Triangles are composited in ascending mean camera-depth order, with face index breaking ties. This approximates per-pixel ordering; intersecting or depth-crossing triangles may composite in the wrong order. There is no hard z-buffer. Hard top-left coverage and clamped interpolated material opacity remain outside the MLP. The resulting fragment alpha is capped at 0.999 before front-to-back transmittance compositing. For soft boundaries, supply explicitly feathered geometry or opacity.

This entry point requires CUDA. Use render_transparent_mlp_ref() for the pure-PyTorch correctness implementation.

Parameters:
  • v – Screen-space vertices [N, V, 3]. X/Y use DRTK pixel coordinates and smaller positive Z values are nearer.

  • vi – Int32 triangle indices [F, 3], [1, F, 3], or [N, F, 3].

  • uv – Per-vertex normalized coordinates [V, 2], [1, V, 2], or [N, V, 2] for texture.

  • texture – Feature texture [N or 1, C, Ht, Wt], where 1 <= C <= 32.

  • weights – Four or five affine weight tensors. Hidden outputs have width eight and the final weight has shape [4, 8].

  • biases – One bias tensor per weight; the final bias has shape [4].

  • height – Output image height.

  • width – Output image width.

  • opacity – Optional per-vertex material opacity [V], [1, V], or [N, V]. The default is one.

  • background – Optional RGB background [3] or [N or 1, 3].

  • negative_slope – LeakyReLU slope for hidden MLP activations.

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

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

  • transmittance_epsilon – Optional inference-only early-termination threshold in [0, 1). It must be zero when gradients are enabled.

  • rgb_activation – Final RGB activation described above.

  • alpha_activation – Final appearance-alpha activation described above.

  • edge_gradients – Add transparent coverage-boundary gradients to vertex X/Y motion. Defaults to True; set to False to disable. This is a filtered-surrogate estimator, not the pointwise derivative of hard coverage. It uses the same mean-triangle-depth order and adds no inference work. Indexed shared tessellation edges and zero-alpha edge traces are suppressed; folded shared boundaries are composited as a bundle. The reference functions retain smooth/interior gradients only.

  • depth_mode – "expected" (default) composites camera-space Z with an opaque background at background_depth. "accumulated" returns only the foreground sum of transmittance * alpha * Z. "foreground_mean" divides that sum by foreground alpha only above depth_alpha_threshold; other pixels return background depth with zero smooth depth gradient. "median" selects the first fragment whose cumulative foreground alpha reaches 0.5, or the background if no fragment does. All modes use the same stable mean-triangle-depth order as RGB, without per-pixel sorting.

  • background_depth – Positive finite background camera Z, in the same units as v[..., 2]. Defaults to 1000. Set it to an appropriate far depth for the scene; it is independent of RGB background. Infinity is not supported. A distant background increases the depth-loss signal for opacity and silhouette changes.

  • depth_alpha_threshold – Minimum foreground alpha for a valid mean depth. Defaults to 1e-6. The division is not evaluated through small or zero alpha; invalid pixels have zero smooth depth gradient. This threshold only affects "foreground_mean".

Returns:

A tuple (rgb, alpha, depth) with shapes [N, 3, H, W], [N, 1, H, W], and [N, 1, H, W]. RGB is premultiplied unless a background is supplied. Alpha always describes foreground opacity, even when depth includes an opaque background. Fragment depth is perspective-correct interpolated camera Z, not ray distance or the triangle-center depth used for sorting.

Expected, accumulated, and valid foreground-mean depth differentiate geometry and opacity. Median differentiates the selected fragment’s depth, with no smooth opacity gradient through its discrete selection. Ordering and the foreground-mean validity test are also discrete. Boundary gradients include the chosen depth output when edge_gradients=True; reference implementations retain only smooth derivatives with coverage fixed.

drtk.render_transparent_mlp_two_textures(v, vi, uv0, uv1, texture0, texture1, weights, biases, height, width, opacity=None, background=None, negative_slope=0.2, mode='bilinear', padding_mode='border', transmittance_epsilon=0.0, rgb_activation='shifted_relu', alpha_activation='shifted_relu_density', edge_gradients=True, *, depth_mode='expected', background_depth=1000.0, depth_alpha_threshold=1e-06)[source]#

Render transparent triangles from two neural feature textures.

Samples texture0 at interpolated uv0 and texture1 at uv1, concatenates their feature vectors in that order, and evaluates an appearance MLP to obtain RGBA. The MLP must have four or five affine layers, hidden width eight, and LeakyReLU hidden activations. Gradients propagate to geometry, both UV sets and textures, opacity, background, weights, and biases.

rgb_activation defaults to "shifted_relu", which computes max(x + 0.5, 0). It also accepts "shifted_identity" (x + 0.5), "sigmoid" (sigmoid(x)), and "shifted_clamp" (clamp(x + 0.5, 0, 1)). alpha_activation defaults to "shifted_relu_density", which computes 1 - exp(-max(x + 0.5, 0)). It also accepts "sigmoid", "exp_density" (1 - exp(-exp(x)), with x capped at 15 before exponentiation), and "shifted_clamp". The shifts make a zero-centered MLP output represent a useful mid-range value. Activation follows feature filtering and MLP evaluation.

Triangles are composited in ascending mean camera-depth order, with face index breaking ties. This approximates per-pixel ordering; intersecting or depth-crossing triangles may composite in the wrong order. There is no hard z-buffer. Hard top-left coverage and clamped interpolated material opacity remain outside the MLP. The resulting fragment alpha is capped at 0.999 before front-to-back transmittance compositing. For soft boundaries, supply explicitly feathered geometry or opacity.

This entry point requires CUDA. Use render_transparent_mlp_two_textures_ref() for the pure-PyTorch correctness implementation.

The caller must gate features from occluded or unrelated surfaces and provide visibility/provenance validity information where needed. Separate UV coordinates do not perform this gating automatically.

Parameters:
  • v – Screen-space vertices [N, V, 3]. X/Y use DRTK pixel coordinates and smaller positive Z values are nearer.

  • vi – Int32 triangle indices [F, 3], [1, F, 3], or [N, F, 3].

  • uv0 – Per-vertex normalized coordinates [V, 2], [1, V, 2], or [N, V, 2] for texture0.

  • uv1 – Per-vertex normalized coordinates with the same supported shapes as uv0 for texture1.

  • texture0 – First feature texture [N or 1, C0, H0, W0].

  • texture1 – Second feature texture [N or 1, C1, H1, W1]. The channel counts must satisfy 1 <= C0 + C1 <= 32.

  • weights – Four or five affine weight tensors. Hidden outputs have width eight and the final weight has shape [4, 8].

  • biases – One bias tensor per weight; the final bias has shape [4].

  • height – Output image height.

  • width – Output image width.

  • opacity – Optional per-vertex material opacity [V], [1, V], or [N, V]. The default is one.

  • background – Optional RGB background [3] or [N or 1, 3].

  • negative_slope – LeakyReLU slope for hidden MLP activations.

  • mode – Interpolation mode shared by both textures: "bilinear", "nearest", or "bicubic".

  • padding_mode – Padding mode shared by both textures: "zeros", "border", or "reflection". Sampling always uses align_corners=False semantics.

  • transmittance_epsilon – Optional inference-only early-termination threshold in [0, 1). It must be zero when gradients are enabled.

  • rgb_activation – Final RGB activation described above.

  • alpha_activation – Final appearance-alpha activation described above.

  • edge_gradients – Add transparent coverage-boundary gradients to vertex X/Y motion. Defaults to True; set to False to disable. This is a filtered-surrogate estimator, not the pointwise derivative of hard coverage. It uses the same mean-triangle-depth order and adds no inference work. Indexed shared tessellation edges and zero-alpha edge traces are suppressed; folded shared boundaries are composited as a bundle. The reference functions retain smooth/interior gradients only.

  • depth_mode – "expected" (default) composites camera-space Z with an opaque background at background_depth. "accumulated" returns only the foreground sum of transmittance * alpha * Z. "foreground_mean" divides that sum by foreground alpha only above depth_alpha_threshold; other pixels return background depth with zero smooth depth gradient. "median" selects the first fragment whose cumulative foreground alpha reaches 0.5, or the background if no fragment does. All modes use the same stable mean-triangle-depth order as RGB, without per-pixel sorting.

  • background_depth – Positive finite background camera Z, in the same units as v[..., 2]. Defaults to 1000. Set it to an appropriate far depth for the scene; it is independent of RGB background. Infinity is not supported. A distant background increases the depth-loss signal for opacity and silhouette changes.

  • depth_alpha_threshold – Minimum foreground alpha for a valid mean depth. Defaults to 1e-6. The division is not evaluated through small or zero alpha; invalid pixels have zero smooth depth gradient. This threshold only affects "foreground_mean".

Returns:

A tuple (rgb, alpha, depth) with shapes [N, 3, H, W], [N, 1, H, W], and [N, 1, H, W]. RGB is premultiplied unless a background is supplied. Alpha always describes foreground opacity, even when depth includes an opaque background. Fragment depth is perspective-correct interpolated camera Z, not ray distance or the triangle-center depth used for sorting.

Expected, accumulated, and valid foreground-mean depth differentiate geometry and opacity. Median differentiates the selected fragment’s depth, with no smooth opacity gradient through its discrete selection. Ordering and the foreground-mean validity test are also discrete. Boundary gradients include the chosen depth output when edge_gradients=True; reference implementations retain only smooth derivatives with coverage fixed.

drtk.render_transparent_ref(v, vi, uv, texture, height, width, opacity=None, background=None, mode='bilinear', padding_mode='border', rgb_activation='relu', alpha_activation='relu_density', *, depth_mode='expected', background_depth=1000.0, depth_alpha_threshold=1e-06)[source]#

Pure-PyTorch correctness reference for render_transparent().

See the main function for the argument and return-value contract. This CPU/CUDA reference differentiates smooth shading and compositing with coverage and triangle order fixed. It does not implement the CUDA entry point’s silhouette-gradient estimator or early termination.

drtk.render_transparent_mlp_ref(v, vi, uv, texture, weights, biases, height, width, opacity=None, background=None, negative_slope=0.2, mode='bilinear', padding_mode='border', rgb_activation='shifted_relu', alpha_activation='shifted_relu_density', *, depth_mode='expected', background_depth=1000.0, depth_alpha_threshold=1e-06)[source]#

Pure-PyTorch correctness reference for render_transparent_mlp().

See the main function for the argument and return-value contract. This CPU/CUDA reference differentiates smooth shading and compositing with coverage and triangle order fixed. It does not implement the CUDA entry point’s silhouette-gradient estimator or early termination.

drtk.render_transparent_mlp_two_textures_ref(v, vi, uv0, uv1, texture0, texture1, weights, biases, height, width, opacity=None, background=None, negative_slope=0.2, mode='bilinear', padding_mode='border', rgb_activation='shifted_relu', alpha_activation='shifted_relu_density', *, depth_mode='expected', background_depth=1000.0, depth_alpha_threshold=1e-06)[source]#

Pure-PyTorch correctness reference for render_transparent_mlp_two_textures().

See the main function for the argument and return-value contract. This CPU/CUDA reference differentiates smooth shading and compositing with coverage and triangle order fixed. It does not implement the CUDA entry point’s silhouette-gradient estimator or early termination.