Visualise Tex Coords

From Terragen Documentation from Planetside Software
Jump to: navigation, search
Visualise Tex Coords



Overview[edit]

In order to apply textures to 3D objects and the terrain, the vertices of a 3D object or the sample points in a terrain make use of texture coordinates which instructs the shader how to colour the given point.

The Visualise tex coords shader outputs an RGB representation of the 3D vector of the texture coordinates, remapping them into the visible range of 0 to 1. In this colour representation the R value is the X component, the G value is the Y, and the B value is the Z. The shader can output this information as diffuse or luminosity. Also note that the Get Position in Texture function can provide the same information, but not as luminosity.

For terrains, the texture coordinates are calculated via a Compute Terrain node or the Tex Coords from XYZ node which return the X,Y and Z position in world space for a given sample point. World space starts at the origin of the project at 0,0,0 and by default is scaled to 1 metre. You can increase the scale by applying a Transform Input node or Transform Merge node after the Visualise Tex Coords node and increasing its XYZ scale values.

Visualise tex coords applied to terrain.
The Transform Merge node can be used to scale the Visualise tex coords scale, which defaults to 1 metre x 1 metre.

Imported 3D geometry makes use of the object’s UV coordinates which can be formatted in UV or UDIM layouts. The X and Y position for each vertex synchronize to the texture map providing the colour information. Typically, the UV coordinates for the bottom left corner are 0,0 and the top right corner are 1,1. UDIM layouts provide a way to offset vertex coordinates, by shifting them to a new 0 to 1 space. This provides a way in which to apply separate texture maps, with various resolutions, to specific surfaces on the object; in other words, you can assign higher resolution texture maps to the areas that require more texture data or use smaller texture maps for areas not often seen.

Example of workflow using UV layout.
Example of workflow using UDIM layout.

Terragen 4 Professional can save the raw texture coordinate data for a rendered frame via its Render Layer feature by enabling the Surface Position checkbox under the Render Elements tab. This render element can be useful for post processing effects and adjustments to the beauty pass. This does not require a Visualise tex coords node within a project.

Render Elements tab


Settings:

    • Name: This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Visualise tex coords nodes in a project.
    • Enable: When checked, the node is active and the settings below will affect the surface. When unchecked, the node is ignored.
    • Diffuse: When checked, the surface of the object or terrain is treated as a diffuse surface.
      Diffuse setting enabled in the Visualise tex coords applied to terrain.
      Diffuse setting enabled in the Visualise tex coordinates shader of the UV Cube object.
    • Luminous: When checked, the surface of the object or terrain is treated as fully luminous.
      Luminous setting enabled in the Visualise tex coords applied to terrain.
      Luminous setting enabled in the Visualise tex coords shader of the UV Cube object.
    • Repeat: When checked, the texture coordinate values of a procedural object such as the terrain, will be tiled across the surface, repeating the 0 - 1 range.
      Repeat enabled with scale at 1,500 metres.
      Repeat enabled with scale at 10,000 metres.


Fun with Visualise Tex Coords[edit]

A very practical use of the Visualise Tex Coords node is to be able to see how a displacement affects a surface. When prominent terrain features are present, it’s often easy to discern the direction and amount of displacement, however when dealing with smooth surfaces, such as an undisplaced planet surface or one with very little surface features, it can be difficult to see what the effects of a displacement shader may be having in these areas.

Let’s add a simple terrain feature to the default Terragen project in order to see what the Visualise Tex Coords can show us.

  • Click on the “Terrain” button on the top toolbar.
  • Click on the “Add Terain” button at the top of the Terrain Node List and select “Displacement Shader” then “Simple shape” from the drop down menu.
    Step 01 - Add a Simple shape shader to the terrain.


  • Set the “Type of shape” to “Polygon”. With the default settings we’ll get a shape that has a pointed end heading in the positive Z axis.
  • Set the “Size” to “500” by “1000”, so that the shape is thinner along the X axis and longer along the Z axis.
  • Under the Displacement tab, checkApply displacement”.
  • Set “Displacement amplitude” to “100”.
  • Set “Edge profile” to “Bevel”.
  • Set “Edge width” to “25”.
  • Set “Edge units” to “Percentage”.
    Step 02 - Adjust the Simple shape shader settings.


Let’s also include a texture feature so we can see how any displacement affects that as well.

  • Click on the “Shaders” button on the top toolbar.
  • Click on the “Add Layer” button at the top of the Shader Node List and select “Colour Shader” then “Simple shape” from the drop down menu.
    Step 03 - Add another Simple shape shader for texture.


  • Set “Size” to “100” by “100”.
    Node Network view - Steps 01 through 03.


