2.6. Appearance in 3D

Changing the appearance of 3D bodies is achieved via several different methods

Not all methods work for every renderer (for example, normal mapping is not taken into accound for vectorial BREP renderers).

Some renderers use 2D techniques, so appearance in 2D can be used. For example, for BREP renderers, with cell-shading, line.style is still used.

See also appearance in 2D

2.6.1. Hierarchy of appearances

Normally, if an apperance is set to an object, all the components that do NOT define an appearance of their own, will inherit the father’s appearance. If explicitely changed, however, the changes prevail:

an example of children objects with their own color,

Sometimes we want to force an object to get one only appearance. This is done via a paremeter .force on a color, texture, or both:

semaphore c: .at 0 0 0 : .state red : # this has three colors, for example
semaphore d: .at 10 0 0 : color blue .force   # now this has been forced

Todo

valorar hacerlo con un operador??

2.6.2. Mixing color and textures

If an object has a color and a texture, the texture prevails. Normal mapping does not interfere with textures or color.

Shine and emitance

2.6.3. Surface appearance

2.6.3.1. Color

Surfaces can get a color. In this case, the alpha value of the given color has no effect, as a body transparency does not depend on the color of the surface.

Surfaces get painted with that color

2.6.3.2. Shine

2.6.3.3. Emmitance

2.6.3.4. Reflection

Alternatively, a reflection function can be given

2.6.4. Textures

Textures paint a surface. Texture shaders work on a pixel level in the raster pipeline and how????:

brick c: .size 20 20 20 cm : .texture {.file file1.png .scale .2 ..rotation 23deg}
sphere s: .radius 20cm : .texture wood.oak

To specify a texture, just give the name of a library texture, or specify

2.6.4.1. Arguments

If an argument given, it will be taken as the name of a texture in the library

2.6.4.2. Parameters

  • image: a canvas with the texture
  • file: an image file (png, etc)
  • scale: scale of the texture
  • rotation: rotation of the texture
  • wraparound: one of wrap , wrapx, wrapy, mirrorx, mirrory, mirror, tiles
    • tiles: is when providing several images. They will be used randomly
    • wrap: texture wraps in the two dimensions
    • wrapx:
    • wrapy:
    • mirrorx:
    • mirrory:
    • mirror:

Todo

figure with the different types of wraparound

2.6.4.3. library textures

There are predefined textures in the library:

  • plastic:
  • wood: oak, pine, etc
  • metal: iron, stainlesssteel, etc.
  • other: grass

Textures will not be shown on some renderers. For example, vectorial renderers get only a color in place of the texture (defined in each texture as <texture>.fallbackcolor).

2.6.4.4. Vectorial vs raster textures

there are vectorial textures, too, that paint on the surface.

  • Mottled
  • Stripped
  • squareflag

2.6.5. Normal mapping

The last is normal mapping

2.6.6. Operators

Operators are included here only for completitud purposes, as they modify the structure of the object. For example:

cube c: size  20 20 20
hairgrow c: .random

Now we have a hairy cube, something different. See operator reference