Difference between revisions of "Warp Shader"

The Warp Shader performs a domain distortion on the shader attached to its "shader" input, using the displacement vectors from the shader attached to its "warper" input. It does this by offsetting the texture coordinates before they are used by "shader". This almost looks like the warper bends the final result, but it's actually bending the space before it is read by the shader. A simplistic way you can think about it is that the shapes from the warper will bend the final texture (but in the opposite direction).

When the Warp Shader is asked to shade or displace a point, the following happens. First, like most other shaders in Terragen, the Warp Shader calls the shader connected to its main input. The main input is not warped. Then "warper" is called to produce a displacement vector. To produce the warp effect the warper must be a displacement shader or a network of shaders producing displacement. The displacement is not applied to the surface; its vector is merely stored for the next step. Next, the texture coordinates ("position in texture") are offset by the displacement vector, and then "shader" is called. The shader will produce different results because it works with modified texture coordinates. Finally, the texture coordinates are reset so that shaders following the Warp Shader will not be affected.

If you have a colour shader, colour function, scalar function or vector function that you want to use as your warper, you can turn it into displacement using a Displacement Shader or a Vector Displacement Shader.

You may see the Warp Shader and the Redirect Shader used in the same context. The reason the Warp Shader and the Redirect Shader often work well together is because the Redirect Shader allows you to construct displacement vectors which go in all directions, which can be useful for warping a 3D function such as the Power Fractal. If you just use a single fractal operating along the normal as your warper, you might not easily see its warping effect.

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.

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.

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 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 scalar is a single number. 1, 200.45, -45, -0.2 are all examples of scalar values.