carson-katri 2022-11-20 23:16:41 +00:00
rodzic bbc3bac999
commit 7361f198a5
4 zmienionych plików z 28 dodań i 62 usunięć

Wyświetl plik

@ -136,57 +136,40 @@
<div id="content" class="content">
<main>
<h1 id="attributes"><a class="header" href="#attributes">Attributes</a></h1>
<p>An important concept in Geometry Nodes is attributes. Many trees transfer attributes between geometry, using a combination of <em>Capture Attribute</em> and <em>Transfer Attribute</em>.</p>
<p>Unfortunately, it takes quite a bit of code to use this common pattern.</p>
<p>An important concept in Geometry Nodes is attributes. Many trees capture attributes or transfer them from one geometry to another.</p>
<p>When using these methods, the <code>data_type</code> argument must be correctly specified for the transfer to work as intended.</p>
<pre><code class="language-python">@tree(&quot;Skin&quot;)
def skin():
# Create a cube
c = cube()
# Capture the position
cube_position_attribute = c.capture_attribute(
data_type=CaptureAttribute.DataType.FLOAT_VECTOR,
value=position()
)
# Create a sphere
sphere = uv_sphere()
# Transfer the position to the sphere
transferred_position = cube_position_attribute.geometry.transfer_attribute(
transferred_position = c.transfer_attribute(
data_type=TransferAttribute.DataType.FLOAT_VECTOR,
attribute=cube_position_attribute.attribute
attribute=position()
)
# Make the sphere conform to the shape of the cube
return sphere.set_position(position=transferred_position)
</code></pre>
<p>Thankfully, a convenient <code>capture(...)</code> method is available on <code>Geometry</code>, which simplifies this function quite a bit.</p>
<p>To improve the usability of these nodes, <code>capture(...)</code> and <code>transfer(...)</code> methods are provided on <code>Geometry</code> that simply take the attribute and any other optional arguments.</p>
<pre><code class="language-python">@tree(&quot;Skin&quot;)
def skin():
# Create a cube
c = cube()
# Capture the position
cube_position = c.capture(position())
# Create a sphere
sphere = uv_sphere()
# Make the sphere conform to the shape of the cube
return sphere.set_position(position=cube_position())
return sphere.set_position(position=c.transfer(position()))
</code></pre>
<h2 id="how-it-works"><a class="header" href="#how-it-works">How it Works</a></h2>
<p>Internally, <code>capture(...)</code> works just like the more manual approach.</p>
<ol>
<li>Capture the attribute from the source</li>
</ol>
<p>In the example above, we capture the <code>position()</code> from the cube.
The data type is automatically inferred from the input. If you want to customize other options, simply pass them as keyword arguments to <code>capture(...)</code>.</p>
<pre><code class="language-python">cube_position = c.capture(position())
cube_position = c.capture(position(), domain=CaptureAttribute.Domain.FACE) # Optionally pass other arguments available on `capture_attribute`.
<p>The same is available for <code>capture(...)</code>.</p>
<pre><code class="language-python">geometry_with_attribute, attribute = c.capture(position())
</code></pre>
<ol start="2">
<li>Transfer the attribute to the target</li>
</ol>
<p><code>capture(...)</code> returns another function that calls <code>transfer_attribute</code> with the correct arguments passed automatically.
Call this returned function (which we store in the variable <code>cube_position</code>) to transfer the attribute.
In this example we also set the transferred cube position back onto the sphere.</p>
<pre><code class="language-python">sphere.set_position(position=cube_position())
sphere.set_position(position=cube_position(mapping=TransferAttribute.Mapping.NEAREST)) # Optionally pass other arguments available on `transfer_attribute`.
<blockquote>
<p>You must use the <code>Geometry</code> returned from <code>capture(...)</code> for the anonymous attribute it creates to be usable.</p>
</blockquote>
<p>Any additional keyword arguments can be passed as normal.</p>
<pre><code class="language-python">c.transfer(position(), mapping=TransferAttribute.Mapping.INDEX)
</code></pre>
</main>

Wyświetl plik

@ -695,57 +695,40 @@ def terrain_generator(
)
</code></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="attributes"><a class="header" href="#attributes">Attributes</a></h1>
<p>An important concept in Geometry Nodes is attributes. Many trees transfer attributes between geometry, using a combination of <em>Capture Attribute</em> and <em>Transfer Attribute</em>.</p>
<p>Unfortunately, it takes quite a bit of code to use this common pattern.</p>
<p>An important concept in Geometry Nodes is attributes. Many trees capture attributes or transfer them from one geometry to another.</p>
<p>When using these methods, the <code>data_type</code> argument must be correctly specified for the transfer to work as intended.</p>
<pre><code class="language-python">@tree(&quot;Skin&quot;)
def skin():
# Create a cube
c = cube()
# Capture the position
cube_position_attribute = c.capture_attribute(
data_type=CaptureAttribute.DataType.FLOAT_VECTOR,
value=position()
)
# Create a sphere
sphere = uv_sphere()
# Transfer the position to the sphere
transferred_position = cube_position_attribute.geometry.transfer_attribute(
transferred_position = c.transfer_attribute(
data_type=TransferAttribute.DataType.FLOAT_VECTOR,
attribute=cube_position_attribute.attribute
attribute=position()
)
# Make the sphere conform to the shape of the cube
return sphere.set_position(position=transferred_position)
</code></pre>
<p>Thankfully, a convenient <code>capture(...)</code> method is available on <code>Geometry</code>, which simplifies this function quite a bit.</p>
<p>To improve the usability of these nodes, <code>capture(...)</code> and <code>transfer(...)</code> methods are provided on <code>Geometry</code> that simply take the attribute and any other optional arguments.</p>
<pre><code class="language-python">@tree(&quot;Skin&quot;)
def skin():
# Create a cube
c = cube()
# Capture the position
cube_position = c.capture(position())
# Create a sphere
sphere = uv_sphere()
# Make the sphere conform to the shape of the cube
return sphere.set_position(position=cube_position())
return sphere.set_position(position=c.transfer(position()))
</code></pre>
<h2 id="how-it-works"><a class="header" href="#how-it-works">How it Works</a></h2>
<p>Internally, <code>capture(...)</code> works just like the more manual approach.</p>
<ol>
<li>Capture the attribute from the source</li>
</ol>
<p>In the example above, we capture the <code>position()</code> from the cube.
The data type is automatically inferred from the input. If you want to customize other options, simply pass them as keyword arguments to <code>capture(...)</code>.</p>
<pre><code class="language-python">cube_position = c.capture(position())
cube_position = c.capture(position(), domain=CaptureAttribute.Domain.FACE) # Optionally pass other arguments available on `capture_attribute`.
<p>The same is available for <code>capture(...)</code>.</p>
<pre><code class="language-python">geometry_with_attribute, attribute = c.capture(position())
</code></pre>
<ol start="2">
<li>Transfer the attribute to the target</li>
</ol>
<p><code>capture(...)</code> returns another function that calls <code>transfer_attribute</code> with the correct arguments passed automatically.
Call this returned function (which we store in the variable <code>cube_position</code>) to transfer the attribute.
In this example we also set the transferred cube position back onto the sphere.</p>
<pre><code class="language-python">sphere.set_position(position=cube_position())
sphere.set_position(position=cube_position(mapping=TransferAttribute.Mapping.NEAREST)) # Optionally pass other arguments available on `transfer_attribute`.
<blockquote>
<p>You must use the <code>Geometry</code> returned from <code>capture(...)</code> for the anonymous attribute it creates to be usable.</p>
</blockquote>
<p>Any additional keyword arguments can be passed as normal.</p>
<pre><code class="language-python">c.transfer(position(), mapping=TransferAttribute.Mapping.INDEX)
</code></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="voxelize"><a class="header" href="#voxelize">Voxelize</a></h1>
<p>This tutorial walks you through creating a script that turns any mesh into voxels.</p>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long