Skip to content

Normal

Rendering function

from fdray import *


def render(*attrs):
    return Scene(
        Include("colors.inc", "textures.inc"),
        Camera(0, 90, view_scale=1, look_at=(0.5, 1, 0)),
        LightSource((2, 3, 4), "white", from_camera=False),
        Box((0, 0, 0), (1, 2, 0.1), Texture("Chrome_Metal", *attrs)),
    ).render(400, 200)

Slope map

smap = SlopeMap((0, (0, 0)), (0.5, (1, 1)), (0.5, (1, -1)), (1, (0, -1)))
render(Normal("wood", smap).scale(0.5))

Normal map

a = Normal("marble", turbulence=0.4)
b = Normal("facets", coords=0.3, scale=0.3)
n = Normal("gradient x", NormalMap((0.2, a), (0.4, b), (0.6, b), (0.7, a)))
render(n.scale(0.4))

Normal pattern

Scene(
    Camera(30, 20, view_scale=1, look_at=(0.5, 0.5, 0.5)),
    LightSource(0, "white"),
    Box(0, 1).pigment(Color("white")).normal("agate"),
).render(300, 300)