Closed jfcameron closed 3 years ago
per triangle sorting is the correct solution.. but I think per entity is good enough for most of what I want to do (sprites, low poly). The strategy should be selectable, this leaves room in the future to do the proper triangle sort.
For triangles, I guess models would have to hold on to the vertex data in RAM, not just upload and forget. then it would have to reupload vertex data that has been sorted on a per triangle basis with respect to distance from the camera. that sounds very time complicated
adding blend mode and cull mode params to the mateiral factor method seems reasonable. material uniforms will vary a lot but blend and cull modes shouldnt really change. having blending set for the entire lifetime on a material also means its impossible for a material to have to swap between blended and opaque collections, which saves some required complexity in webgl1es2_scene
Per entity translucency has been implemented as of e34c970e6d863d07065281a889e1c933a912566f
currently the opengl implementation of context separates models by draw mode (fan, etc.), geometry cull, shader program, uniform value. all this memoization is done to minimize changes to the opengl global state when asked to render any given model. supporting blending will add another nested layer to this. think about this. maybe a "pipeline" abstraction should be introduced to the renderer.