Tech/LxEngine/ShaderBuilder

From Athile

Jump to:navigation, search
This page is a work-in-progress. It is not yet complete.
It may contain inaccurate, incorrect information. Use at your own risk.

This documentation is still under heavy construction. Documentation updates to address questions posted on the forum will be prioritized.

Overview

The ShaderBuilder is a system for dynamically generating a shader (and the parameters to that shader) from a JSON description of a shader graph. The ShaderBuilder is intended to work for multiple targets: e.g. GLSL as well as a native CPU ray-tracer.

The ShaderBuilder describes library only; it does not include any GUI for creating such shader graphs.

Contents


A nested procedural material composed of a weave pattern and a Phong-shader checker pattern.

Goal is for the shader graph compiler to be independent of LxEngine; such that other engines, following a minimal set of naming conventions (or possibly passing in a table of presets) can use the output shader source.

A Material is a hierarchy of parameters that describe how to render geometry.

Internally, this set of parameters is parsed and mapped to shader and shader parameter pair. LxEngine will reuse the same shader program when possible.

The hierarchy of parameters creates a graph of connected nodes. These nodes have names which refer to "graph fragments".

Each node definition becomes a function. Each node in the graph becomes a call to a function. The result values are saved so they can be reused by multiple subsequent nodes. The tree is processed bottom-up.

Materials Library

Shading Nodes

solid

Solid.png

Returns the input "color" parameter directly. The default is gray.

Source: https://github.com/athile/lxengine/blob/master/lx0/dev/media/shaders/glsl/nodes/solid.node

phong

Phong.png

Source: https://github.com/athile/lxengine/blob/master/lx0/dev/media/shaders/glsl/nodes/phong.node

Pattern Nodes

checker

Checker.png

Source: https://github.com/athile/lxengine/blob/master/lx0/dev/media/shaders/glsl/nodes/checker.node

spot

Spot.png

Source: https://github.com/athile/lxengine/blob/master/lx0/dev/media/shaders/glsl/nodes/spot.node

tile

square

diamond

star

wave

weave

Mapping Nodes

Navigation
Toolbox