core.shader.create_from_raw
Client
Creates a new shader instance directly from a GLSL source string
Syntax
local instance = core.shader.create_from_raw(
raw,
mode
)Parameters
| Type | Name | Description |
|---|---|---|
string | raw | Raw GLSL shader source code |
core.shader.shader_mode | mode | Rendering pipeline to target |
Returns
| Type | Name | Description |
|---|---|---|
shader | instance | Created shader instance |
Examples
local raw = [[
void fragment() {
COLOR = vec4(UV, 0.0, 1.0);
}
]]
local entity = core.shader.create_from_raw(raw, core.shader.shader_mode.CANVAS_ITEM)
util.event.on("sandbox:draw", function()
core.engine.draw_material(
{0, 0},
core.engine.get_resolution(),
entity
)
end)local raw = [[
uniform float dissolve_amount : hint_range(0.0, 1.0) = 0.0;
void fragment() {
ALBEDO = vec3(dissolve_amount);
}
]]
local entity = core.shader.create_from_raw(raw, core.shader.shader_mode.SPATIAL)
entity:set_param("dissolve_amount", 0.5)