Package com.codename1.gpu.shaders
package com.codename1.gpu.shaders
A library of ready made shaders built on com.codename1.gpu.shader, to
mix and match into a scene: water, terrain, foliage, surfaces, toon
styles, effects, liquids and skies, plus ScenePresets that set the
light, sky and post processing to suit.
Every factory returns an ordinary ShaderMaterial, built only from
public ShaderNode calls, so each one runs on every backend and doubles
as an example to copy and change. Each class names its tunable uniforms
as constants; set them with ShaderMaterial.setUniform at any time, even
every frame, without rebuilding anything.
import com.codename1.gpu.*;
import com.codename1.gpu.shaders.*;
void setUp(GraphicsDevice device) {
ScenePresets.Preset look = ScenePresets.harbourDusk();
look.apply(device);
Mesh sea = Primitives.grid(120f, 160);
Material water = new Material(Material.Type.PBR).setShader(Water.ocean());
Material quay = new Material(Material.Type.PBR).setShader(Surface.concrete());
Material crates = new Material(Material.Type.PBR).setShader(Surface.paintedMetal());
}
-
ClassesClassDescriptionPlants that move in the wind.Effects: energy, magic, damage and sci-fi surfaces.Glowing and moving liquids, and the light water throws on what lies under it.Procedural noise built from
ShaderNodemath, so it runs in either stage on every backend and needs no texture.Complete looks: a sun, the sky's light, fog, tone mapping, post effects and a matchingSkydome, tuned to work together.A light, environment, post chain and sky dome that belong together.Small building blocks most surface shaders share: view dependent terms, fades, world space texture coordinates and signed distance shapes.Sky domes: draw an inside-out sphere (Primitives.sphere(r, 24, 32, true)) around the camera with aMaterial.Type.UNLITmaterial andsetFogged(false). The colour depends only on the direction from the camera, so the dome's size and position do not matter. The sun follows the scene's light.Man made and natural surfaces forMaterial.Type.PBR.Ground.Stylized, non photographic shading.Water surfaces.