Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/materials/nodes/Line2NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { positionGeometry } from '../../nodes/accessors/Position.js';
import { mix, smoothstep } from '../../nodes/math/MathNode.js';
import { Fn, float, vec2, vec3, vec4, If } from '../../nodes/tsl/TSLBase.js';
import { uv } from '../../nodes/accessors/UV.js';
import { viewport } from '../../nodes/display/ScreenNode.js';
import { screenDPR, viewport } from '../../nodes/display/ScreenNode.js';
import { viewportSharedTexture } from '../../nodes/display/ViewportSharedTextureNode.js';

import { LineDashedMaterial } from '../LineDashedMaterial.js';
Expand Down Expand Up @@ -300,7 +300,7 @@ class Line2NodeMaterial extends NodeMaterial {
offset.assign( offset.mul( materialLineWidth ) );

// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
offset.assign( offset.div( viewport.w ) );
offset.assign( offset.div( viewport.w.div( screenDPR ) ) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the library, viewport is sometimes defined in physical pixels, and other times in logical pixels. It would be a lot better if there was consistency in this regard -- or improved nomenclature. Perhaps @sunag and @Mugen87 could come to an agreement on this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree with what @sunag has defined in #29347.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This bug occurred because the definitions are not consistent.

renderer.setViewport() is in logical pixel units. Can you improve the nomenclature?

Copy link
Collaborator Author

@Mugen87 Mugen87 Nov 10, 2025

Choose a reason for hiding this comment

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

I think there is a difference with what is defined via the renderer API and what TSL objects represent in the shader. That has been mentioned here #29347 (comment). I don't think you can come up with a solution that satisfies every use case. Keeping the TSL objects in physical pixel units seems correct to me. And I would leave the renderer API as it is, especially to avoid any kind of breakage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Keeping the TSL objects in physical pixel units seems correct to me.

Yes.

And I would leave the renderer API as it is,

Yes.

So the only possible changes are in the margins: revist the docs and inline docs and ensure the units are clearly stated.

Also the internal nomenclature could be reviewed.

_viewport // logical (css) pixel units

_currentViewport // physical pixel units

state.viewport // physical pixel units


// select end
clip.assign( positionGeometry.y.lessThan( 0.5 ).select( clipStart, clipEnd ) );
Expand Down