< GeeXLab Reference Guide />

> Back to Reference Guide Index


gh_material library

Description

gh_material is the module that manages materials: creation, destruction, parameters setting. The fundamental goal of material is to define the final appearence of an object surface. A material is made up of one or several textures and a GPU program.


Number of functions: 12

  1. gh_material.add_texture ()
  2. gh_material.bind ()
  3. gh_material.create ()
  4. gh_material.get_gpu_program ()
  5. gh_material.set_gpu_program ()
  6. gh_material.get_num_textures ()
  7. gh_material.get_texture ()
  8. gh_material.remove_texture ()
  9. gh_material.vk_descriptorset_add_all_textures ()
  10. gh_material.vk_descriptorset_add_texture ()
  11. gh_material.vk_descriptorset_copy ()
  12. gh_material.vk_descriptorset_update_all_textures ()



add_texture

Description

Adds a texture to the material.


Syntax

gh_material.add_texture(
 mat_id,
 tex_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_material.add_texture(mat_id, tex_id)
			


bind

Description

Bind the material to the renderer: textures and GPU programs are bound.


Syntax

gh_material.bind(
 mat_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_material.bind(mat_id)
			


create

Description

Creates a material.


Syntax

mat_id = gh_material.create()

Languages


Parameters

This function has no input parameter(s).


Return Values


Code sample


mat_id = gh_material.create()
			


get_gpu_program

Description

Gets the GPU program of the material.


Syntax

gpuprog_id = gh_material.get_gpu_program(
 mat_id
)

Languages


Parameters


Return Values


Code sample


gpuprog_id = gh_material.get_gpu_program(mat_id)
			


set_gpu_program

Description

Sets the GPU program of the material.


Syntax

gh_material.set_gpu_program(
 mat_id,
 gpuprog_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_material.set_gpu_program(mat_id, gpuprog_id)
			


get_num_textures

Description

Gets the number of textures of the material.


Syntax

n = gh_material.get_num_textures(
 mat_id
)

Languages


Parameters


Return Values


Code sample


n = gh_material.get_num_textures(mat_id)
			


get_texture

Description

Gets a particular texture of the material.


Syntax

tid = gh_material.get_texture(
 mat_id,
 texture_index
)

Languages


Parameters


Return Values


Code sample


n = gh_material.get_num_textures(mat_id)
for i=0, n-1 do
	tid = gh_material.get_texture(mat_id, i)
	DoSomething(tid)
end
			


remove_texture

Description

Removes a texture from the material.


Syntax

gh_material.remove_texture(
 mat_id,
 tex_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_material.remove_texture(mat_id, tex_id)
			


vk_descriptorset_add_all_textures

Description

Vulkan only - Adds all textures of a material to a vulkan descriptor set.


Syntax

gh_material.vk_descriptorset_add_all_textures(
 mat_id,
 descriptorset_id,
 binding_point_start,
 shader_stages,
 sampler_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


binding_point_start = 1			
shader_stages = SHADER_STAGE_FRAGMENT
gh_material.vk_descriptorset_add_all_textures(mat_id, descriptorset_id, binding_point_start, shader_stages, sampler)
			


vk_descriptorset_add_texture

Description

Vulkan only - Adds a texture of a material to a vulkan descriptor set.


Syntax

resource_index = gh_material.vk_descriptorset_add_texture(
 mat_id,
 descriptorset_id,
 texture_index,
 binding_point,
 shader_stages,
 sampler_id
)

Languages


Parameters


Return Values


Code sample


binding_point = 1			
texture_index = 0
shader_stages = SHADER_STAGE_FRAGMENT
resource_index = gh_material.vk_descriptorset_add_texture(mat_id, descriptorset_id, texture_index, binding_point, shader_stages, sampler)

binding_point = 2			
texture_index = 1
shader_stages = SHADER_STAGE_FRAGMENT
resource_index = gh_material.vk_descriptorset_add_texture(mat_id, descriptorset_id, texture_index, binding_point, shader_stages, sampler)
			


vk_descriptorset_copy

Description

Vulkan only - copies the information of a vulkan descriptor set from a source material to a destination material. This function does not update the Vulkan descriptor set referenced by the source material. This function is useful if you have several materials with same texture layout (same number and type of textures) that have to share the same descriptor set.


Syntax

gh_material.vk_descriptorset_copy(
 material_src_id,
 material_dst_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_material.vk_descriptorset_copy(material_src_id, material_dst_id)
			


vk_descriptorset_update_all_textures

Description

Vulkan only - updates a vulkan descriptor set with the textures of a material. This function is automatically called when a model is rendered.


Syntax

gh_material.vk_descriptorset_update_all_textures(
 material_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_material.vk_descriptorset_update_all_textures(material_id)
			






GeeXLab Rootard Guide | Downloads | Contact | Newsletter