I'm trying to test my glTF library (https://github.com/FuzzyWuzzie/haxe-gltf) for loading glTF models. Basically, right now, I just want to load the mesh data and display it. And what I have right now kind-of works: https://fuzzywuzzie.github.io/gltf-sample-kha/ (source code is at: https://github.com/FuzzyWuzzie/gltf-sample-kha).
If you can't run the demo, here's a screenshot:
As far as I can tell, the glTF data is being loaded correctly (I've manually checked things on smaller triangle and quad models), but it clearly isn't rendering correctly; and it seems like a depth issue (the colours are coming from the mesh normal).
I think I'm doing something wrong in Kha, but I can't seem to figure out what exactly, other than that it seems like a depth issue. The pipeline looks like it should be writing to the depth buffer and comparing against it:
pipeline = new PipelineState();
pipeline.inputLayout = [structure];
pipeline.fragmentShader = Shaders.simple_frag;
pipeline.vertexShader = Shaders.simple_vert;
pipeline.cullMode = CullMode.Clockwise;
pipeline.depthMode = CompareMode.GreaterEqual;
pipeline.depthWrite = true;
pipeline.compile();
And my render function clears the depth buffer:
var g = frame.g4;
g.begin();
g.clear(Color.fromFloats(0.33, 0.33, 0.33), 0);
g.setVertexBuffer(vertexBuffer);
g.setIndexBuffer(indexBuffer);
g.setPipeline(pipeline);
g.setMatrix(mvpID, mvp);
g.setMatrix(mID, model);
g.drawIndexedVertices();
g.end();
But it seems like perhaps the depth buffer isn't being used? Or is there something else wrong with the model data? I could really use another pair of eyes on this if you're available.
Thanks so much!