Here’s a render of what we’ve got so far, a pentagon terrain feature with a white dot.

    Rendered image of Steps 01 through 03.


Now let’s add a displacement to the surface of the planet that will affect our new additions to the project.

  • In the Node Network pane, right-click on the Simple shape shader 02 node and select “Displacement shader” then “Redirect” from the context menus that appear.
    Step 04 - Add a Redirect shader to the project.


  • Right-click on the “X shader” input of the Redirect shader and select “Create new Shader” then “Colour Shader” then “Power fractal shader v3”.
    Step 05 - Add and assign a Power fractal shader to the Redirect shader’s X shader input.


  • Double-click on the Power fractal shader v3 node to open its dialog window.
  • Set “Feature scale” to “10”.
    Step 06 - Adjust the Power fractal shader’s Scale tab settings.


  • Under the Displacement tab, checkApply displacement”.
  • Set “Displacement amplitude” to “100”.
    Step 07 - Adust the Power fractal shader’s Displacement tab settings.


In the rendered image below, we can clearly see the displacement along the sides of the new terrain feature and also the white dot, but it’s almost impossible to tell what affect the Redirect shader is having on the flat and smooth areas of the terrain.

    Rendered image through Step 07.


This is where the Visualise Tex Coords shader comes in handy.

  • Click on the “Add Layer” button at the top of the Shader Node List and select “Colour Shader” then “Visualise tex coords” to add the shader to the project.
    Step 08 - Add a Visualise tex coords shader to the project.


When we render a frame or look through the 3D Preview this is what we see.

    Rendered image through Step 08.


Although we can see some displacement along the edges where the magenta colour meets the pale green colour, it’s not much help yet, and this is because by default the node’s “Repeat” parameter is checked and Terragen’s default unit equals 1 meter, which means that a 1 meter repeating pattern is being projected across the entire terrain. We need to adjust the size of the pattern so that it’s appropriate for our terrain features.

  • Click once in an empty area of the Node Network pane to focus the program’s attention there. A dotted yellow line will become visible around the Node Network pane.
  • Press the “Tab” key or “N” key to open the Quick Node Palette window.
  • Start typing the words “Transform merge shader” and the closest match in the Node list will be highlighted.
  • With “Transform merge shader” highlighted, press the “Enter” key to add it to the project.
  • Drag a connection line from the “Output” of the Simple shape shader 03 node to the “Main input” of the Transform merge shader node.
  • Drag a connection line from the “Output” of the Visualise tex coords node to the “Shader” input of the Transform merge shader node.
  • Disconnect the connection line from the “Output” of the Simple shape shader 03 node to the “Main input” of the Visualise tex coords node.
  • Drag a connection line from the “Output” of the Transform merge shader node to the “Surface shader” input of the Planet node.
  • Double-click the Transform shader node to open its dialog window.
  • Check the “Scale shader” checkbox and set all three of its component values to “100”.
    Node Network view  of project through Step 09.


In the rendered image below, now we can see how the displacement affects not only on the terrain feature but the flat and smooth areas as well!

    Rendered image through Step 09.



A sample refers to a value or set of values at a point in time and/or space. The defining point of a sample is that it is a chosen value out of a continuous signal. In Terragen 2 it is usually a mathematical (procedural) function that is being sampled.

A shader is a program or set of instructions used in 3D computer graphics to determine the final surface properties of an object or image. This can include arbitrarily complex descriptions of light absorption and diffusion, texture mapping, reflection and refraction, shadowing, surface displacement and post-processing effects. In Terragen 2 shaders are used to construct and modify almost every element of a scene.

A vector is a set of three scalars, normally representing X, Y and Z coordinates. It also commonly represents rotation, where the values are pitch, heading and bank.

A single object or device in the node network which generates or modifies data and may accept input data or create output data or both, depending on its function. Nodes usually have their own settings which control the data they create or how they modify data passing through them. Nodes are connected together in a network to perform work in a network-based user interface. In Terragen 2 nodes are connected together to describe a scene.

Literally, to change the position of something. In graphics terminology to displace a surface is to modify its geometric (3D) structure using reference data of some kind. For example, a grayscale image might be taken as input, with black areas indicating no displacement of the surface, and white indicating maximum displacement. In Terragen 2 displacement is used to create all terrain by taking heightfield or procedural data as input and using it to displace the normally flat sphere of the planet.

In a graphical user interface (GUI) on a computer a toolbar is a row, column, or block of onscreen buttons or icons that, when clicked, activate certain functions of the program.

A parameter is an individual setting in a node parameter view which controls some aspect of the node.