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

DepthFunc per material #4098

Merged
merged 4 commits into from
Mar 29, 2022
Merged

DepthFunc per material #4098

merged 4 commits into from
Mar 29, 2022

Conversation

MrMabulous
Copy link
Contributor

This change adds the material property 'depthFunc' that can be set to
any of the following values in order to control what comparison function
is used for the depth test during rendering:

FUNC_NEVER: don't draw
FUNC_LESS: draw if new depth < depth buffer
FUNC_EQUAL: draw if new depth == depth buffer
FUNC_LESSEQUAL: draw if new depth <= depth buffer
FUNC_GREATER: draw if new depth > depth buffer
FUNC_NOTEQUAL: draw if new depth != depth buffer
FUNC_GREATEREQUAL: draw if new depth >= depth buffer
FUNC_ALWAYS: always draw

previously depthFunc was always set to FUNC_LESSEQUAL, which is thus the
new default value for this property.

Fixes #4093

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

This change adds the material property 'depthFunc' that can be set to
any of the following values in order to control what comparison function
is used for the depth test during rendering:

FUNC_NEVER: don't draw
FUNC_LESS: draw if new depth < depth buffer
FUNC_EQUAL: draw if new depth == depth buffer
FUNC_LESSEQUAL: draw if new depth <= depth buffer
FUNC_GREATER: draw if new depth > depth buffer
FUNC_NOTEQUAL: draw if new depth != depth buffer
FUNC_GREATEREQUAL: draw if new depth >= depth buffer
FUNC_ALWAYS: always draw

previously depthFunc was always set to FUNC_LESSEQUAL, which is thus the
new default value for this property.
This is re-adding the depthWrite fix, since the GL will not update the
depth buffer if depth test is disabled. Instead, it must be enabled with
FUNC_ALWAYS.
@yaustar yaustar requested a review from a team March 9, 2022 14:48
@yaustar yaustar added area: graphics Graphics related issue feature request labels Mar 9, 2022
@Maksims
Copy link
Contributor

Maksims commented Mar 9, 2022

Personally, I would name it something more specific, as by reading it out of context e.g. "func less" - does not speak enough for itself.
DEPTHFUNC_LESS - would work better to give an idea of a constant out of context.

@mvaligursky
Copy link
Contributor

mvaligursky commented Mar 9, 2022

FUNC_LESS ...

I agree with you, but these constant names are existing constants in the engine. The PR only allows them to be set on material, but does not create any additional constant names.

@mvaligursky mvaligursky added the release: next minor Ticket marked for the next minor release label Mar 24, 2022
@mvaligursky mvaligursky merged commit 23c1d3e into playcanvas:main Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature request release: next minor Ticket marked for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose depth compare functionality
4 participants