Skip to content

Commit ab3b421

Browse files
committed
use lang injection
1 parent 5b81e59 commit ab3b421

File tree

6 files changed

+24
-29
lines changed

6 files changed

+24
-29
lines changed

libs/postprocessing/src/lib/effects/lens-flare.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { Color, Mesh, Texture, Uniform, Vector2, Vector3 } from 'three';
1919
import { NgtpEffectComposer } from '../effect-composer';
2020

2121
const LensFlareShader = {
22-
fragmentShader: /* glsl */ `
22+
fragmentShader: /* language=glsl glsl */ `
2323
2424
uniform float iTime;
2525
uniform vec2 lensPosition;

libs/soba/shaders/src/lib/caustics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ export const CausticsMaterial = shaderMaterial(
126126
size: 10,
127127
intensity: 0.5,
128128
},
129-
/* glsl */ `
129+
/* language=glsl glsl */ `
130130
varying vec2 vUv;
131131
void main() {
132132
vUv = uv;
133133
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
134134
}`,
135-
/* glsl */ `
135+
/* language=glsl glsl */ `
136136
uniform mat4 cameraMatrixWorld;
137137
uniform mat4 cameraProjectionMatrixInv;
138138
uniform vec3 lightDir;

libs/soba/shaders/src/lib/grid-material.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const GridMaterial = shaderMaterial(
4646
worldCamProjPosition: new Vector3(),
4747
worldPlanePosition: new Vector3(),
4848
},
49-
/* glsl */ `
49+
/* language=glsl glsl */ `
5050
varying vec3 localPosition;
5151
varying vec4 worldPosition;
5252
@@ -69,7 +69,7 @@ export const GridMaterial = shaderMaterial(
6969
gl_Position = projectionMatrix * viewMatrix * worldPosition;
7070
}
7171
`,
72-
/* glsl */ `
72+
/* language=glsl glsl */ `
7373
varying vec3 localPosition;
7474
varying vec4 worldPosition;
7575

libs/soba/src/materials/custom-shader-material.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PointsMaterial } from 'three';
88
import { makeDecorators, makeStoryObject, number } from '../setup-canvas';
99

1010
const shader = {
11-
vertex: /* glsl */ `
11+
vertex: /* language=glsl glsl */ `
1212
uniform float uTime;
1313
varying float vVisibility;
1414
varying vec3 vViewNormal;
@@ -28,7 +28,7 @@ const shader = {
2828
csm_PointSize += ((1. - visibility) * 0.05);
2929
}
3030
`,
31-
fragment: /* glsl */ `
31+
fragment: /* language=glsl glsl */ `
3232
varying float vVisibility;
3333
varying vec3 vViewNormal;
3434

libs/soba/src/staging/spot-light.stories.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ import { makeDecorators, makeStoryObject } from '../setup-canvas';
3434
<ngts-spot-light [options]="options()">
3535
<ngts-spot-light-shadow
3636
[shader]="shader()"
37-
[options]="{
38-
scale: 4,
39-
distance: 0.4,
40-
width: 2048,
41-
height: 2048,
42-
map: leafTexture(),
43-
}"
37+
[options]="{ scale: 4, distance: 0.4, width: 2048, height: 2048, map: leafTexture() }"
4438
/>
4539
</ngts-spot-light>
4640
`,
@@ -70,23 +64,24 @@ class SpotLightShadowStory {
7064
},
7165
},
7266
);
67+
7368
leafTexture = injectTexture(() => './textures/other/leaves.jpg');
7469
shader = computed(() => {
7570
if (!this.wind()) return undefined;
76-
return /* glsl */ `
77-
varying vec2 vUv;
78-
uniform sampler2D uShadowMap;
79-
uniform float uTime;
80-
void main() {
81-
// material.repeat.set(2.5) - Since repeat is a shader feature not texture
82-
// we need to implement it manually
83-
vec2 uv = mod(vUv, 0.4) * 2.5;
84-
// Fake wind distortion
85-
uv.x += sin(uv.y * 10.0 + uTime * 0.5) * 0.02;
86-
uv.y += sin(uv.x * 10.0 + uTime * 0.5) * 0.02;
87-
vec3 color = texture2D(uShadowMap, uv).xyz;
88-
gl_FragColor = vec4(color, 1.);
89-
}
71+
return /* language=glsl glsl */ `
72+
varying vec2 vUv;
73+
uniform sampler2D uShadowMap;
74+
uniform float uTime;
75+
void main() {
76+
// material.repeat.set(2.5) - Since repeat is a shader feature not texture
77+
// we need to implement it manually
78+
vec2 uv = mod(vUv, 0.4) * 2.5;
79+
// Fake wind distortion
80+
uv.x += sin(uv.y * 10.0 + uTime * 0.5) * 0.02;
81+
uv.y += sin(uv.x * 10.0 + uTime * 0.5) * 0.02;
82+
vec3 color = texture2D(uShadowMap, uv).xyz;
83+
gl_FragColor = vec4(color, 1.);
84+
}
9085
`;
9186
});
9287
}

libs/soba/staging/src/lib/spot-light.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export class NgtsSpotLightShadowShader {
266266
return new FullScreenQuad(
267267
new ShaderMaterial({
268268
uniforms: this.uniforms,
269-
vertexShader: /* glsl */ `
269+
vertexShader: /* language=glsl glsl */ `
270270
varying vec2 vUv;
271271
272272
void main() {

0 commit comments

Comments
 (0)