jfcameron / gdk-graphics

3D Rendering using OpenGLES 2.0/WebGL1.0. Platforms: Linux, Windows, Mac, x86 64bit, arm64, wasm
MIT License
1 stars 1 forks source link

Transparency: support per-entity sorted transparency #30

Closed jfcameron closed 3 years ago

jfcameron commented 3 years ago

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.

jfcameron commented 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.

jfcameron commented 3 years ago

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

jfcameron commented 3 years ago

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

jfcameron commented 3 years ago

Per entity translucency has been implemented as of e34c970e6d863d07065281a889e1c933a912566f