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

WebGLMaterials helper #19304

Merged
merged 10 commits into from
May 8, 2020
Merged

WebGLMaterials helper #19304

merged 10 commits into from
May 8, 2020

Conversation

taphos
Copy link

@taphos taphos commented May 5, 2020

Introduced WebGLMaterials helper
made all WebgLRenderer helpers customizable via WebGLRendererParameters

@taphos
Copy link
Author

taphos commented May 5, 2020

#19292

@Mugen87
Copy link
Collaborator

Mugen87 commented May 6, 2020

I've tested the PR on my local computer and it seems to work fine.

@mrdoob I have one (minor) concern about this PR: WebGLMaterials does not encapsulates the entire logic for updating uniforms. It is now spread across WebGLMaterials and WebGLRenderer which could make the code harder to follow. The renderer still has to evaluate material parameters in setProgram() to ensure correct uniforms in the shader. So WebGLMaterials is a first step but the change feels a bit "incomplete".

@taphos
Copy link
Author

taphos commented May 6, 2020

change feels a bit "incomplete".

This is my first PR, just to understand how you guys work. I will be happy to help making WebGLRenderer less monolithic, messy and more flexible. If you allow me to.

@mrdoob
Copy link
Owner

mrdoob commented May 8, 2020

@mrdoob I have one (minor) concern about this PR: WebGLMaterials does not encapsulates the entire logic for updating uniforms. It is now spread across WebGLMaterials and WebGLRenderer which could make the code harder to follow. The renderer still has to evaluate material parameters in setProgram() to ensure correct uniforms in the shader. So WebGLMaterials is a first step but the change feels a bit "incomplete".

Thanks. Yes, I think this is definitely one step in the right direction. I think more refactoring will become clearer after this.

Comment on lines -1953 to -1958
if ( material.isShaderMaterial ) {

material.uniformsNeedUpdate = false; // #15581

}

Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, you changed the order of this code. Before the PR it executed after WebGLUniforms.upload() and now it's executing before.

I'll merge the PR but I'll put this code back just in case. Step by step...

Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAICS, that should not have any side effects. It's just important that this bit comes before this section:

if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {

    WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
    material.uniformsNeedUpdate = false;

}

Otherwise WebGLUniforms.upload() is called twice for ShaderMaterials when uniformsNeedUpdate is set to true.

Copy link
Author

Choose a reason for hiding this comment

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

ok. This makes me wonder, how much you guys trust unit and e2e tests?
And how safe is more radical refactoring?

Copy link
Collaborator

@Mugen87 Mugen87 May 8, 2020

Choose a reason for hiding this comment

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

This makes me wonder, how much you guys trust unit and e2e tests?

Right now, the test coverage is not sufficient so broad refactoring can only be done with a lot of manual testing.

Copy link
Owner

@mrdoob mrdoob May 8, 2020

Choose a reason for hiding this comment

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

ok. This makes me wonder, how much you guys trust unit and e2e tests?

Unit tests and e2e are nice to have but they wouldn't catch uploading uniforms twice.

The codebase is still fairly small just so we can still keep it in our heads (more or less). I would hate if we get to a point where no one understands it and we just rely on tests.

And how safe is more radical refactoring?

Generally not a fan of radical refactorings. Incremental refactoring are more manageable.

Copy link
Owner

Choose a reason for hiding this comment

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

Okay, moved the code back: b063139

@mrdoob mrdoob added this to the r117 milestone May 8, 2020
@mrdoob mrdoob merged commit abc1cb8 into mrdoob:dev May 8, 2020
@mrdoob
Copy link
Owner

mrdoob commented May 8, 2020

Thanks!

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.

5 participants