Skip to content

Commit

Permalink
Merge pull request #14460 from RolandCsibrei/master
Browse files Browse the repository at this point in the history
GRL - instancing support
  • Loading branch information
sebavan committed Oct 25, 2023
2 parents 841412b + f1e3f51 commit da36100
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
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 @@ -71,7 +71,9 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial implements IGrease
{
attributes,
uniforms: [
"worldViewProjection",
"world",
"viewProjection",
"view",
"projection",
"grlColorsWidth",
"grlUseColors",
Expand Down
12 changes: 10 additions & 2 deletions packages/dev/core/src/Shaders/greasedLine.vertex.fx
@@ -1,10 +1,11 @@
precision highp float;
#include<instancesDeclaration>

attribute float grl_widths;
attribute vec3 grl_offsets;
attribute float grl_colorPointers;
attribute vec3 position;
uniform mat4 worldViewProjection;
uniform mat4 viewProjection;
uniform mat4 projection;
varying float grlCounters;
varying float grlColorPointer;
Expand All @@ -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,12 @@ void main() {
vec3 grlNext = grl_nextAndCounters.xyz;
grlCounters = grl_nextAndCounters.w;

mat4 grlMatrix = worldViewProjection;
#ifdef INSTANCES
mat4 grlMatrix = viewProjection * finalWorld ;
#else
mat4 grlMatrix = viewProjection * world ;
#endif

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

0 comments on commit da36100

Please sign in to comment.