Skip to content

Renderers refactor #1850

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

Draft
wants to merge 799 commits into
base: master
Choose a base branch
from
Draft

Renderers refactor #1850

wants to merge 799 commits into from

Conversation

MichalDybizbanskiCreoox
Copy link
Collaborator

No description provided.

Copy link
Member

@xeolabs xeolabs left a comment

Choose a reason for hiding this comment

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

Looks good to me - refactoring to use common factories for DRY makes sense.

@@ -70,6 +74,42 @@ <h3>Components used</h3>
canvasId: "myCanvas"
});

// new ReflectionMap(viewer.scene, {
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this commented out bit

@@ -1031,6 +1031,21 @@ class XKTLoaderPlugin extends Plugin {
}
};

window._timestamp = (function() {
Copy link
Member

Choose a reason for hiding this comment

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

Looks like window._timeStamp is no longer needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, it's one of the things left temporarily for the draft, as it's easier to debug with.
It'll be gone in the final PR.

? lightSetup.directionalLights.map(
light => `(max(dot(${attributes.normal.view}, ${light.getDirection(geometry.viewMatrix, attributes.position.view)}), 0.0) * ${light.getColor()})`)
: [ ]);
// TODO: A blending mode for emphasis materials, to select add/multiply/mix
Copy link
Member

Choose a reason for hiding this comment

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

I agree - dynamic blending mode for emphasis materials

@@ -285,11 +286,20 @@ <h3>Components Used</h3>

const map = {};

const RNG = function(seed) {
Copy link
Member

Choose a reason for hiding this comment

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

This function is introduced in this PR in many examples to replace Math.random(), but I don't think it makes sense here, as examples should be simple. But if it's really needed for some reason, then it would be good to at least refer to the source. I'm not sure where the original source comes from, if this is the one: https://stackoverflow.com/a/72732727, then we should refer to it, as it is under CC BY-SA 4.0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function has been introduced temporarily for reproducibility during debugging.
There's a few commits there in the branch (especially at its beginning) that were meant only for development, and will be gone in the final PR.

Copy link
Member

@paireks paireks left a comment

Choose a reason for hiding this comment

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

Just a comment, that it is great case to use automatic tests Ania and Mateusz prepared for us. Not only to make sure it works after refactor, but also to check their work and see if these tests makes sense. I'd ask Mateusz once he's back to try to run them before merge.

@MichalDybizbanskiCreoox
Copy link
Collaborator Author

@xeolabs I've pushed the latest commits added on top of the branch that we discussed last time.
Besides internal refactorings they migrate SAO renderers and Occlusion Tester to the createProgramVariablesState abstraction.
96c7c94...7e980ed

@MichalDybizbanskiCreoox
Copy link
Collaborator Author

MichalDybizbanskiCreoox commented Jun 23, 2025

The following relates to the current HEAD at 5d128a5.

This PR refactors renderers architecture, but in general doesn't change rendered outputs.
There is one exception to that, namely the
9d0fa08 "FIX TrianglesColorTextureRenderer's uColorMap sRGBToLinear decoding (to make the same as e.g. TrianglesPBRRenderer)"
commit changes how texels are processed in the shaders, which results in changes in the outputs.
The tests affected by this change are all 8 from the tests/snapshots-loading-textures.spec.js set.

By the end of the PR three commits are added that reintroduce those previously reverted changes.
At the last commit of the PR (5d128a5) all tests render the same outputs as the ones rendered with the master branch, except for the 8 snapshots-loading-textures tests mentioned above.

@MichalDybizbanskiCreoox MichalDybizbanskiCreoox force-pushed the renderers-refactor branch 3 times, most recently from 2cad949 to e1c0f92 Compare July 8, 2025 09:56
@MichalDybizbanskiCreoox MichalDybizbanskiCreoox force-pushed the renderers-refactor branch 4 times, most recently from f5c04fe to 5caed07 Compare August 4, 2025 16:31
…reverted at the beginning of this branch

Note that the "cleaner edges" had originally only been implemented for VBO's and DTX's Color and FlatColor programs.
The support probably needs to be extended to some of the other programs, as well as to the Mesh hierarchy.
…es layers)" #1884 - reverted at the beginning of this branch
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.

3 participants