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

fix: npe in depth shader diffuseTexture #7267

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dar-dev
Copy link
Contributor

@dar-dev dar-dev commented Oct 31, 2023

Line: https://github.com/libgdx/libgdx/blob/7fb396541a8c2777c92a5062aaa49afcab0bec1f/gdx/src/com/badlogic/gdx/graphics/g3d/shaders/DefaultShader.java#L237C32-L237C50

This is throwing an npe because the DepthShader canRender() is recycling the shader without the diffuse texture attribute.

Step to replicate:

Copy link
Contributor

@mgsx-dev mgsx-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fixes the issue you have but it introduces a regression : let say you have 2 models without blending, one with a diffuse texture and another one without diffuse texture, 2 shaders will be generated instead of one. And will then produce some unnecessary shader switches when rendering.

@dar-dev
Copy link
Contributor Author

dar-dev commented Jan 17, 2024

It fixes the issue you have but it introduces a regression : let say you have 2 models without blending, one with a diffuse texture and another one without diffuse texture, 2 shaders will be generated instead of one. And will then produce some unnecessary shader switches when rendering.

If we use the same shader an npe is thrown, so.. it never worked (at least in our tests).
How can we avoid this shader switch ? Do we need to introduce an npe check in diffuseTexture local setter ?

--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants