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

WebGLUniformsGroups: Fix programs sharing multiple ubo and support array uniforms #25084

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

RenaudRohlinger
Copy link
Collaborator

This PR fixes the fact that the UBO cache system was previously based per block and not per program which was breaking as soon as more than one UBO was used (wrong index). I updated the example by adding the lights UBO on the second material, to reproduce the issue just set back the old cache system in WebGLState.js:
uboBindings.get( program ) => uboBindings.get( uniformsGroup ) and you will see that the programs fail based randomly.

It seems that with multiple UBOs attached this change will trigger uniformBlockBinding per frame, I wonder about the performance implication of this call.

The PR also introduces the support for uniform array structure. For example:

struct PointLight {
	vec4 position;
	vec4 color;
};

layout(std140) uniform LightingData {
	PointLight pointLight[40];
};

Also, it might be interesting to add a note that it is necessary to only use vec4 with UBO and std140.

Most GPUs (Apple for example) do not render a correct result if a non-vec4 is being used when using a uniform array and std140.

@RenaudRohlinger RenaudRohlinger changed the title fix programs sharing multiple ubo and support array uniforms WebGLUniformsGroups: Fix programs sharing multiple ubo and support array uniforms Dec 6, 2022
@Mugen87 Mugen87 added this to the r148 milestone Dec 6, 2022
@Mugen87 Mugen87 merged commit 3e97fb1 into mrdoob:dev Dec 8, 2022
@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 8, 2022

Merging for further testing.

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.

2 participants