Skip to content

Multiple cgltf Nodes Import and Meshes, Skysphere#21

Open
TimeTravelerFromNow wants to merge 4 commits into
MrFrenik:mainfrom
TimeTravelerFromNow:main
Open

Multiple cgltf Nodes Import and Meshes, Skysphere#21
TimeTravelerFromNow wants to merge 4 commits into
MrFrenik:mainfrom
TimeTravelerFromNow:main

Conversation

@TimeTravelerFromNow
Copy link
Copy Markdown

@TimeTravelerFromNow TimeTravelerFromNow commented Jul 24, 2024

Pull Request to gunslinger framework for this example

Multiple cgltf Nodes with base_color_texture Import, Skysphere matrix function

Introduces structs for mirroring the cgltf file format during an import into gs. The slot arrays in gs_gfxt_scene_t will be used to render each nodes' singular mesh.

vlc-record-2024-07-23-22h25m20s-2024-07-23.22-24-26.mp4-.mp4

Todos

  • I'd like the pbr_basic.sf pipeline to be standard to gs. (not sure the best way, so I'm just loading from the ./assets/pipelines, but in the gs/util/gs_gfxt.h this is hardcoded with gs_gfxt_scene_new()). Not so great
  • gs_gfxt_pbr_free(gs_gfxt_pbr_t* pbr_info) to free unused texture data.
  • Matrix transforms for child- parent nodes.
  • More pbr textures and flag handling as in the gltf spec
  • the black mesh actually has a vec4 base color that isn't rendered yet.
  • Expand upon the pbr_basic.sf pipeline

Ambitions

Some sort of node management. Not sure how to go about this, but I intend to draw inspiration from this article:
Evolve Your Hierarchy: Mick West - Gamedev.net. It discusses problems with node graphs and suggests a component manager system instead. I think this could inspire a unique solution in gunslinger.

Tripping points

  • Tried to use renderables initially when writing importing code but I was flailing trying to understand how to use gs_gfxt_raw_data_func_desc_ts. (Was trying to point meshes to materials with the handles and causes seg faults left and right). Settled on using uint32_t handles to the gs_slot_array(gs_gfxt_material_t).
  • Had no clue about stack vs heap before attempting this so I was seg fault finding for a week, I've learned a bit more but please look through the code and give me pointers.
  • Some things I came across; initially I tried gs_slot_map. Not sure if I was structuring data wrong, but I was getting issues with nearby memory getting overwritten. So for the new structs I used gs_dyn_array for textures and gs_slot_array for custom structs and the problems went away.

@Samdal
Copy link
Copy Markdown

Samdal commented Jul 24, 2024

Cool project!

If you aren't you definitely should be using a sanitizer. It catches 95% of the dumb memory mistakes one might accidentally do.
With gcc/clang adding it is just -fsanitize=address.

Otherwise it's mostly about using a debugger to track down when/where it happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants