Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class Shading
- Object
- Shading
Small building blocks most surface shaders share: view dependent terms,
fades, world space texture coordinates and signed distance shapes.
Fragment stage unless a method says otherwise.
Methods
Inherited methods
Method details
fresnel
public static ShaderNode fresnel(float power)Schlick style edge factor: 0 facing the camera, 1 at grazing angles.
Parameters
powerfloat- higher keeps it closer to the silhouette; 5 is physical
Returns
a
FLOATrim
public static ShaderNode rim(ShaderNode color, float power)A coloured glow along the silhouette.
Parameters
colorShaderNode- a
VEC3 powerfloat- how tight the rim is, 2 to 8
Returns
a
VEC3, for the EMISSIVE hookheightFade
public static ShaderNode heightFade(float from, float to)1 below
from and 0 above to along world height, smoothly between.
Both stages.Parameters
fromfloat- the height where the fade starts
tofloat- the height where it ends
Returns
a
FLOATdistanceFade
public static ShaderNode distanceFade(float from, float to)1 near the camera and 0 beyond
to, for fading detail out with
distance. Both stages.Parameters
fromfloat- the distance where the fade starts
tofloat- the distance where it ends
Returns
a
FLOATworldUv
public static ShaderNode worldUv(float scale)Texture coordinates from world position seen from above, so a pattern
tiles across meshes without seams and ignores their UVs. Both stages.
Parameters
scalefloat- repeats per world unit
Returns
a
VEC2boxUv
public static ShaderNode boxUv(float scale)Texture coordinates that follow the surface on every face: the world
plane the normal faces most, so walls do not smear a pattern seen from
above. A cheap one sample stand-in for triplanar blending.
Parameters
scalefloat- repeats per world unit
Returns
a
VEC2scroll
public static ShaderNode scroll(ShaderNode uv, float u, float v)A texture coordinate that scrolls with time. Both stages.
Parameters
uvShaderNode- a
VEC2 ufloat- units per second along u
vfloat- units per second along v
Returns
a
VEC2sdCircle
public static ShaderNode sdCircle(ShaderNode p, ShaderNode center, float radius)The signed distance to a circle: negative inside.
Parameters
pShaderNode- a
VEC2point centerShaderNode- a
VEC2 radiusfloat- the radius
Returns
a
FLOATsdBox
public static ShaderNode sdBox(ShaderNode p, ShaderNode center, ShaderNode halfSize)The signed distance to an axis aligned box: negative inside.
Parameters
pShaderNode- a
VEC2point centerShaderNode- a
VEC2 halfSizeShaderNode- a
VEC2of half the width and height
Returns
a
FLOATsdSegment
public static ShaderNode sdSegment(ShaderNode p, ShaderNode a, ShaderNode b)The distance to a line segment.
Parameters
pShaderNode- a
VEC2point aShaderNode- a
VEC2end bShaderNode- the other
VEC2end
Returns
a
FLOAT, never negativefill
public static ShaderNode fill(ShaderNode distance, float softness)Turns a signed distance into coverage with a soft edge: 1 inside, 0
outside.
Parameters
distanceShaderNode- a signed distance
softnessfloat- the width of the edge
Returns
a
FLOATstroke
public static ShaderNode stroke(ShaderNode distance, float width, float softness)A band of
width around the zero line of a signed distance: outlines,
rings, foam lines along a shore.Parameters
distanceShaderNode- a signed distance
widthfloat- the band width
softnessfloat- the width of its edges
Returns
a
FLOATramp
public static ShaderNode ramp(ShaderNode t, ShaderNode a, ShaderNode b, ShaderNode c)A smooth three colour ramp:
a at 0, b at 0.5, c at 1.Parameters
tShaderNode- a
FLOAT aShaderNode- a
VEC3 bShaderNode- a
VEC3 cShaderNode- a
VEC3
Returns
a
VEC3opaque
public static ShaderNode opaque(ShaderNode rgb)Opaque
VEC4 from a VEC3 colour.Parameters
rgbShaderNode- a
VEC3
Returns
a
VEC4 with alpha 1