kopia lustrzana https://github.com/carson-katri/geometry-script
deploy: f50fa922be
rodzic
bbc3bac999
commit
7361f198a5
|
@ -136,57 +136,40 @@
|
||||||
<div id="content" class="content">
|
<div id="content" class="content">
|
||||||
<main>
|
<main>
|
||||||
<h1 id="attributes"><a class="header" href="#attributes">Attributes</a></h1>
|
<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>An important concept in Geometry Nodes is attributes. Many trees capture attributes or transfer them from one geometry to another.</p>
|
||||||
<p>Unfortunately, it takes quite a bit of code to use this common pattern.</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("Skin")
|
<pre><code class="language-python">@tree("Skin")
|
||||||
def skin():
|
def skin():
|
||||||
# Create a cube
|
# Create a cube
|
||||||
c = cube()
|
c = cube()
|
||||||
# Capture the position
|
|
||||||
cube_position_attribute = c.capture_attribute(
|
|
||||||
data_type=CaptureAttribute.DataType.FLOAT_VECTOR,
|
|
||||||
value=position()
|
|
||||||
)
|
|
||||||
# Create a sphere
|
# Create a sphere
|
||||||
sphere = uv_sphere()
|
sphere = uv_sphere()
|
||||||
# Transfer the position to the 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,
|
data_type=TransferAttribute.DataType.FLOAT_VECTOR,
|
||||||
attribute=cube_position_attribute.attribute
|
attribute=position()
|
||||||
)
|
)
|
||||||
# Make the sphere conform to the shape of the cube
|
# Make the sphere conform to the shape of the cube
|
||||||
return sphere.set_position(position=transferred_position)
|
return sphere.set_position(position=transferred_position)
|
||||||
</code></pre>
|
</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("Skin")
|
<pre><code class="language-python">@tree("Skin")
|
||||||
def skin():
|
def skin():
|
||||||
# Create a cube
|
# Create a cube
|
||||||
c = cube()
|
c = cube()
|
||||||
# Capture the position
|
|
||||||
cube_position = c.capture(position())
|
|
||||||
# Create a sphere
|
# Create a sphere
|
||||||
sphere = uv_sphere()
|
sphere = uv_sphere()
|
||||||
# Make the sphere conform to the shape of the cube
|
# 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>
|
</code></pre>
|
||||||
<h2 id="how-it-works"><a class="header" href="#how-it-works">How it Works</a></h2>
|
<p>The same is available for <code>capture(...)</code>.</p>
|
||||||
<p>Internally, <code>capture(...)</code> works just like the more manual approach.</p>
|
<pre><code class="language-python">geometry_with_attribute, attribute = c.capture(position())
|
||||||
<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`.
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<ol start="2">
|
<blockquote>
|
||||||
<li>Transfer the attribute to the target</li>
|
<p>You must use the <code>Geometry</code> returned from <code>capture(...)</code> for the anonymous attribute it creates to be usable.</p>
|
||||||
</ol>
|
</blockquote>
|
||||||
<p><code>capture(...)</code> returns another function that calls <code>transfer_attribute</code> with the correct arguments passed automatically.
|
<p>Any additional keyword arguments can be passed as normal.</p>
|
||||||
Call this returned function (which we store in the variable <code>cube_position</code>) to transfer the attribute.
|
<pre><code class="language-python">c.transfer(position(), mapping=TransferAttribute.Mapping.INDEX)
|
||||||
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`.
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
43
print.html
43
print.html
|
@ -695,57 +695,40 @@ def terrain_generator(
|
||||||
)
|
)
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<div style="break-before: page; page-break-before: always;"></div><h1 id="attributes"><a class="header" href="#attributes">Attributes</a></h1>
|
<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>An important concept in Geometry Nodes is attributes. Many trees capture attributes or transfer them from one geometry to another.</p>
|
||||||
<p>Unfortunately, it takes quite a bit of code to use this common pattern.</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("Skin")
|
<pre><code class="language-python">@tree("Skin")
|
||||||
def skin():
|
def skin():
|
||||||
# Create a cube
|
# Create a cube
|
||||||
c = cube()
|
c = cube()
|
||||||
# Capture the position
|
|
||||||
cube_position_attribute = c.capture_attribute(
|
|
||||||
data_type=CaptureAttribute.DataType.FLOAT_VECTOR,
|
|
||||||
value=position()
|
|
||||||
)
|
|
||||||
# Create a sphere
|
# Create a sphere
|
||||||
sphere = uv_sphere()
|
sphere = uv_sphere()
|
||||||
# Transfer the position to the 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,
|
data_type=TransferAttribute.DataType.FLOAT_VECTOR,
|
||||||
attribute=cube_position_attribute.attribute
|
attribute=position()
|
||||||
)
|
)
|
||||||
# Make the sphere conform to the shape of the cube
|
# Make the sphere conform to the shape of the cube
|
||||||
return sphere.set_position(position=transferred_position)
|
return sphere.set_position(position=transferred_position)
|
||||||
</code></pre>
|
</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("Skin")
|
<pre><code class="language-python">@tree("Skin")
|
||||||
def skin():
|
def skin():
|
||||||
# Create a cube
|
# Create a cube
|
||||||
c = cube()
|
c = cube()
|
||||||
# Capture the position
|
|
||||||
cube_position = c.capture(position())
|
|
||||||
# Create a sphere
|
# Create a sphere
|
||||||
sphere = uv_sphere()
|
sphere = uv_sphere()
|
||||||
# Make the sphere conform to the shape of the cube
|
# 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>
|
</code></pre>
|
||||||
<h2 id="how-it-works"><a class="header" href="#how-it-works">How it Works</a></h2>
|
<p>The same is available for <code>capture(...)</code>.</p>
|
||||||
<p>Internally, <code>capture(...)</code> works just like the more manual approach.</p>
|
<pre><code class="language-python">geometry_with_attribute, attribute = c.capture(position())
|
||||||
<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`.
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<ol start="2">
|
<blockquote>
|
||||||
<li>Transfer the attribute to the target</li>
|
<p>You must use the <code>Geometry</code> returned from <code>capture(...)</code> for the anonymous attribute it creates to be usable.</p>
|
||||||
</ol>
|
</blockquote>
|
||||||
<p><code>capture(...)</code> returns another function that calls <code>transfer_attribute</code> with the correct arguments passed automatically.
|
<p>Any additional keyword arguments can be passed as normal.</p>
|
||||||
Call this returned function (which we store in the variable <code>cube_position</code>) to transfer the attribute.
|
<pre><code class="language-python">c.transfer(position(), mapping=TransferAttribute.Mapping.INDEX)
|
||||||
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`.
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<div style="break-before: page; page-break-before: always;"></div><h1 id="voxelize"><a class="header" href="#voxelize">Voxelize</a></h1>
|
<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>
|
<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
Ładowanie…
Reference in New Issue