# X to Scalar

## Contents

## Overview[edit]

The X/Y/Z to scalar nodes all take a vector as input and output the respective vector component as a scalar. For example, the X to scalar node will output the X value of the input vector.

This node has no other settings apart from the Input node.

**Settings:**

**Name:**This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple X to scalar nodes in a project.**Enable:**When checked, the node is active and the conversion operation will take place. When unchecked the values assigned to its Main Input, if any, are passed through, otherwise a value of 0 is passed through.

## Fun with X to Scalar[edit]

Using the X to scalar node you can define parallel lines, warp them into interesting shapes, then use them as masks for a multitude of things, like displacement or cloud density.

To create a bunch of rows, start by adding these three function nodes to the project. An X to scalar node, a Get position in texture node, and a Sin scalar node. You can quickly add these nodes to the project via the Quick Node Palette by pressing the Tab key, selecting the node and pressing the Enter key.

The X to scalar node needs a vector as input, so we use a Get position in texture node to provide the texture coordinates for the point being sampled. The X to scalar node outputs a scalar value to the Sin scalar which creates the rows. To visualize what these three nodes are doing in the 3D Preview, apply them as a mask to a Surface layer node.

- Add an X to scalar node to the project.
- Add a Get position in texture node to the project and connect its output to the Main Input of the X to scalar node.
- Add a Sin scalar node and connect the output from the X to scalar node to its Main input.
- Add a Surface layer node and connect the output from the Sin scalar node to its Mask shader input.
- Check the Surface layer’s Enable test colour parameter to easily visualize the effect of the node in the 3D Preview.

You can scale the rows by multiplying the X to scalar value by another value. We’ll use a Constant scalar node to provide that value, and a Multiply scalar node to do the multiplication operation.

- Add a Multiply scalar node to the project and connect its output to the Sin scalar node’s Main input.
- Connect the output from the X to scalar node to the Main input of the Multiply scalar node.
- Add a Constant scalar node and connect its output to the Multiply scalar node’s Input 2.
- Double click the Constant scalar node to open its window and try some values to the Scalar input parameter to see their effect.

To warp the straight rows into more interesting shapes we’ll add a Fractal warp shader after the Sin scalar node. The Fractal warp shader has a number of parameters in which to modify the values assigned to its Main input.

- Add a Fractal warp shader to the project and connect its output to the Surface layer’s Mask shader.
- Connect the output from the Sin scalar node to the Main input of the Fractal warp shader.
- Double click on the Fractal warp shader and enter different values into its parameters to see the effect on the straight rows.

Now we can use this not only as a mask, but to displace the surface of the planet as well. With the Surface layer shader you can control the height of the displacement and constrain it by altitude and slope.

- Connect the output of the Fractal warp shader to the Surface layer’s Displacement input.
- Double click the Surface layer node to open its window and under the Displacement tab increase the Displacement multiplier value to see its effect.
- Under the Altitude constraints tab, check the Limit maximum altitude checkbox and modify the Maximum altitude parameter to see its effect.

A scalar is a single number. 1, 200.45, -45, -0.2 are all examples of scalar values.

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.

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 parameter is an individual setting in a node parameter view which controls some aspect of the node.

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.