Alpha textures on mesh not showing correctly (No alpha present when rendering)

Started by wiccy, July 03, 2022, 03:36:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wiccy

ok so,  im new here,  and so far,  fantastic API.   However i have a question - i have a mesh im able to load and display using the geexlab api (tweaked the d07 meshes demo for this) and have successfully loaded the textures using the gh_model load_textures function but i notice theres no parameter to specify the pixel format (all the textures use an RGBA pixel format), and it doesnt seem to detect this automatically,  leading to no alpha being present on the textures when displayed.

So my question is this:

Is there an alternative function which supports specifying the pixel format or is there a way to access the materials and their info so i could do it myself?   I used Blender to create these meshes,  and exported using the built-in collada exporter.

JeGX

Thanks for your feedback.

Indeed, the specification of the pixel format in gh_model.load_textures() is missing.
I added in the next GeeXLab, a new function gh_model.load_textures_v2() that allows you to set the pixel format.

gh_model.load_textures() uses the RGBA_U8 pixel format for all textures and you should have the correct alpha value in your shader.

I will add some functions in the next update to improve the rendering of opaque and transparent sub-meshes of a model.
Mabye Something like:
gh_model.render_opaque_meshes(...)

alpha_blending_enable(...)
gh_model.render_transparent_meshes(...)
alpha_blending_disable(...)

If you want to do some tests now, you can loop through a model like this:

num_children = gh_node.get_num_children(model)
for i=0, num_children-1 do
  mesh = gh_node.get_child_by_index(model, i)
  num_materials = gh_object.get_num_materials(mesh)
  for k=0, num_materials-1 do
    matid = gh_object.get_material(mesh, k)
    material_name = gh_node.get_name(matid)
   
   
    bind_gpu_program(...)
   
    num_tex = gh_material.get_num_textures()
    for t=0, num_tex-1 do
      tex = gh_material.get_texture(matid, t)
     
      bind_texture(...)
      render_mesh(...)
     
    end
  end
end 

JeGX

Next GeeXLab will be available with better opaque and transparent material support.