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

model: transparency_strategy enum + factory param #56

Open jfcameron opened 3 years ago

jfcameron commented 3 years ago

add enum class "transparency_strategy" to model. { per_entity, per_triangle }. make_model factory method will have a transparency_strategy param.

in implementation, if the strategy is triangle, then a copy of the vertex_data is kept if the provided vertex_data's primitive type is triangle. During transparency pass, if this mutable vertex_data is present, it will be sorted per tri and uploaded to the vbo before drawing.

additionally, if per_tri is selected, uploaded data should always be streaming. user calls to update_vertex_data should ignore the user usage param and upload streaming instead

default strategy is per_entity, as this is cheaper both in time, storage, and for the most part I think users should be able to arrange scenes such that per entity is good enough. per tri is really only needed when a complex shape can blend with its own geometry