four.Effect
.__newindex (t, k, v)
local lib = { type = 'four.Effect' } four.Effect = lib
local Color = four.Color local Effect = lib
-- Meta table to detect shader source changes. Allows the renderer to -- dynamically recompile the GPU program.
local isShaderKey = { vertex = true, geometry = true, fragment = true }
if k == "shaders" then return rawget(t, k) elseif isShaderKey[k] then return t.shaders[k] else return lib[k] end end
if isShaderKey[k] then local shaders = t.shaders shaders[k] = v t.program_changed = true else rawset(t, k, v) end end
setmetatable(lib, { __call = function(lib, ...) return lib.new(...) end})
-- h2. Render states
--[[-- h3. Rasterization state
Note. Faces with a counter clock-wise orientation are front faces.
Rasterization state is described by a table with the following keys:
- @face_cull@, faces to cull (defaults to @CULL_NONE@).
TODO MISSING DOCUMENTATION
.defaultRasterization 1
TODO MISSING DOCUMENTATION
.CULL_FRONT = 2
TODO MISSING DOCUMENTATION
.CULL_BACK = 3
TODO MISSING DOCUMENTATION
.defaultDepth 1
TODO MISSING DOCUMENTATION
TODO MISSING DOCUMENTATION
.DEPTH_FUNC_LESS = 2
TODO MISSING DOCUMENTATION
.DEPTH_FUNC_EQUAL = 3
TODO MISSING DOCUMENTATION
.DEPTH_FUNC_LEQUAL = 4
TODO MISSING DOCUMENTATION
.DEPTH_FUNC_GREATER = 5
TODO MISSING DOCUMENTATION
.DEPTH_FUNC_NOTEQUAL = 6
TODO MISSING DOCUMENTATION
.DEPTH_FUNC_GEQUAL = 7
TODO MISSING DOCUMENTATION
.DEPTH_FUNC_ALWAYS = 8
TODO MISSING DOCUMENTATION
.new (def)
@Effect(def)@ is a new effect object. @def@ keys:
- @default_uniforms@, key/value table, defining default values for uniforms.
- @uniform@, uniform lookup function invoked before rendering a renderable. defaults to @function(self, cam, renderable, name) = return renderable[name]@. If the function returns @nil@, @default_uniforms@ is used.
- @vertex@, vertex shader source.
- @geometry@, geometry shader source (optional).
- @fragment@, fragment shader source.
- @depth@, depth state keys to override the defaults (see Depth state).
- @rasterization@, rasterization state keys to override the defaults (see Rasterization state).
- @opaque@, defines whether the effect is opaque. Renderables with opaque effects are rendered before non-opaque ones.
:set (def)
TODO MISSING DOCUMENTATION
.Shader (src)
TODO MISSING DOCUMENTATION
.MODEL_TO_WORLD = { special_uniform = true }
h2. Special uniform values
TODO MISSING DOCUMENTATION
.MODEL_TO_CAMERA = { special_uniform = true }
TODO MISSING DOCUMENTATION
.MODEL_TO_CLIP = { special_uniform = true }
TODO MISSING DOCUMENTATION
.MODEL_NORMAL_TO_CAMERA = { special_uniform = true }
TODO MISSING DOCUMENTATION
.WORLD_TO_CAMERA = { special_uniform = true }
TODO MISSING DOCUMENTATION
.WORLD_TO_CLIP = { special_uniform = true }
TODO MISSING DOCUMENTATION
.CAMERA_TO_CLIP = { special_uniform = true }
TODO MISSING DOCUMENTATION
.CAMERA_RESOLUTION = { special_uniform = true }
TODO MISSING DOCUMENTATION
.RENDER_FRAME_START_TIME = { special_uniform = true }
TODO MISSING DOCUMENTATION
:vertexShaderSource (pre)
TODO MISSING DOCUMENTATION
TODO MISSING DOCUMENTATION
:fragmentShaderSource (pre)
TODO MISSING DOCUMENTATION
:geometryShaderSource (pre)
.Wireframe (def)
TODO MISSING DOCUMENTATION
.Normals (def)
@Normals(def)@ renders the normals of geometry.
- @normal_scale@, a scale factor to apply to the normals.
- @normal_color_start@, color at the starting point of the vector.
- @normal_color_end@, color at the end of vector.
TODO
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
#setTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
EffectTODO MISSING DOCUMENTATION
#vertexShaderSourceTODO MISSING DOCUMENTATION
#vertexShaderSourceTODO MISSING DOCUMENTATION
#fragmentShaderSourceTODO MISSING DOCUMENTATION
EffectTODO use discard ?
EffectTODO MISSING DOCUMENTATION