Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to disable depth mask in forward pass #248

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pyrender/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def __init__(self,
self.wireframe = wireframe

self._tex_flags = None

self.depthMask = True

@property
def name(self):
Expand Down Expand Up @@ -249,6 +251,16 @@ def textures(self):
material.
"""
return self._compute_textures()

@property
def depthMask(self):
return self._depthMask

@depthMask.setter
def depthMask(self, value):
if not isinstance(value, bool):
raise TypeError('depthMask must be bool')
self._depthMask = value

def _compute_transparency(self):
return False
Expand Down
9 changes: 9 additions & 0 deletions pyrender/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,12 @@ def _bind_and_draw_primitive(self, primitive, pose, program, flags):
if primitive.mode == GLTF.POINTS:
glEnable(GL_PROGRAM_POINT_SIZE)
glPointSize(self.point_size)

# Disable depth mask if specified in material
if material.depthMask == False:
glDepthMask(GL_FALSE)
else:
glDepthMask(GL_TRUE)

# Render mesh
n_instances = 1
Expand All @@ -617,6 +623,9 @@ def _bind_and_draw_primitive(self, primitive, pose, program, flags):

# Unbind mesh buffers
primitive._unbind()

# Depth mask is on by default in forward pass
glDepthMask(GL_TRUE)

def _bind_lighting(self, scene, program, node, flags):
"""Bind all lighting uniform values for a scene.
Expand Down