@@ -2023,7 +2023,7 @@ std::ostream& osc::operator<<(std::ostream& o, const RenderTextureParams& params
20232023 " RenderTextureParams(width = " << params.pixel_dimensions .x
20242024 << " , height = " << params.pixel_dimensions .y
20252025 << " , device_pixel_ratio = " << params.device_pixel_ratio
2026- << " , antialiasing_level = " << params.anti_aliasing_level
2026+ << " , anti_aliasing_level = " << params.anti_aliasing_level
20272027 << " , color_format = " << params.color_format
20282028 << " , depth_stencil_format = " << params.depth_stencil_format
20292029 << " )" ;
@@ -3428,6 +3428,9 @@ class osc::Material::Impl final {
34283428 DepthFunction depth_function () const { return depth_function_; }
34293429 void set_depth_function (DepthFunction depth_function) { depth_function_ = depth_function; }
34303430
3431+ bool writes_to_depth_buffer () const { return writes_to_depth_buffer_; }
3432+ void set_writes_to_depth_buffer (bool value) { writes_to_depth_buffer_ = value; }
3433+
34313434 bool is_wireframe () const { return is_wireframe_mode_; }
34323435 void set_wireframe (bool value) { is_wireframe_mode_ = value; }
34333436
@@ -3446,6 +3449,7 @@ class osc::Material::Impl final {
34463449 BlendingEquation blending_equation_ = BlendingEquation::Default;
34473450 bool is_transparent_ = false ;
34483451 bool is_depth_tested_ = true ;
3452+ bool writes_to_depth_buffer_ = true ;
34493453 bool is_wireframe_mode_ = false ;
34503454};
34513455
@@ -3518,6 +3522,16 @@ void osc::Material::set_depth_function(DepthFunction depth_function)
35183522 impl_.upd ()->set_depth_function (depth_function);
35193523}
35203524
3525+ bool osc::Material::writes_to_depth_buffer () const
3526+ {
3527+ return impl_->writes_to_depth_buffer ();
3528+ }
3529+
3530+ void osc::Material::set_writes_to_depth_buffer (bool value)
3531+ {
3532+ impl_.upd ()->set_writes_to_depth_buffer (value);
3533+ }
3534+
35213535bool osc::Material::is_wireframe () const
35223536{
35233537 return impl_->is_wireframe ();
@@ -7346,6 +7360,10 @@ void osc::GraphicsBackend::handle_batch_with_same_material(
73467360 glDepthFunc (to_opengl_depth_function_enum (material_impl.depth_function ()));
73477361 }
73487362
7363+ if (not material_impl.writes_to_depth_buffer ()) {
7364+ glDepthMask (GL_FALSE);
7365+ }
7366+
73497367 if (material_impl.cull_mode () != CullMode::Off) {
73507368 glEnable (GL_CULL_FACE);
73517369 glCullFace (to_opengl_cull_face_enum (material_impl.cull_mode ()));
@@ -7403,6 +7421,10 @@ void osc::GraphicsBackend::handle_batch_with_same_material(
74037421 glDisable (GL_CULL_FACE);
74047422 }
74057423
7424+ if (not material_impl.writes_to_depth_buffer ()) {
7425+ glDepthMask (GL_TRUE); // Khronos: "Initially, depth buffer writing is enabled"
7426+ }
7427+
74067428 if (material_impl.depth_function () != DepthFunction::Default) {
74077429 glDepthFunc (to_opengl_depth_function_enum (DepthFunction::Default));
74087430 }
0 commit comments