How to use the RawShaderMaterial function from three
Find comprehensive JavaScript three.RawShaderMaterial code examples handpicked from public code repositorys.
18 19 20 21 22 23 24 25 26 27
createObj() { // Define Geometry const geometry = new THREE.PlaneGeometry(2, 2); // Define Material const material = new THREE.RawShaderMaterial({ uniforms: this.uniforms, vertexShader: require('./glsl/postEffect.vs').default, fragmentShader: require('./glsl/postEffectBright.fs').default, });
259
3
0
GitHub: edankwan/hyper-mix
52 53 54 55 56 57 58 59 60 61
_scene = new THREE.Scene(); _camera = new THREE.Camera(); _camera.position.z = 1; _copyShader = new THREE.RawShaderMaterial({ uniforms: { resolution: { type: 'v2', value: new THREE.Vector2( TEXTURE_WIDTH, TEXTURE_HEIGHT ) }, texture: { type: 't', value: undef } },
34
217
8
+ 27 other calls in file
GitHub: edankwan/hyper-mix
31 32 33 34 35 36 37 38 39 40
}, fragmentShader: glslify('./dof.frag') }); _depth1Buffer = new Float32Array(4); _depth1Material = new THREE.RawShaderMaterial({ uniforms: { u_distance: { type: 't', value: undef }, u_mouse: { type: 'v2', value: settings.mouse } },
34
216
8
43 44 45 46 47 48 49 50 51 52
_scene.add( _mesh ); var rawShaderPrefix = 'precision ' + renderer.capabilities.precision + ' float;\n'; vs = exports.vs = rawShaderPrefix + shaderParse(glslify('../glsl/quad.vert')); fxaa = exports.fxaa = new THREE.RawShaderMaterial({ uniforms: { uResolution: { type: 'v2', value: new THREE.Vector2( 1, 1 ) }, uDiffuse: { type: 't', value: undef } },
34
216
8
+ 7 other calls in file
103 104 105 106 107 108 109 110 111 112
// https://github.com/Jam3/three-bmfont-text/pull/24 fragmentShader: shaderOptions.fragmentShader.replace('vec3 sample = 1.0 -', 'vec3 sample =') } ); const material = new THREE.RawShaderMaterial(shaderOptions); const geometry = createTextGeometry({font: json, width: 300, align: 'center'}); geometry.update(sampleText); const mesh = new THREE.Mesh(geometry, material);
15
120
9
105 106 107 108 109 110 111 112 113 114
_target3 = _createTarget(simWidth, simWidth); var _currUpdateTarget = 3; var _simulationMaterial = new THREE.RawShaderMaterial( { uniforms: { "tPrevPos": { type: "t", value: null }, "tCurrPos": { type: "t", value: null }, "tInitPos": { type: "t", value: _initPosTexture },
5
23
3
+ 9 other calls in file
41 42 43 44 45 46 47 48 49 50
blending: THREE.NoBlending, vertexShader: vertexShader, fragmentShader: precisionPrefix + glslify('../glsl/quadColor.frag') }) copyMaterial = new THREE.RawShaderMaterial({ uniforms: { u_texture: { type: 't', value: undefined } }, depthTest: false,
18
1
3
+ 15 other calls in file
GitHub: i10416/sketch-threejs
26 27 28 29 30 31 32 33 34 35
} geometry.setAttribute('height', height); geometry.setAttribute('offsetX', offsetX); return new THREE.InstancedMesh( geometry, new THREE.RawShaderMaterial({ uniforms: this.uniforms, vertexShader: require('./glsl/hill.vs').default, fragmentShader: require('./glsl/hill.fs').default, }),
260
0
0
24 25 26 27 28 29 30 31 32 33
depthWrite: false, transparent: true, blending: THREE.AdditiveBlending, flatShading: true, }); const materialWire = new THREE.RawShaderMaterial({ uniforms: this.uniforms, vertexShader: require('./glsl/node.vs').default, fragmentShader: require('./glsl/nodeWire.fs').default, depthWrite: false,
260
0
2
+ 2 other calls in file
383 384 385 386 387 388 389 390 391 392
this.useDash = ( this.dashArray !== [] ) ? 1 : 0; this.visibility = check( parameters.visibility, 1 ); this.alphaTest = check( parameters.alphaTest, 0 ); this.repeat = check( parameters.repeat, new THREE.Vector2( 1, 1 ) ); var material = new THREE.RawShaderMaterial( { uniforms:{ lineWidth: { type: 'f', value: this.lineWidth }, map: { type: 't', value: this.map }, useMap: { type: 'f', value: this.useMap },
398
9
1
+ 3 other calls in file
97 98 99 100 101 102 103 104 105 106
fragmentShader: require ('./shaders/slab-frag.glsl'), side: THREE.DoubleSide } ); // material for instanced objects var pathMat = new THREE.RawShaderMaterial({ uniforms: { image1: { // Check the Three.JS documentation for the different allowed types and values type: "t",
14
0
2
+ 3 other calls in file
129 130 131 132 133 134 135 136 137 138
}); this.mesh = new THREE.Mesh( this.bufferGeometry, this.bufferMaterial ); this.mesh.updateMatrix(); this.updateSpringMaterial = new THREE.RawShaderMaterial( { 'uniforms': { 'uBasePositions' : { type: 't', value: this.geometryRT }, 'uPrevPositions' : { type: 't', value: this.geometryRT }, 'uPrevPositionsGeom' : { type: 't', value: this.geometryRT },
0
1
6
+ 5 other calls in file
GitHub: mrdavidlaing/ipyvolume
49 50 51 52 53 54 55 56 57 58
arrow: this.geo_arrow, sphere: this.geo_sphere, cat: this.geo_cat, } this.material = new THREE.RawShaderMaterial({ uniforms: { xlim : { type: "2f", value: [0., 1.] }, ylim : { type: "2f", value: [0., 1.] }, zlim : { type: "2f", value: [0., 1.] },
236
0
2
+ 3 other calls in file
79 80 81 82 83 84 85 86 87 88
fragmentShader: glslify('./motionBlur.frag') }); _linesPositions = []; _linesGeometry = new THREE.BufferGeometry(); _linesMaterial = new THREE.RawShaderMaterial({ uniforms: { u_texture: { type: 't', value: undef }, u_motionTexture: { type: 't', value: _motionRenderTarget }, u_resolution: { type: 'v2', value: effectComposer.resolution },
159
0
1
+ 3 other calls in file
13 14 15 16 17 18 19 20 21 22
// textures const tempMap = new three_1.FramebufferTexture(16, 16, three_1.RGBAFormat); const occlusionMap = new three_1.FramebufferTexture(16, 16, three_1.RGBAFormat); // material const geometry = Lensflare.Geometry; const material1a = new three_1.RawShaderMaterial({ uniforms: { 'scale': { value: null }, 'screenPosition': { value: null } },
1
3
0
+ 2 other calls in file
637 638 639 640 641 642 643 644 645
uniforms[uniformId].semantic = originalUniform.semantic; uniforms[uniformId].node = originalUniform.node; } this.params.uniforms = uniforms; return new THREE.RawShaderMaterial(this.params); }; /* GLTF PARSER */
0
1
0
+ 9 other calls in file
GitHub: PSkinnerTech/obscurus
27 28 29 30 31 32 33 34 35 36
u_amount: { type: 'f', value: 0 } }, fragmentShader: glslify('./bloom.frag') }); _blurMaterial = new THREE.RawShaderMaterial({ uniforms: { u_texture: { type: 't', value: undef }, u_delta: { type: 'v2', value: new THREE.Vector2() } },
0
0
0
59 60 61 62 63 64 65 66 67 68
this.width = 1; this.height = 1; this.renderer = renderer; this.material = new THREE.RawShaderMaterial( { uniforms: { map: { type: 't', value: null } }, vertexShader: vertexShader,
0
0
0
+ 6 other calls in file
35 36 37 38 39 40 41 42 43 44
// material var geometry = THREE.Lensflare.Geometry; var material1a = new THREE.RawShaderMaterial({ uniforms: { 'scale': { value: null }, 'screenPosition': { value: null } },
0
0
0
+ 2 other calls in file
three.Vector3 is the most popular function in three (22341 examples)