<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mark Robinson on Medium]]></title>
        <description><![CDATA[Stories by Mark Robinson on Medium]]></description>
        <link>https://medium.com/@mrdeerwhale?source=rss-210e03190e6d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KVzZv5CFR9GoK_mly_CYCw.jpeg</url>
            <title>Stories by Mark Robinson on Medium</title>
            <link>https://medium.com/@mrdeerwhale?source=rss-210e03190e6d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 18:47:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mrdeerwhale/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting Started with Node-Based Shaders for visionOS Materials]]></title>
            <link>https://medium.com/@mrdeerwhale/getting-started-with-node-based-shaders-for-visionos-materials-7f901177567c?source=rss-210e03190e6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f901177567c</guid>
            <category><![CDATA[reality-composer]]></category>
            <category><![CDATA[visionos]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[shaders]]></category>
            <category><![CDATA[provision]]></category>
            <dc:creator><![CDATA[Mark Robinson]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 23:48:39 GMT</pubDate>
            <atom:updated>2023-06-28T19:40:15.459Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Use Material Nodes in Reality Composer Pro’s Shader Graph</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JPuxu_PzpJTLCsFu_WLqLw.jpeg" /></figure><p>One of coolest new features I saw during the WWDC2023 session videos was the addition of a node-based shader system in the new Reality Composer Pro app and how you can use it in spatial experiences with RealityKit. Because I’ve worked in node-based renderers (like Redshift), and have a little bit of experience with creating custom shaders (in Three.js via glsl), I was super excited when I saw <a href="https://developer.apple.com/videos/play/wwdc2023/10202/">Niels Gabel’s session on materials in Reality Composer Pro</a>. Not only can you create custom surface shaders (similar to a fragment shader) in the node-based system, you can also create geometry modifier shaders (similar to a vertex shader).</p><p>This new node-based way of working really opens the gates for creatives who are intimidated by writing their own Metal code (me lol) so we can make and experiment with custom shaders. All it takes is a little bit of know-how and curiosity to get started…</p><p>I plan to dive deeper into working with this node-based system to create some slightly more complex shaders in future posts, but for now I wanted to just give a quick intro into how to get started.</p><p>This first post walks you through creating a boilerplate project in Xcode, opening Reality Composer Pro, and assigning your first node to drive the color on a material. If you want to go further, I encourage you to try <a href="https://www.youtube.com/watch?v=KVyomXuaR7g">my tutorial on YouTube where I re-create the macOS Monterey surface shader in Reality Composer Pro</a>.</p><p><strong>What you’ll need:</strong><br>- Xcode 15.2 Beta (must be on a Mac running macOS Ventura to install)<br>- Add the VisionOS SDK (either via Xcode when you open it, or download separately)<br>- Some experience with other 3D DCCs (Cinema 4D, Maya, etc)<br>What’s helpful to know:<br>- Basic understanding of shaders.<br>- Experience with a node-based interface.<br>- Some math knowledge</p><p><strong>Background</strong><br>What’s a shader? If you really want to know, do a search and find somebody more knowledgeable than me. But if you can get by with a cursory explanation from an amateur…<br>A shader is essentially a tiny program that tells your computer how to display something on screen. The shaders are assigned to a 3D object’s geometry and make up the ‘material’ of the object. These materials actually have two parts (shaders).</p><p>The first is called a vertex shader (in our Reality Composer Pro context, a geometry modifier): It calculates where the object is in 3D space and how to translate that position into the 2D image you see on your screen. The basics of this are that given the coordinates of each piece of geometry that makes up your 3D scene, the computer will use the vertex shader to calculate whether your object can even be seen by the current view (maybe something is in front of it or it’s behind the camera), how it should be shown to give a sense of depth to the 2D image (aka, objects further from the camera should be smaller), and also how the field of view of the camera will make the object appear (a wide field of view will have distortion on the sides of the image). The vertex shader is essentially where you can manipulate the shape of the object.</p><p>The second part is a fragment shader (in our Reality Composer Pro context, it’s a surface shader): it takes the information handed to it by the vertex shader (aka, all these things appear on-screen), and it figures out how to color each pixel. The computer will look at one pixel, figure out what piece of geometry it’s rendering (via the vertex shader) and then do calculations to figure out what the final color of the pixel should be. This can be as simple as saying: this is a red box, so wherever we see this box, it’ll be red. However, you wouldn’t get a sense of depth to be able to decipher the edges or faces of the box. So in addition to color, a fragment shader will also calculate how the object at this pixel is being lit by lights in the seen, or if the object is reflective, perhaps its color should be influenced by the objects around it. Both types of shaders are topics that you can go down the rabbit hole on, and the only limitation will be your knowledge of math and physics. The reason renders in VFX films look realistic is because there are and have been brilliant minds working to apply the rules of we perceive the real world into generating these images. But besides making photo-realistic renders, we can also utilize these same tools and display things in a creative way with just some basic math.</p><p>Okay, let’s dive in!</p><p><strong>1. Boilerplate App and Launching Reality Composer Pro</strong><br>The goal here is to get into Reality Composer Pro as quickly as possible, and just use Xcode as a way to get a boilerplate visionOS app set up so we can view our scene in the simulator. After Reality Composer Pro has been installed, you can open it directly, however then you’ll have to coordinate bringing your scene into Xcode to be able to see it in the simulator, so this is an easier way to lean on Xcode and get something in the simulator as fast as possible.</p><ul><li>Open Xcode 15.2 Beta</li><li>Choose ‘Create New Project’</li><li>Go to the ‘VisionOS’ tab and select ‘App’. Click Next.</li><li>Give it a name. Set the initial Scene to ‘Volume,’ and the Immersive Space to ‘None’. This means that our app will launch with a boilerplate 3D scene in a ‘Volume’ window, and we can just edit this scene via Reality Composer Pro without having to write any code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*alWGCc2tE-oM25mkl9aACg.jpeg" /><figcaption>Name the project, choose Volume for Initial Scene and None for Immersive Space.</figcaption></figure><ul><li>You’ll be presented with the boilerplate app. If you select the ‘ContentView’ file from the navigator in the left pane, it will show a preview of our app (currently just a gray sphere floating with a button).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z6CTW-PVNcxCcJN4VaQfgQ.jpeg" /><figcaption>The default visionOS Volume App, with boilerplate AR scene.</figcaption></figure><ul><li>The 3D scene presented in the content view is automatically added by Xcode based on the assets found inside of a RealityKit package. To edit the scene, we just have to navigate to the Package file in the navigator that’s found inside Packages/RealityKitContent/ directory. Once you select this file, you’ll see a view of our scene (our grey sphere). In the upper-right corner you’ll see a button to ‘Open in Reality Composer Pro’. Click it and Reality Composer Pro will launch.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUT0xeiYXr5RXvE2G41MPg.jpeg" /><figcaption>Navigate to the Package in the hierarchy, which shows the default scene. Click ‘Open in Reality Composer Pro’ to launch RCP.</figcaption></figure><p><strong>2. Working in Reality Composer Pro.</strong><br>The goal here is to give a quick rundown on how to work in Reality Composer Pro, and move on to using the Shader Graph nodes to tweak our material.</p><ul><li>When Reality Composer Pro launches, it will look familiar to anybody that’s worked in another 3D DCC before. The main viewport shows the same scene that we saw in Xcode. A pane on the left that shows the scene’s heirarchy. A pane on the right shows an inspector where you can adjust parameters for whatever is currently selected.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZsZ2TEfBb4VWlxg39baZag.jpeg" /></figure><ul><li>The bottom pane contains four workspaces you can toggle via the tabs in the middle:</li><li><strong>A. Project Browser, </strong>is an overview of the assets in the rkassets folder that was generated by Xcode (to view it in finder, right click the name ‘RealityKitContent.rkassets’ under Project and select ‘Open in Finder’).</li><li><strong>B. Shader Graph </strong>(starts empty), but this is where we’ll edit our material shortly.</li><li><strong>C. Audio Mixer</strong> (starts empty), we won’t use this in the tutorial.</li><li><strong>D. Statistics.</strong> This is where you can see the stats of your scene to address performance issues / optimize.</li><li>You can move around your scene by clicking/dragging in the viewport. There are six buttons at the bottom left of the viewport that can help you navigate. They are: Selection Mode (Has a similar feel to other DCCs — clicking and dragging orbits, clicking selects objects, middle mouse/scroll dollies the camera), Look Mode (camera stays still, clicking and dragging just pans/tilts the camera), Pan Mode (clicking + dragging moves the camera (tracks/peds up/down — Not panning lol, bad Apple, bad Apple!)), Orbit Mode (clicking dragging does the same thing as Selection Mode except you can’t select objects), Dolly Mode (clicking dragging doilies in and out), Reset Camera (this will reset the camera to a default position).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*ZSt2cGqc3KOTClVjb9kkeg.jpeg" /><figcaption>The different camera modes for navigating the viewport.</figcaption></figure><ul><li>Great, that’s enough to get you started. Let’s delete the sphere and the placeholder material from the scene. Just select in the hierarchy and delete.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fWPGjjYDWK9WKosnt8L3sg.jpeg" /><figcaption>Remove the default content from the scene.</figcaption></figure><ul><li>Let’s import our little landscape model. Go to File -&gt; Import. Check the ‘Add to current scene’ checkbox.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NtW26noFnUo8PGPHvpcTYw.jpeg" /><figcaption>Add your model by importing it into the project and add it to the current scene.</figcaption></figure><ul><li>Great, you’ll notice that because there are no materials in our scene, the model has that pink striped look. Let’s create a material. Click the + icon at the bottom of the hierarchy and select Materials -&gt; Physically Based.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GklkOc2fg7B7vfsuieb_Ug.jpeg" /><figcaption>Add a new physically based material.</figcaption></figure><ul><li>Now select your material in the hierarchy, and click on the Shader Graph in the bottom pane. Click ‘Create Material’ and two nodes will be added — a MaterialXPreviewSurface node and an Outputs node.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*ts7CIr12ewZ35yZ1RQeM4Q.jpeg" /><figcaption>Select the new material. Open the Shader Graph pane and click ‘Create Material.’ Two nodes will be populated for you.</figcaption></figure><ul><li>Assign the material to your geometry so we can see it instead of those pink stripes: Select the geometry in the hierarchy and look at the ‘Material Bindings’ parameters in the inspector pane. Under Binding, select our new material. Your object should now take on the default material look in the viewport.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*CtJPhiJDLpISVLhvF4e9Lw.jpeg" /><figcaption>After selecting your object’s geometry in the hierarchy, the inspector will show options for material bindings. Choose your new material from the ‘Binding’ dropdown.</figcaption></figure><ul><li>Let’s turn our attention to the ShaderGraph area. What are these two nodes? The Outputs node receives the data that is fed to the renderer to determine how our object is rendered and it has two inputs on it: Custom Surface and Custom Geometry Modifier (aka fragment shader and vertex shader). We’re just going to work with the Custom Surface data, and we’ll leave the Custom Geometry Modifier port empty. The MaterialXPreviewSurface Shader has a series of properties that can simulate real-life materials (color, roughness, metalness, opacity, etc). You can either set these values to a constant in the Inspector (for instance you could give the entire object a roughness value of 1.0 for a completely rough surface), or you can drive these value by piping data into the ports on the node (for instance, maybe you have a roughness texture that you can load in a texture node and feed into the roughness port).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P28CEgr_hCqb2mtpBD1n0A.jpeg" /><figcaption>Anatomy of a node.</figcaption></figure><ul><li>Since we’re just trying to get the hang of the shader graph, let’s start by adding a simple flat color to drive the materials Diffuse Color. Click the ‘+ New Node’ button in the top right.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*XN3mqfSyZCdpelwgjhGP3Q.jpeg" /><figcaption>To add a new node, click the + New Node button, or just double click in an empty space of the shader graph window.</figcaption></figure><ul><li>A dialogue pops up showing all the available nodes. Search for color. Select ‘Color3 (Float)’, and the node will be added somewhere on the shader graph. You can click and drag the node to reposition it if you like.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*N0VgYea7CiHdWslcPtiY9A.jpeg" /><figcaption>Search ‘Color’ in the dialogue and select the Color3 (Float) node.</figcaption></figure><ul><li>Now click on the Color3 (Float) node (it will be labelled ‘Constant’ by default, but you can rename it as you see fit). When you click on it, a color picker appears in the inspector next to ‘Value’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILKAwg2oXYKhoOvAll-s6g.jpeg" /><figcaption>When you select a node, it’s available properties will be displayed in the Inspector.</figcaption></figure><ul><li>Click it and pick a color. You’ll notice our object didn’t update in the viewport. This is because while we have the color data available to us now, we aren’t using it anywhere.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3wIqafeyNpfq_FM66r1_Q.jpeg" /><figcaption>Pick a color. After editing the value input, you won’t see the color reflected on your model yet.</figcaption></figure><ul><li>To use the color we created click on the output port (the little grey dot on the right side) of the Color3 node and drag to the ‘Diffuse Color’ input on the MaterialXPreviewSurface node.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*ZdvXgb139adKlSoupkHsHg.jpeg" /><figcaption>To connect nodes, click on the output of one node and drag to the appropriate input on the receiving node.</figcaption></figure><ul><li>Ta-Da! Our model is colorful!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vt3ILOA9hBCCpTnn87ujqQ.jpeg" /><figcaption>Now we can see that the input value from the Color3 (Float) node is driving the diffuse color of our material!</figcaption></figure><p><strong>3. View it in AR via the Preview window or the Vision Pro Simulator.</strong> In order to send the edits you made in Reality Composer Pro back to Xcode, all you have to do is save the scene. Once you do, the Preview of your ContentView will be updated with the changes. If you want to see your Volume in the Apple Vision Pro simulator, just Build and Run the Xcode project and the simulator will launch. Select your app form the home screen in the simulator, and voila! Your scene is available to view in AR!</p><p><strong>4. Next Steps </strong>— In the follow-on posts to this series, I’ll be showing how to use nodes to make slightly more complex shaders like the one below, which is colored based on the position of the object and changes color over time. Until then, happy experimenting!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*mRy2s1HXCJ8hDUa67v7iVw.jpeg" /><figcaption>In future posts, I’ll go over how to use the nodes in the shader graph to create more custom shaders, like this one that utilizes the position of the model for color and changes over time.</figcaption></figure><p><strong>If you have any questions or notice an error, please let me know by leaving a comment! And if you found this helpful please let me know by applauding or following me.</strong></p><p>Happy noding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f901177567c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shader Nodes Available in Reality Composer Pro]]></title>
            <link>https://medium.com/@mrdeerwhale/shader-nodes-available-in-reality-composer-pro-28325431adb6?source=rss-210e03190e6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/28325431adb6</guid>
            <category><![CDATA[reality-composer]]></category>
            <category><![CDATA[visionos]]></category>
            <category><![CDATA[shaders]]></category>
            <category><![CDATA[provision]]></category>
            <category><![CDATA[xcode]]></category>
            <dc:creator><![CDATA[Mark Robinson]]></dc:creator>
            <pubDate>Thu, 22 Jun 2023 13:46:38 GMT</pubDate>
            <atom:updated>2023-06-30T04:00:32.513Z</atom:updated>
            <content:encoded><![CDATA[<h3>Shader Nodes Available in Reality Composer Pro [Updated]</h3><p><em>Edit: June 29, 2023: I made a new reference site that is easier to view than the below. Please take a look and let me know if you spot any errors or have any questions.</em></p><p><a href="http://www.rcpguide.com/"><em>www.RCPGuide.com</em></a></p><p>With the release of Reality Composer Pro in Xcode 15.2 Beta, I couldn’t wait to jump in and see what kinds of nodes we can play with for our shaders. However, it seems like the documentation for Reality Composer Pro is still not published (at least I couldn’t find a list of all the shaders at our disposal). So I’m creating my own list based on what’s available from the New Node button (currently wip). And if you’re interested in <a href="https://medium.com/@mrdeerwhale/getting-started-with-node-based-shaders-for-visionos-materials-7f901177567c">getting started with nodes in Reality Composer Pro’s shader graph, but you’re not sure where to start, check out my other post here.</a> If you’re interested in something a little more advanced, <a href="https://www.youtube.com/watch?v=KVyomXuaR7g&amp;t=39s">watch my tutorial on YouTube</a> where I recreate the surface shader of the macOS Monterey screensaver.</p><p>Here’s the list of all the shader nodes available in Reality Composer Pro, along with the brief descriptions that are provided in the New Node dropdown.</p><h4><strong>2D Procedural</strong></h4><ul><li><strong>Cellular Noise 2D:</strong> A 2D cellular noise generator.</li><li><strong>Noise 2D:</strong> A 2D Perlin noise generator.</li><li><strong>Ramp 4 Corners:</strong> A four-point linear value ramp (gradient) generator.</li><li><strong>Ramp Horizontal:</strong> A left-to-right linear value ramp (gradient) generator.</li><li><strong>Ramp Vertical: </strong>A top-to-bottom linear value ramp (gradient) generator.</li><li><strong>Split Horizontal:</strong> A left-to-right split matte, split at a specified U value.</li><li><strong>Split Vertical:</strong> A top-to-bottom split matte, split at a specified V value.</li><li><strong>Worley Noise 2D:</strong> A 2D Worley noise generator.</li></ul><h4><strong>2D Texture</strong></h4><ul><li><strong>Image: </strong>A texture referencing a 2D image file.</li><li><strong>Tiled Image: </strong>Samples data from an image with provisions for offsetting and tiling in UV space.</li><li><strong>Transform 2D:</strong> A node that applies an affine transformation to a 2d input.</li><li><strong>UV Texture:</strong> A MaterialX version of USD UV Texture reader.</li></ul><h4><strong>3D Procedural</strong></h4><ul><li><strong>Cellular Noise 3D:</strong> A 3D cellular noise generator.</li><li><strong>Fractal Noise 3D:</strong> Zero-centered 3D fractal noise created by summing several octaves of 3D Perlin noise.</li><li><strong>Noise 3D:</strong> A 3D Perlin noise generator.</li><li><strong>Worley Noise 3D</strong>: A 3D Worley noise generator.</li></ul><h4><strong>3D Texture</strong></h4><ul><li><strong>Triplanar Projection:</strong> Samples data from three images and projects each along its respective coordinate axis and blends them by geometric normal.</li></ul><h4><strong>Adjustment</strong></h4><ul><li><strong>Contrast:</strong> Increases or decreases contrast of values using a linear slope multiplier.</li><li><strong>HSV Adjust:</strong> Adjusts the hue, saturation, and value of an RGB color by a vector &lt;amount&gt;.</li><li><strong>HSV to RGB:</strong> Converts a color from HSV to RGB space.</li><li><strong>Luminance:</strong> Outputs a grayscale value containing the luminance of the incoming RGB color in all color channels.</li><li><strong>Range:</strong> Remaps incoming values from one range to another.</li><li><strong>Remap: </strong>Linearly remaps incoming values from one range to another.</li><li><strong>RGB to HSV:</strong> Converts a color form RGB to HSV space.</li><li><strong>Saturate:</strong> Adjusts the saturation of a color.</li><li><strong>Smooth Step:</strong> Outputs a smooth remapping from low-high to 0–1.</li><li><strong>Step (RealityKit): </strong>Step.</li></ul><h4><strong>Application</strong></h4><ul><li><strong>Time (float):</strong> The current time in seconds.</li><li><strong>Up Direction:</strong> The direction of the up vector.</li></ul><h4><strong>Compositing</strong></h4><ul><li><strong>Additive Mix: </strong>Adds foreground and background values. B + F</li><li><strong>Burn: </strong>A blend operation that darkens the foreground layer using the background. 1 — (1 — B) / F</li><li><strong>Difference: </strong>Outputs the distance between foreground and background values. abs(B — F)</li><li><strong>Disjoint Over:</strong> A merge operation that layers foreground over background color, but assumes no overlap in partially transparent areas covered by both.</li><li><strong>Dodge: </strong>A blend operation that lightens the background layer depending on the foreground. B / (1 — F)</li><li><strong>In: </strong>Outputs areas of foreground that overlap with the alpha of background.</li><li><strong>Inside:</strong> Multiplies a mask to all channels of the input.</li><li><strong>Mask:</strong> Outputs areas of background that overlap with the alpha of foreground.</li><li><strong>Matte:</strong> A merge operation that layers premultiplied foreground over background.</li><li><strong>Mix: </strong>Mixes foreground and background inputs, weighting based on mix value. F * m + B(1 — m)</li><li><strong>Out:</strong> Outputs areas of foreground that do not overlap with background.</li><li><strong>Outside:</strong> Multiplies (1 — mask) to all channels of the input.</li><li><strong>Over:</strong> A merge operation that layers foreground over background, using the alpha of the foreground.</li><li><strong>Overlay: </strong>A blend operation that multiplies dark areas and screens light areas. 2 * F * B if F &lt; 0.5; 1 — (1 — F)(1 — B) if F ≥ 0.5</li><li><strong>Premultiply:</strong> Multiplies the RGB channels of the input by the alpha channel.</li><li><strong>Screen:</strong> A blend operation that lightens area that are dark than white. 1 — (1 — F)(1 — B)</li><li><strong>Subtractive Mix</strong>: Subtracts foreground from background values. B — F</li><li><strong>Unpremultiply:</strong> Divides RGB channels of the input by the alpha channel.</li></ul><h4><strong>Data</strong></h4><ul><li><strong>Combine 2: </strong>Combines the channels from two streams into two channels of a single output stream of a compatible type.</li><li><strong>Combine 3:</strong> Combines the channels from three streams into three channels of a single output stream with a compatible type.</li><li><strong>Combine 4:</strong> Combines the channels from four streams into four channels of a single output stream of a compatible type.</li><li><strong>Convert:</strong> Converts a stream from one data type to another.</li><li><strong>Extract:</strong> Generates a float stream from one channel of a colorN or vectorN stream.</li><li><strong>Primvar Reader (bool):</strong> A node that provides the ability for shading networks to consume boolean data defined on geometry.</li><li><strong>Primvar Reader (float): </strong>A node that provides the ability for shading networks to consume float data defined on geometry.</li><li><strong>Primvar Reader (integer):</strong> A node that provides the ability for shading networks to consume integer data defined on geometry.</li><li><strong>Primvar Reader (String):</strong> A node that provides the ability for shading networks to consume string data defined on geometry.</li><li><strong>Primvar Reader (vector2f):</strong> A node that provides the ability for shading networks to consume float2 data defined on geometry.</li><li><strong>Primvar Reader (vector3f): </strong>A node that provides the ability for shading networks to consume float3 data defined on geometry.</li><li><strong>Primvar Reader (vector4f):</strong> A node that provides the ability for shading networks to consume float4 data defined on geometry.</li><li><strong>Separate 2:</strong> Outputs each of the channels of a vector2 as a separate float output.</li><li><strong>Separate 3:</strong> Outputs each of the channels of a vector3 as a separate float output.</li><li><strong>Separate 4: </strong>Outputs each of the channels of a vector4 as a separate float output.</li><li><strong>Swizzle:</strong> Performs an arbitrary permutation of the channels of the input stream, returning a new stream of the specified type.</li></ul><h4><strong>Geometric</strong></h4><ul><li><strong>Bitangent:</strong> The geometric bitangent vector of the currently processed data in a given coordinate space.</li><li><strong>Geometric Property: </strong>The value of the specified geometric property (defined using &lt;geompropdef&gt;) of the currently-bound geometry.</li><li><strong>Geometry Color:</strong> The color associated with the geometry at the currently processed geometric position, typically defined by vertex color.</li><li><strong>Normal:</strong> The geometric normal of the currently-processed data in a given coordinate space.</li><li><strong>Position:</strong> The coordinates of the currently-processed data in a given coordinate space</li><li><strong>Reflect (RealityKit):</strong> Reflects a vector about another vector.</li><li><strong>Refract (RealityKit):</strong> Refracts a vectror using a given normal and index of refraction (eta).</li><li><strong>Tangent: </strong>The geometric tangent of the currently-processed data in a given coordinate space.</li><li><strong>Texture Coordinates:</strong> The 2D or 3D texture coordinates fo the currently-processed data.</li></ul><p>Logic</p><ul><li>And (RealityKit): Boolean operation in1 &amp;&amp; in2.</li><li>If Equal: Outputs True Result or False Result depending on whether value1 == value2.</li><li>If Greater: Outputs True Result or False Result depending on whether value1 &gt; value2.</li><li>If Greater Or Equal: Outputs True Result or False Result depending on whether value1 ≥ value2.</li><li>Not (RealityKit): Returns !input.</li><li>Or (RealityKit): Boolean operation in1 || in2.</li><li>Switch: Outputs the value from one of ten input streams acording to a selector &lt;which&gt;.</li><li>XOR (RealityKit): Returns true if only one of the inputs is true.</li></ul><p>Material:</p><ul><li>NodeGraph: A node that can contain shading nodes and other node graphs.</li></ul><p>Math</p><ul><li>Abs: Outputs the per-channel absolute value of the input.</li><li>Acos: The arccosine of the incoming value in radians.</li><li>Add: Adds two values.</li><li>Asin: The arcsine of the incoming value in radians.</li><li>Atan2: The arctangent of the expression (inx/iny) in radians.</li><li>Ceiling: Outputs the nearest integer value, per channel, greater than or equal to the incoming values.</li><li>Clamp: Clamps the input per-channel to a specified range.</li><li>Cos: The cosine of the incoming value in radians.</li><li>Cross Product: crossproduct.menuDescriptionShort (LOL). My guess: The cross product of two incoming float3 vectors.</li><li>Determinant: Outputs the float determinate of a matrix.</li><li>Divide: Divides two values. Division of two matrices is the product of &lt;in1&gt; and the inverse of &lt;in2&gt;.</li><li>Dot Product: Outputs the dot product of two vectors. (in1.x * in2.x) + (in1.y + in2.y)</li><li>Exp: ‘e’ to the power of the input.</li><li>Floor: Outputs the nearest integer value, per-channel, less than or equal to the incoming values.</li><li>Fractional (RealityKit): Returns the fractional part of a floating point number.</li><li>Invert Matrix: Outputs the inverse of a matrix.</li><li>Magnitude: Outputs the float magnitude of a vector.</li><li>Max: Outputs the maximum of two incoming values.</li><li>Min: Outputs the minimum of two incoming values.</li><li>Modulo: Outputs the remaining fraction after dividing the input by a value and subtracting the integer portion.</li><li>Multiply: Multiplies two values.</li><li>Natural Log: The natural log of the input.</li><li>Normal Map: Transforms a normal vector from object or tangent space into world space.</li><li>Normalize: Outputs a normalized vector.</li><li>One Minus (RealityKit): One minus.</li><li>Place 2D: Transforms UV texture coordinates for 2D texture placement.</li><li>Power: Raises the incoming value to an exponent.</li><li>Rotate 2D: Rotates a vector2 (Float) about the origin in 2D.</li><li>Rotate 3D: Rotates a vector3 (Float) about a specified unity axis vector.</li><li>Round: Rounds to the nearest integer value, per channel. floor(i + 0.5)</li><li>Safe Power: Raises the incoming value to an exponent and assigns the sign of the base to the output. safepow(x,y) = sign(x) * pow(abs(x), y)</li><li>Sign: The per-channel sign of the input value: -1 for negative, +1 for positive, 0 for zero.</li><li>Sin: The sine of the incoming value in radians.</li><li>Square Root: The square root of the incoming value.</li><li>Subtract: Subtracts two values.</li><li>Tan: The tangent of the incoming value in radians.</li><li>Transform Matrix: Transforms a vector by a matrix.</li><li>Transform Normal: Transforms a normal from one space to another.</li><li>Transform Point: Transforms a coordinate from one space to another.</li><li>Transform Vector: Transforms a vector3 from one space to another.</li><li>Transpose: Outputs the transpose of a matrix.</li></ul><p>Organization</p><ul><li>Dot: A pass-through node used for visually routing edges in the graph.</li></ul><p>PBR</p><ul><li>Preview Surface: A MaterialX version of the USD Preview Surface.</li></ul><p>Procedural</p><ul><li>Boolean: A constant boolean (true/false) value.</li><li>Color3 (Float): A constant Color3 (Float) value.</li><li>Color4 (Float): A constant Color4 (Float) value.</li><li>Float: A constant floating-point numeric value.</li><li>Half: ND_constant_half.menuDescriptionShort (lol). I’m guessing: A constant 16-bit floating-point numeric value.</li><li>Image File: A constant path referring to an arbitrary image file on disk.</li><li>Integer: A constant integer numeric value.</li><li>Matrix2x2 (Float): A constant Matrix2x2 (Float) value. (Row-major order)</li><li>Matrix3x3 (Float): A constant Matrix3x3 (Float) value. (Row-major order)</li><li>Matrix4x4 (Float): A constant Matrix4x4 (Float) value. (Row-major order)</li><li>String: A constant string (text) value.</li><li>Vector2 (Float): A constant Vector2 (Float) value.</li><li>Vector2 (Half): ND_constant_half2.menuDescriptionShort (lol). I’m guessing: A constant Vector2 (Half) value.</li><li>Vector3 (Float): A constant Vector3 (Float) value.</li><li>Vector3 (Half): ND_constant_half3.menuDescriptionShort (lol). I’m guessing: A constant Vector3 (Half) value.</li><li>Vector4 (Float): A constant Vector4 (Float) value.</li><li>Vector4 (Half): ND_constant_half4.menuDescriptionShort (lol). I’m guessing: A constant Vector4 (Half) value.</li></ul><p>…to be continued!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28325431adb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cinema 4D Redshift to PBR .glTF Workflow]]></title>
            <link>https://medium.com/@mrdeerwhale/cinema-4d-redshift-to-pbr-gltf-workflow-3e13c7c2e8d5?source=rss-210e03190e6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e13c7c2e8d5</guid>
            <category><![CDATA[creative-coding]]></category>
            <category><![CDATA[cinema-4d]]></category>
            <category><![CDATA[gltf]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[redshift]]></category>
            <dc:creator><![CDATA[Mark Robinson]]></dc:creator>
            <pubDate>Fri, 11 Nov 2022 00:26:54 GMT</pubDate>
            <atom:updated>2022-11-11T00:26:54.485Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cinema 4D Redshift to PBR .glTF Workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9GAelSMFhLz583PgplmmMQ.jpeg" /></figure><p>In this post I detail how to export materials from Redshift to textures that can be used to re-create the material for .glb / .glTF models using a PBR methodology in Three.js or elsewhere (<a href="https://cinema4d-redshift-to-pbr-gltf-example.vercel.app/">live scene</a>).</p><p>This is a follow up to <a href="https://medium.com/@mrdeerwhale/cinema-4d-redshift-to-three-js-workflow-51acb4f8ac5e">my previous post </a>where I discussed how to bake out your Redshift materials AND lighting from Cinema 4D to a .glb / .glTF file and import them into Three.js. That workflow is well-suited when you want to preserve the lighting created in Cinema 4D / Redshift, without having to replicate it in Three.js. An added bonus is that your lighting is not calculated in your Three.js scene, which should mean better performance. However, there are major drawbacks to that method, depending on your use case. Because the lighting is baked, the specularity won’t update based on the camera movement in Three.js, so for highly specular materials it will lack a certain realism. Additionally, that workflow will not look correct if you have animated items, as the objects will not be actively lit by the scene. So if you change the position, rotation, scale of the object (or some other type of vertex-based animation like a skin/morph) the shadow/ shading / lighting won’t update on the surface of the models. While you could maybe get away with subtle animations, large movements would look odd.</p><p>So what’s to be done?</p><p>Well, this post will cover a workflow for assets where you want to bake out the standard PBR channels (color, metalness, roughness) so that you can light the scene directly in Three.js (or elsewhere) and animate to your heart’s content! <strong>Note: I’m still developing a method for exporting tangent-space normal maps from Redshift and will follow up with a new post when it’s reliably working.</strong> As in the previous post, I’ll mainly be focused on the export process: how your C4D file and Redshift materials need to be setup in order for this work, how to export them as maps, how to color correct them, and how to export the models. Some of this information will be repeated if you’re familiar with <a href="https://medium.com/@mrdeerwhale/cinema-4d-redshift-to-three-js-workflow-51acb4f8ac5e">my previous post about baking Redshift materials and lighting</a>.</p><h4>Acknowledgements</h4><p>As always, I gotta give major props to <a href="https://bruno-simon.com/">Bruno Simon</a> for all my Three.js knowledge — his <a href="https://threejs-journey.com/">ThreeJS Journey</a> course is so well put together. It’s a must-have resource if you’re looking to get into development with Three.js or WebGL in general.</p><p>I also had a bit of an “A-ha!” moment while watching <a href="https://www.youtube.com/watch?v=Jc1_Bi6G3S4">this video from the Maxon Training Team</a>, at around 1:12:08, where Dustin Valkema uses a custom AOV to store the color information. I hadn’t ever seen the Store Color to AOV node before, and it got me thinking about how I could use that to separate the different maps for your typical PBR material representation. I also use the same After Effects color correct workflow from my previous post, which I learned from Lionel Vicidomini (also of the Maxon Training Team) <a href="https://www.youtube.com/watch?v=ohiPICLnqZo">in this video</a>. I definitely recommend following their content — their whole team is pumping out exceptional tutorials, from quick tips to deep-dives into specific topics.</p><p>Let’s go!</p><h3>1. Begin with any UV’d model(s).</h3><p>Any model you want to export using this method will need to have UV’s. While you may be accustomed to just dragging Redshift materials onto your models without creating a proper set of UV’s first, we’ll need the UV’s in this workflow: Redshift will need to have a destination set of UV’s when it bakes out your maps, and Three.js will need the UV information to know how to apply those maps to your geometry. Unfortunately, I’m not a UV-pro, so if you have questions on this step, I’ll refer you to the copious amount of UV tutorials available online to get you up to speed.</p><p>As you’re making your models, remember to keep them (fairly) low-poly since this will ultimately be used in a Three.js scene.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Kxpmt6Q3IsmWYnJLqytHw.jpeg" /><figcaption>Everything on my model has been UV’d. All three pieces of geo share the same UV/Texture space.</figcaption></figure><h3>2. Create custom AOV’s for each channel.</h3><p>In the Redshift AOV Manager, setup a custom AOV for each map you want to export (i.e. color, metalness, roughness). For each AOV, make the following settings updates:</p><ol><li>Update the name (i.e. color, metalness, roughness).</li><li>Uncheck ‘ Multi-Pass.’</li><li>Check ‘Direct.’</li><li>In the ‘Direct Output’ section on the right, choose OpenEXR as your format, Float (32 bits) for bpc (because why not?), and under compression use DWAA.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YLkKCGL7i50aijKUr_sZA.jpeg" /><figcaption>Create 3 custom AOVs, re-name them to the corresponding maps you’ll need for your PBR material, and update the Direct Output settings.</figcaption></figure><h3>3. Make your materials in Redshift, adding the Custom AOVs as you go.</h3><p>Now that you’ve setup your custom AOV’s for the PBR maps we want, it’s time to create and apply your Redshift materials. There are some limitations to what you can do in Redshift if you’re using this method of export, but if you keep these limitations in mind and plan your materials with some forethought, you can get some nice results.</p><p>You’ll need to follow this rough setup:</p><ul><li>For each new material, you’ll add a ‘Store Color to AOV’ node. Take the output from your material and pipe it into the ‘Beauty’ input of the ‘Store Color to AOV’ node. Now take the output of your ‘Store Color to AOV’ node and pipe that into the ‘Surface’ input on your ‘Output’ node (see below).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NrUDAerq0k6kIBRy_TSlPA.jpeg" /><figcaption>Add a Store Color to AOV Node, and connect it between your material and output.</figcaption></figure><ul><li>For each channel (color, metalness, roughness) you’ll want to pipe it into the corresponding input of your material AND an ‘AOV Input’ input on the ‘Store Color to AOV’ node. Then edit your ‘Store Color to AOV’ node in the attribute editor and choose the appropriate custom AOV for that channel in the ‘AOV Name’ dropdown. What this means is that you shouldn’t control any of these channels from within the material node itself. For instance, even if you just want a flat 100% metalness value, you should create a ‘Color’ node, set it to 100% white and then pipe that color into your metalness channel on the material node (see below).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I9F79cK9Z_XouUBZ-Z2U5Q.jpeg" /><figcaption>All your calculations for the color, metalness and roughness are done outside the material node, then piped into the corresponding channels on the material and the Store Color to AOV node. Notice the metalness gets a black color, since the eraser should be 0% metal.</figcaption></figure><ul><li>In the Redshift RenderView, you can change the pass dropdown from ‘Beauty’ to your custom AOV’s. This way you can preview how each isolated channel will be output onto your model and make sure all of the connections to your ‘Store Color to AOV’ nodes are correct. This is the color information that will be baked out to textures when we bake.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BB68Lrq_ovnu76tng3YLZw.jpeg" /><figcaption>You can toggle the dropdown in the Redshift RenderView to preview what each of your AOVs will look like.</figcaption></figure><ul><li>Hone your material as you normally would (keeping the below limitations in mind).</li></ul><p>Other notes / limitations:</p><ul><li>You can only use one material node per material (i.e. you can’t use a material blender). Any material blending that you’d want to do will have to be done in a much more labor-intensive way of mixing it down to one color output for each channel it affects (for instance, making use of a ‘Color Composite’ node) and then piping that into the appropriate channel on your single material node (and your ‘Store Color to AOV’ node).</li><li>Similarly, you won’t be able to (easily) use the new stacked material method in Redshift where multiple materials affect the same geometry, because I don’t think you can have two materials export to one Custom AOV on the same piece of geo.</li><li>You’ll want to use the new Standard node material, as this more closely conforms to the PBR channels (since it has a metalness channel).</li></ul><h3>4. Check your Redshift render settings.</h3><p>Because we want to export the raw color data from Redshift, while using the ACEScg workflow, update the following in your Render Settings under Redshift -&gt; Globals in the ‘Color Management’ tab:</p><ul><li>In the ‘View’ dropdown, select ‘Raw.’</li><li>Uncheck the ‘Compensate for View Transform’ option.</li></ul><p>Note: the colors in your Redshift RenderView will look off once you do this, so hone your materials prior to making this change (see below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUBl0Y3I7OeqZvQE6ddwyA.jpeg" /><figcaption>Once you make these changes, you’ll notice that the color in your RenderView drastically changes — this is to be expected.</figcaption></figure><h3>5. Add your geo to a Redshift BakeSet.</h3><p>Now that your material development is done, we can get ready for baking!</p><p>If you have multiple objects that will share the same UV/Texture space (and you already packed the UV’s appropriately), you should make a duplicate and ‘Connect Objects and Delete’ the duplicate. By connecting them into one object (with one UV tag), the BakeSet will bake them into on texture (per custom AOV), and give you that nice UV edge extension on the seams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uLBxzhM0WYJLZrpaTrPurQ.jpeg" /><figcaption>If multiple objects share the same UV/Texture space, duplicate them and merge one by using Connect Objects + Delete.</figcaption></figure><p>You can turn off the view and render visibility for the original goemetry and just keep the merged version visible. You can also turn off any lights in your scene (which will speed up the render when you go to bake) since Redshift won’t need lights to calculate your Custom AOV renders. Now select all the objects you want to bake out and go to Redshift -&gt; Tools -&gt; Texture Baking -&gt; ‘Create BakeSet from Selection.’ This will add a Redshift BakeSet to your scene (see below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u0bxQwlglHxCZ9aNIa2vzg.jpeg" /><figcaption>You can turn off the visibility of the original version of your geometry and any lights or extra objects in your scene. Then select your merged geometry, and Create BakeSet from Selection.</figcaption></figure><h3>6. Bake your texture maps!</h3><p>In the ‘Object’ tab of your Redshift BakeSet, you can set the output resolution for your textures. If you had more than one UV tag on your geometry, you’d want to indicate the target UV’s for the bake in the ‘UV Source’ field. You can also add or remove objects from the bake in the ‘Objects’ field.</p><p>Click ‘Bake’ and in the dialogue box that appears, you can set the output folder for your baked textures. Also, go ahead and uncheck the ‘Default Beauty’ box (we don’t need a beauty pass for this method). Now click ‘Bake’ in the dialogue box and Redshift will start to render out your textures — it should be pretty quick since it’s just flat colors for each channel (color, metalness, roughness).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O91Y-jFQDvbutj7E4XyYnw.jpeg" /><figcaption>Configure the width and height of your texture in the BakeSet attributes. Clicking bake will bring up a dialog box. Uncheck the Default Beauty box as we won’t need it for this method.</figcaption></figure><p>Great, now we have our three maps as OpenEXRs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXFFt9RLOy4PgG0beH4a0Q.jpeg" /></figure><h3>7. Color correct your textures in After Effects.</h3><p>Because we were using the ACEScg color space, we want do some conversions to make sure the color will be right when we go into Three.js. The way I know how to do this is in After Effects. Do the following:</p><ul><li>Set your project to: 32 bpc, Working Space: ‘sRGB…’, and check ‘Linearize Working Space’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ekqo9CbinrZYL6I8mkTw1A.jpeg" /><figcaption>Update your project settings in After Effects.</figcaption></figure><ul><li>Import your OpenEXRs. Choose ‘Import As’: ‘Composition — Retain Layer Sizes’, and check ‘Create Composition.’ In the pop-ups that appear, keep ‘Import As: Composition’ selected, check ‘Pre-compose layers’, and uncheck ‘Contact sheet,’ then click OK (see below).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IettNAHfTvwYjwr5UnBu8g.jpeg" /></figure><p>I like to add all of my OpenEXRs to one comp, trim them to one frame each, and then offset them by one frame, and trim the comp to this length so that when I want to export them I can just go ahead and render that one comp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y68Yw1dg80_E9O8H9BNt0w.jpeg" /><figcaption>Put all your EXRs into one comp on different frames so you can just render the entire comp when you’re ready to export as pngs.</figcaption></figure><p>Before we render though, we need to make some adjustments. While our metalness and roughness maps can be exported as is (to .png or .jpg), we need to do some work on the color map to make sure it’ll match what we saw in Redshift:</p><ul><li>Add an adjustment layer on top of the color texture (trim to just be over this texture) and addd the OpenColorIO effect to the Adjustment layer (<a href="http://fnordware.blogspot.com/2012/05/opencolorio-for-after-effects.html">available here</a>). (see below).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4xa5cxdaujROeWe-uidvg.jpeg" /><figcaption>Create an adjustment layer over just your color texture, install the OpenColorIO effect, apply it to the adjustment layer.</figcaption></figure><ul><li>In the ‘Configuration’ dropdown, find Redshift’s ‘config.ocio’ file in the Applications/Redshift/Data/OCIO directory.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*hCRamYJ8eJsJ_TloKwaSDw.jpeg" /><figcaption>Navigate to the OpenColorIO config file from Redshift.</figcaption></figure><ul><li>Click the ‘Display’ button, then in the ‘Input Space’ dropdown select ‘ACES -&gt; ACEScg’. Below the OpenColorIO effect, add a Color Profile Converter effect to the Adjustment Layer and from the ‘Input Profile’ dropdown, select ‘sRGB …’. Your color texture should look correct now (see below).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jfZ2O8o7WgnEC0P_dOcpcg.jpeg" /></figure><p>Now render out your textures as a png image sequence. And you can down-res or compress these to .jpgs, etc before you go live.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WM_fVIAZiJCFt-KHAVuBgg.jpeg" /><figcaption>Great, now we have some high quality PNGs. You can further down-res or compress them as needed.</figcaption></figure><h3>8. Export your model as .glb / .glTF</h3><p>So we have our texture files ready, now we just need to export our model from Cinema 4D.</p><p>If you combined multiple pieces of geo into one object by using the ‘Connect Objects and Delete’ method for baking (in step 5), you can remove that version, and turn back on the render and editor visibility for the original copy. You can delete all other objects, including cameras and lights, so that you just have your geo in your outliner. You can also remove your materials, although make sure to keep your UV tags and Phong tags. Now go up to File -&gt; Export -&gt; glTF and configure it with the settings below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qty71OeEE5zXGQZIIJE4yA.jpeg" /><figcaption>The only thing left in the scene is the geometry (can be grouped under Nulls if you want), phong tags and UV tags. Export as .glb, and include the Normals, UVs, and Flip the Z.</figcaption></figure><h3>9. Import your .glb file into Three.js and re-link your maps.</h3><p>Great! All that’s left is to import your maps, create a material that makes use of them in the appropriate channel, import your .glb, and apply that material to your .glb’s mesh! Here’s the general overview:</p><ol><li>Create a generic scene with basic boilerplate Three stuff (a canvas, a scene, a camera, lights, an environment map, orbit controls, a renderer, a resize event for the browser window, initialize a texture loader and a gltf loader, and add an animation loop).</li><li>Load the texture maps from their URIs, update your color’s encoding to be THREE.sRGBEncoding, and set each of their flipY properties to false.</li><li>Create a MeshStandardMaterial and link the appropriate texture above to the appropriate channel. Add the environment map to the envMap attribute and set it’s intensity.</li><li>Load the gltf. During the loading, traverse the gltf and apply the correct material to the mesh (the naming from the Cinema 4D export will remain, so just search for meshes with those names). And add the gltf to the Three.js scene.</li><li>Optimize / tweak to your heart’s content.</li></ol><p>And voila! A material made in Redshift that now uses PBR maps applied to a model made in Cinema 4D and running in the browser at 60 fps!+</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gS4HT58ASZB4JTiyW97NUA.png" /><figcaption>Just a nice simple PBR pencil being actively lit by Three.js with soft shadows and running at 120 FPS.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e13c7c2e8d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cinema 4D Redshift to Three.js Workflow]]></title>
            <link>https://medium.com/@mrdeerwhale/cinema-4d-redshift-to-three-js-workflow-51acb4f8ac5e?source=rss-210e03190e6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/51acb4f8ac5e</guid>
            <category><![CDATA[cinema-4d]]></category>
            <category><![CDATA[redshift]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[gltf]]></category>
            <category><![CDATA[webgl]]></category>
            <dc:creator><![CDATA[Mark Robinson]]></dc:creator>
            <pubDate>Fri, 04 Nov 2022 03:13:16 GMT</pubDate>
            <atom:updated>2022-11-16T19:45:26.790Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bf474dVUNM7djUj23jrxMg.jpeg" /></figure><p>This post covers the export process, starting with a UV’d model in Cinema 4D to a final .glb/.gltf asset and texture files for use in a Three.js mesh that will rely on a MeshStandardMaterial to replicate what you saw in Redshift without any lighting handled by Three.js (running <a href="https://cinema4d-to-threejs-example.vercel.app/">example</a>). If you’re looking for a way to export .glb/.gltf assets with textures that can be actively lit in Three.js, check out <a href="https://medium.com/@mrdeerwhale/cinema-4d-redshift-to-pbr-gltf-workflow-3e13c7c2e8d5">my other post about baking PBR style maps from Redshift</a>. Because this post is concerned primarily with the export process, I won’t go into things like how to UV a model (I’m no expert anyways) or how to import a .glb/.gltf into Three.js and assign textures. Future posts of this series will include important ways to optimize the process and your assets, shortcomings of this method (there are many!), and additional tips and tricks. If you have questions, notice errors, or have improvements, please feel free to let me know!</p><h4>First though, acknowledgements:</h4><p>Massive thanks to Bruno Simon. The info I learned in his <a href="https://threejs-journey.com/">Three-JS Journey</a> course informed this workflow, although he details the workflow using Blender. But I don’t use Blender and needed to reverse engineer for Redshift / Cinema 4D. If you are interested in Three.js, his course is worth 100x what it costs — check it out!</p><p>And a thanks to <a href="https://youtu.be/ohiPICLnqZo">this Maxon Training Team video</a> that helped me figure out a color workflow from Redshift -&gt; After Effects. They’re providing really great content, so def subscribe!</p><p>Okay, now let’s dig in..</p><h3>1. Start with any UV’d model or model(s).</h3><p>Any models you want to export will need to have a decent set of UV’s. While I know working with Redshift sometimes makes this process un-necessary for applying shaders, it’s imperative that a model you plan to export as a glb/gltf be UV’d. This is so C4D/Redshif knows how to bake out the materials / textures to a image, and so Three.js knows how to apply that texture to the model vertices. There are plenty of tutorials on the web about UV-ing, and I’m no expert, so I’ll leave you to do your own research if you need to level up before moving on.</p><p>Remember to keep your model’s geo fairly low-poly, this is a Three.js scene after all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhtzCVuyWwnJJJuTmAgHaA.png" /><figcaption>All items in my scene have been UV’d. All the tongs geo is packed onto one UV space, the groundplane and the cutting board have their own UV space.</figcaption></figure><h3>2. Add your Redshift materials (and/or textures) and light your scene.</h3><p>Complete your scene by adding materials / textures / etc in Redshift and light your scene. Go wild and work how you normally would, but <strong>remember that in the end we’ll be baking out a single flat beauty pass to apply to the model without any lighting handled in Three.js, so some things won’t translate</strong> (i.e. bump/displacement will affect the appearance of the bake (i.e. crevasses will have shadows), but you won’t see any bump/displacement on the model itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZNenoTiSfbG0kOmlg_aOOw.png" /><figcaption>I created and applied some basic Redshift materials to my scene, along with a standard lighting setup (3-point + dome light + overhead) light to give a shadow on the groundplane).</figcaption></figure><h3>3. Check your Redshift render settings and add an AOV.</h3><p>When we bake out the textures, we want to use ACEScg and raw colors in an exr file, so we can be sure we maintain all the color information possible. Make a few adjustments to your Redshift Render settings in the Globals tab in the Color Management section:</p><ul><li>Make sure Rendering Color Space is set to ACEScg,</li><li>Set the view to ‘Raw’</li><li>Turn off ‘Compensate for View Transform’)</li></ul><p>You’ll notice the color looks off if you have a Redshift RenderView/IPR open. That’s to be expected.</p><p>You also want to setup an AOV for the Beauty pass in the Redshift AOV Manager. Add the pass, then make sure ‘Direct’ is checked (you can uncheck ‘Multi-pass’), and under the Direct Output section on the right:</p><ul><li>Set the Format to ‘OpenEXR’,</li><li>Set the Bits Per Channel to ‘Float (32 Bits)’ (probably overkill, but whatever)</li><li>Set Compression to ‘DWAA.’</li></ul><p>You can optionally export other AOV’s if you want, which will also be output into their own image files when we bake. However, since we’re just looking to get the exact results we see in Redshift into Three.js, we just need the Beauty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J14K03wd_eNLWLRi4wB56g.png" /><figcaption>I’ve edited the Redshift Render settings under the Globals tab in the Color Management section and added a Beauty AOV as direct output pass. Notice how the color changed in my Redshift RenderView — this is normal.</figcaption></figure><h3>4. Combine geo that uses the same UV/Texture space, add a RS BakeSet, and bake!</h3><p>Because the tongs have three seperate pieces of geo, but I placed them on the same UV/Texture space, I want to temporarily combine them using this workflow:</p><ul><li>Duplicate the group.</li><li>Turn off editor visibility / render visibility for the original group.</li><li>Perform ‘Connect Objects and Delete’ on the duplicate. I renamed it to Tongs-Combined.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bMDV7PCXVLcwTn_I4pneg.png" /><figcaption>I temporarily combined all the tong geo into one piece of geometry since the different pieces of geo were already mapped to the same UV/Texture space.</figcaption></figure><p>This will ensure that when we do the bake, it outputs the baked textures for all the tong geo into one image file instead of separate ones based on each piece of geo. While you could combine the files separately in Photoshop this will make it easier, and give you nice edge painting / UV edge expansion in the texture image.</p><p>Now create your RS BakeSet by:</p><ul><li>Select all the geometry you want to bake (mine is the Tongs-Combined, the GroundPlane and the CuttingBoard).</li><li>Go to Redshift menu -&gt; Tools -&gt; Texture Baking -&gt; Create BakeSet from Selection.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UiPkG7HU0fUnIpurvGWmWw.png" /><figcaption>Create your RS BakeSet.</figcaption></figure><p>Now select the BakeSet in the outliner and update the width and height. I did 2K which is probably overkill, but you can always scale them down later based on the needs of the scene in Three.js. If you had another UV space set up that you wanted to bake to you could specify this in the UV source field, although since all of ours use a default one called UVW you can leave it blank. You can also verify that all the objects you want to bake are listed in the Objects field. If any are missing you can drag them here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BD5S3xwaeLv5UaU-WXtE6g.png" /><figcaption>Configure the RS BakeSet Object</figcaption></figure><p>Now you can click the Bake Button on the BakeSet. It will give you a pop up where you can set:</p><ul><li>The Output Folder for your textures</li><li>Uncheck the ‘Default Beauty AOV’ since we already configured one in the AOV Manager.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FrS8gEHm0WEt0BDPWPD5Kw.png" /><figcaption>Configure the ‘Bake Textures’ pop-up.</figcaption></figure><p>Click ‘Bake’ and it will take a while to render out your textures. You’ll have something like the below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m0oMoNSlFv0guVBJ4s3ulg.png" /><figcaption>Here’s what our OpenEXR baked textures look like.</figcaption></figure><h3>5. Color correct the textures (in After Effects).</h3><p>Because we wanted all the color information we could get and we used the ACEScg color space in Redshift, we need to do some color conversion on our OpenEXRs so that they look correct in Three.js by making sure they’re in sRGB color space. The way I know how to do this is by using After Effects:</p><ul><li>Make sure your color settings in Project Settings use: 32 bps, sRGB, and check ‘Linearize Working Space.’ (see below)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*htjX6ZWk7X0us9eVTbSBOQ.png" /><figcaption>You can easily access this menu by clicking where the arrow indicates.</figcaption></figure><ul><li>Import your OpenEXRs into After Effects as Compositions. Make sure to import as compositions, but there’s no need for a contact sheet. (see below)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5YAr2suhuJiNfMHq8MpLIg.png" /><figcaption>Import the EXRs as Compositions</figcaption></figure><ul><li>Put all of the OpenEXR’s into one composition. Trim them each to 1 frame, and offset their positions in time by 1 frame so you can see them all and scrub through them using the current time indicator. (see below)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kkJBYCup927SLXAkZEokXQ.png" /><figcaption>Setting up a MainComp like this will allow you to only add the color conversion adjustment layer once, and you can export all textures just by rendering this comp to an image sequence.</figcaption></figure><ul><li>Now add an adjustment layer to the top of this comp and add the OpenColorIO effect (<a href="http://fnordware.blogspot.com/2012/05/opencolorio-for-after-effects.html">available here</a>) to that layer. From the Configuration dropdown, add Redshift’s config file which is in the Applications/redshift/Data/OCIO directory and called config.ocio. (see below)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_zNsEu1UJ-aK_sqrsZwfTA.png" /><figcaption>Add the OpenColorIO effect to the Adjustment Layer and set it to use the Redshift OCIO config file.</figcaption></figure><ul><li>Now set the OpenColorIO effect to ‘Display’ mode. Set the Input Space to ‘ACEScg’, and set the Display to ‘sRGB’. The color still won’t look right, we first need to add a Color Profile Converter effect below the OpenColorIO effect. Set the input profile to ‘sRGB.’ Finally, our colors should look exactly how they looked when we set up our materials and lights in Redshift! If you want to edit the textures you can, just add any adjustments BELOW that top Color Conversion layer to make sure you’re harnessing all the color information in the OpenEXRs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FG2PATDH0K7cspUY1cFzyg.png" /><figcaption>Our color is looking correct!</figcaption></figure><ul><li>Next we can render our timeline (all three frames) as a PNG sequence, and we’ll have our texture files ready to use in Three.js. For now, render them with high bit depth and at full res (2048). Once they’re output you can down-res them or compress them to jpg, etc. They should look like the below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rh8A1DQAgzCCa8lwKZ5lTQ.png" /><figcaption>Our color converted textures.</figcaption></figure><h3>6. Export your Cinema 4D scene as a glb/gltf.</h3><p>Switch back to your Cinema 4D file, and get it ready to export to glb/gltf. You may want save your scene as a duplicate like ‘-JustGeo’ or something because we’ll be cleaning out the things we won’t need for Three.js.</p><p>Remove any lights, cameras, and the duplicate geo you made to facilitate the texture baking. The only thing left in your outliner should be Nulls, Geometry, and possibly Bones if you have something rigged (although there are a lot of intricacies for exporting a rigged/skinned object so do some experimentation before relying on this workflow for anything animated or rigged with bones). You can remove the material tags too, but leave the UV tags and the Phong tags in place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mpd-zVrEsQAObENyzQqe2g.png" /><figcaption>This is what your file should look like before export. Boring!</figcaption></figure><p>Now go to File -&gt; Export -&gt; glTF and configure it with the following settings, and save it out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_G5qlukNFzQwAC6dQvj1A.png" /><figcaption>Export settings to export our model for Three.js</figcaption></figure><h3>7. Import your .glb and textures into Three.js</h3><p>There are basically 4 things you need to do to get your scene working in Three.js</p><ol><li>Create a generic scene with basic boilerplate Three stuff (a canvas, a scene, a camera, orbit controls, a renderer, a resize event for the browser window, initialize a texture loader and a gltf loader, and add an animation loop).</li><li>Load the three texture files from their URIs, update each of their encodings to be THREE.sRGBEncoding, and set each of their flipY properties to false.</li><li>Create three MeshBasicMaterials (one for each texture) and set their map property to be the texture objects above.</li><li>Load the gltf. During the loading, traverse the gltf and apply the correct material to each piece of geometry (the naming from the Cinema 4D export will remain, so just search for meshes with those names). And add the gltf to the Three.js scene.</li></ol><p>And boom — you’ll have your 3D model running in the browser with the same high quality look you developed in Redshift and Cinema 4D.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xNdQDlrAEj0F2stoNJEX5g.png" /><figcaption>Ah, an interactive camera running at 60fps+ viewing our lovely little Cinema 4D model with Redshift materials and lighting.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51acb4f8ac5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>