Home Reference VEX VEX contexts 

surface vex context

Define a surface shader with a program that sets the final color, opacity, and alpha of a surface being rendered.

The surface shading context’s purpose is to set the final color, opacity and alpha of the surface being rendered. If the Of and Af variables are not set, they will default to 1. If the Af variable is not set, it will resolve to avg(Of). It is possible to set the Af variable to any arbitrary value, making it possible to build matte/cutout shaders.

Globals

Time (read-only)

The time at which the shading occurs, as a number from 0 (shutter open) to 1 (shutter close).

dPdz (read-only)

Floating point step size for volume rendering.

P (read-only)

Position of the point on the surface being shaded. In light or shadow shaders, the P variable contains the point on the light source.

Ng (read-only)

Geometric normal for the surface. This normal represents the “true” normal of the surface being shaded. For example, with Phong shading, the N variable represents the interpolated normal, while the Ng variable represents the true polygon normal.

L (read-only)

Vector from the point on the surface to the light source. The length of this vector represents the distance to the light source.

dPds (read-only)

Change in position with respect to the parametric s.

Pz (read-only)

Z component of the point being shaded.

I (read-only)

Direction from the eye to the point being shaded. This may or may not be a normalized vector.

Of

Final opacity for the surface. A value of {1,1,0} will be opaque in red/green, but let through blue light from behind. See opacity vs. alpha .

Eye (read-only)

Position of the eye.

dPdt (read-only)

Change in position with respect to the parametric t.

Cf

Final color for the surface. The vector represents the RGB color .

F

Output bsdf for physically based rendering (see how to write a PBR shader).

t (read-only)

Parametric t (sometimes called v) coordinate of the surface being shaded.

N

Shading normal for the surface.

Cl

Light color.

s (read-only)

Parametric s (sometimes called u) coordinate of the surface being shaded.

Af

Final alpha for the surface. This is the value which is placed in the alpha channel of the output image. See opacity vs. alpha .