|
@@ -32,7 +32,7 @@
|
|
|
import WebGL from 'three/addons/capabilities/WebGL.js';
|
|
|
|
|
|
import WebGPURenderer from 'three/addons/renderers/webgpu/WebGPURenderer.js';
|
|
|
- import { tslFn, attribute, varyingProperty, timerLocal, uniform, wgslFn, texture, uv, clamp, float, vec2, vec3, fract, floor, MeshBasicNodeMaterial, positionGeometry, sin } from 'three/nodes';
|
|
|
+ import { tslFn, sampler, attribute, varyingProperty, timerLocal, uniform, wgslFn, texture, uv, clamp, float, vec2, vec3, fract, floor, MeshBasicNodeMaterial, positionGeometry, sin } from 'three/nodes';
|
|
|
|
|
|
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
|
|
|
|
|
@@ -109,12 +109,12 @@
|
|
|
crtHeight
|
|
|
);
|
|
|
// Coordinate for each cell in the pixel map
|
|
|
- var coord = pixel / cellSize;
|
|
|
+ let coord = pixel / cellSize;
|
|
|
// Three color values for each cell (r, g, b)
|
|
|
- var subcoord = coord * vec2f( 3.0, 1.0 );
|
|
|
- var offset = vec2<f32>( 0, fract( floor( coord.x ) * cellOffset ) );
|
|
|
+ let subcoord = coord * vec2f( 3.0, 1.0 );
|
|
|
+ let offset = vec2<f32>( 0, fract( floor( coord.x ) * cellOffset ) );
|
|
|
|
|
|
- var maskCoord = floor( coord + offset ) * cellSize;
|
|
|
+ let maskCoord = floor( coord + offset ) * cellSize;
|
|
|
|
|
|
var samplePoint = maskCoord / vec2<f32>(crtWidth, crtHeight);
|
|
|
samplePoint.x += fract( time * speed / 20 );
|
|
@@ -127,7 +127,7 @@
|
|
|
|
|
|
// Current implementation does not give an even amount of space to each r, g, b unit of a cell
|
|
|
// Fix/hack this by multiplying subCoord.x by cellSize at cellSizes below 6
|
|
|
- var ind = floor( subcoord.x ) % 3;
|
|
|
+ let ind = floor( subcoord.x ) % 3;
|
|
|
|
|
|
var maskColor = vec3<f32>(
|
|
|
f32( ind == 0.0 ),
|
|
@@ -135,7 +135,7 @@
|
|
|
f32( ind == 2.0 )
|
|
|
) * 3.0;
|
|
|
|
|
|
- var cellUV = fract( subcoord + offset ) * 2.0 - 1.0;
|
|
|
+ let cellUV = fract( subcoord + offset ) * 2.0 - 1.0;
|
|
|
var border: vec2<f32> = 1.0 - cellUV * cellUV * borderMask;
|
|
|
|
|
|
maskColor *= vec3f( clamp( border.x, 0.0, 1.0 ) * clamp( border.y, 0.0, 1.0) );
|
|
@@ -180,7 +180,7 @@
|
|
|
wgslShaderMaterial.fragmentNode = wgslFragmentShader( {
|
|
|
vUv: vUv,
|
|
|
tex: texture( planetTexture ),
|
|
|
- texSampler: texture( planetTexture ),
|
|
|
+ texSampler: sampler( planetTexture ),
|
|
|
crtWidth: crtWidthUniform,
|
|
|
crtHeight: crtHeightUniform,
|
|
|
cellOffset: cellOffsetUniform,
|