Functions for interacting with compute programs.
Version: alpha
| FUNCTIONS | |
|---|---|
| compute.get_constants() | gets shader constants from a compute program |
| compute.get_samplers() | gets texture samplers from a compute program |
| compute.get_textures() | gets textures associated with a compute program |
| compute.set_constants() | sets shader constants in a compute program |
| compute.set_samplers() | sets texture samplers in a compute program |
| compute.set_textures() | sets textures in a compute program |
compute.get_constants(path:hash|string)→table:material.constant_info[]
Returns a table of all the shader constants in the compute program.
PARAMETERS
path |
hashstring |
The path to the resource |
RETURNS
table |
material.constant_info[] |
Information about the shader constants. |
EXAMPLES
Get the shader constants from a compute program resourcefunction init(self)
local constants = compute.get_constants("/my_compute.computec")
end
compute.get_samplers(path:hash|string)→table:material.sampler_info[]
Returns a table of all the texture samplers in the compute program. This function will return all the texture samplers that are available, even the ones that have not been specified in the compute resource.
PARAMETERS
path |
hashstring |
The path to the resource |
RETURNS
table |
material.sampler_info[] |
Information about the texture samplers. |
EXAMPLES
Get the texture samplers from a compute program resourcefunction init(self)
local samplers = compute.get_samplers("/my_compute.computec")
end
compute.get_textures(path:hash|string)→table:material.texture_info[]
Returns a table of all the textures from the compute program.
PARAMETERS
path |
hashstring |
The path to the resource |
RETURNS
table |
material.texture_info[] |
Information about the compute textures. |
EXAMPLES
Get the textures from a compute program resourcefunction init(self)
local textures = compute.get_textures("/my_compute.computec")
end
compute.set_constants(path:hash|string, constants:table<string|hash, material.constant_options>)
Sets shader constants in a compute program, if the constants exist.
PARAMETERS
path |
hashstring |
The path to the resource |
constants |
table<string|hash, material.constant_options> |
Constant options keyed by constant name. Partial updates are supported. |
EXAMPLES
Set a shader constant in a compute programfunction update(self)
-- update the 'tint' constant
compute.set_constants("/my_compute.computec", {
tint = { value = vmath.vector4(1, 0, 0, 1) }
})
-- change the type of the 'view_proj' constant to CONSTANT_TYPE_USER_MATRIX4 so the renderer can set our custom data
compute.set_constants("/my_compute.computec", {
view_proj = { value = self.my_view_proj, type = material.CONSTANT_TYPE_USER_MATRIX4 }
})
end
compute.set_samplers(path:hash|string, samplers:table<string|hash, material.sampler_options>)
Sets texture samplers in a compute program, if the samplers exist. Use this function to change the settings of texture samplers.
To set actual textures that should be bound to the samplers, use the compute.set_textures function instead.
PARAMETERS
path |
hashstring |
The path to the resource |
samplers |
table<string|hash, material.sampler_options> |
Sampler options keyed by sampler name. Partial updates are supported. |
EXAMPLES
Configures a sampler in a compute programfunction init(self)
compute.set_samplers("/my_compute.computec", {
texture_sampler = { u_wrap = graphics.TEXTURE_WRAP_REPEAT, v_wrap = graphics.TEXTURE_WRAP_MIRRORED_REPEAT }
})
end
compute.set_textures(path:hash|string, textures:table<string|hash, string|hash>)
Sets textures in a compute program, if the samplers exist.
PARAMETERS
path |
hashstring |
The path to the resource |
textures |
table<string|hash, string|hash> |
A table keyed by sampler name with texture resources as values. |
EXAMPLES
Set a texture in a compute program from a resourcego.property("my_texture", resource.texture())
function init(self)
compute.set_textures("/my_compute.computec", {
my_texture = self.my_texture
})
end