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

GRL - instancing support #14460

Merged
merged 8 commits into from Oct 25, 2023
Expand Up @@ -372,7 +372,7 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase implements IGr
grlCounters = grl_nextAndCounters.w;


mat4 grlMatrix = viewProjection * world;
mat4 grlMatrix = viewProjection * finalWorld;
vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );
vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );
vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );
Expand Down
Expand Up @@ -72,6 +72,10 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial implements IGrease
attributes,
uniforms: [
"worldViewProjection",
"world",
"worldView",
"viewProjection",
"view",
"projection",
"grlColorsWidth",
"grlUseColors",
Expand Down
6 changes: 5 additions & 1 deletion packages/dev/core/src/Shaders/greasedLine.vertex.fx
@@ -1,4 +1,5 @@
precision highp float;
#include<instancesDeclaration>

attribute float grl_widths;
attribute vec3 grl_offsets;
Expand Down Expand Up @@ -28,6 +29,8 @@ varying float grlColorPointer;
#endif

void main() {
#include<instancesVertex>

grlColorPointer = grl_colorPointers;

#ifdef GREASED_LINE_CAMERA_FACING
Expand All @@ -39,7 +42,8 @@ void main() {
vec3 grlNext = grl_nextAndCounters.xyz;
grlCounters = grl_nextAndCounters.w;

mat4 grlMatrix = worldViewProjection;
mat4 grlMatrix = worldViewProjection * finalWorld;
Popov72 marked this conversation as resolved.
Show resolved Hide resolved

vec3 grlPositionOffset = grl_offsets;
vec4 grlFinalPosition = grlMatrix * vec4( position + grlPositionOffset , 1.0 );
vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );
Expand Down