How to use the UniformsUtils function from three

Find comprehensive JavaScript three.UniformsUtils code examples handpicked from public code repositorys.

23
24
25
26
27
28
29
30
31
32

};

lineShaders = {

        uniforms: THREE.UniformsUtils.merge( [
                THREE.UniformsLib.common,
                THREE.UniformsLib.fog,
                lineUniforms
        ] ),
fork icon185
star icon867
watch icon40

+ 11 other calls in file

53
54
55
56
57
58
59
60
61
62
}
var geometry = new THREE.BufferGeometry();
geometry.addAttribute( 'position', new THREE.BufferAttribute( position, 3 ));

var material = new THREE.ShaderMaterial({
    uniforms: THREE.UniformsUtils.merge([
        THREE.UniformsLib.shadowmap,
        {
            texturePosition: { type: 't', value: undef },
            color1: { type: 'c', value: undef },
fork icon160
star icon993
watch icon36

+ 3 other calls in file

55
56
57
58
59
60
61
62
63
64
module.exports = function (renderer, scene, camera, rt, fullWidth, fullHeight, chunkHeights, sampleLevel, render) {
    return new Promise((resolve) => {
        const jitterOffsets = JitterVectors[Math.max(0, Math.min(sampleLevel, 5))];
        const {autoClear} = renderer;
        const copyShader = THREE.CopyShader;
        const copyUniforms = THREE.UniformsUtils.clone(copyShader.uniforms);
        const copyMaterial = new THREE.ShaderMaterial({
            uniforms: copyUniforms,
            vertexShader: copyShader.vertexShader,
            fragmentShader: copyShader.fragmentShader,
fork icon119
star icon813
watch icon25

92
93
94
95
96
97
98
99
100
101
Fn.expandBoundingBox(boundingBoxGeometry.boundingBox, config.point_size * 0.5);

geometry.boundingBox = boundingBoxGeometry.boundingBox.clone();

const material = new THREE.ShaderMaterial({
    uniforms: THREE.UniformsUtils.merge([phongShader.uniforms, {
        shininess: {value: 50},
        opacity: {value: config.opacity},
    }, uniforms]),
    defines: {
fork icon115
star icon803
watch icon0

32
33
34
35
36
37
38
39
40
// };

var geometry = new THREE.SphereGeometry(200, 40, 40);

// shader = this.shaders['earth'];
// uniforms = THREE.UniformsUtils.clone(shader.uniforms);

var texture = THREE.ImageUtils.loadTexture('world.jpg');
texture.minFilter = THREE.LinearFilter;
fork icon40
star icon163
watch icon13

186
187
188
189
190
191
192
193
194
195


            
// Material Properties
let shader = volrenutils.VolumeRenderShader;
let uniforms = THREE.UniformsUtils.clone({
    "u_size": { value: new THREE.Vector3( dim[0],dim[1],dim[2]) },
    "u_spacing": { value: new THREE.Vector3( 1.0/spa[0],1.0/spa[1],1.0/spa[2] )},
    "u_renderstyle": { value: 1 },
    "u_renderthreshold": { value: 0.15 },
fork icon31
star icon75
watch icon16

8
9
10
11
12
13
14
15
16
17

THREE.ShaderPass = function ( shader, textureID ) {

        this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";

        this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );

        this.material = new THREE.ShaderMaterial( {

                uniforms: this.uniforms,
fork icon9
star icon36
watch icon16

+ 11 other calls in file

590
591
592
593
594
595
596
597
598
599
extendParams: function (materialParams, materialDef, parser) {
  var pbrSpecularGlossiness = materialDef.extensions[this.name];

  var shader = THREE.ShaderLib["standard"];

  var uniforms = THREE.UniformsUtils.clone(shader.uniforms);

  var specularMapParsFragmentChunk = [
    "#ifdef USE_SPECULARMAP",
    "	uniform sampler2D specularMap;",
fork icon3
star icon7
watch icon8

+ 14 other calls in file

1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
	console.error( 'THREE.BokehPass relies on THREE.BokehShader' );

}

const bokehShader = THREE.BokehShader;
const bokehUniforms = THREE.UniformsUtils.clone( bokehShader.uniforms );
bokehUniforms[ 'tDepth' ].value = this.renderTargetDepth.texture;
bokehUniforms[ 'focus' ].value = focus;
bokehUniforms[ 'aspect' ].value = aspect;
bokehUniforms[ 'aperture' ].value = aperture;
fork icon3
star icon7
watch icon0

+ 118 other calls in file

763
764
765
766
767
768
769
770
771
772

this.saoMaterial = new THREE.ShaderMaterial( {
	defines: Object.assign( {}, THREE.SAOShader.defines ),
	fragmentShader: THREE.SAOShader.fragmentShader,
	vertexShader: THREE.SAOShader.vertexShader,
	uniforms: THREE.UniformsUtils.clone( THREE.SAOShader.uniforms )
} );
this.saoMaterial.extensions.derivatives = true;
this.saoMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
this.saoMaterial.defines[ 'NORMAL_TEXTURE' ] = this.supportsNormalTexture ? 1 : 0;
fork icon3
star icon7
watch icon1

+ 125 other calls in file

68
69
70
71
72
73
74
75
76
77
  ].join('\n')
};


var ShaderPass = function(shader) {
  this.uniforms = THREE.UniformsUtils.clone(shader.uniforms);

  this.material = new THREE.ShaderMaterial({
    defines: shader.defines || {},
    uniforms: this.uniforms,
fork icon3
star icon6
watch icon2

+ 9 other calls in file

1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
                delete this.defines.MATCAP_BLENDING_MULTIPLY;
                break;
        }
    },
});
this.uniforms = three_1.UniformsUtils.clone(MMDToonShader_1.MMDToonShader.uniforms);
// merged from MeshToon/Phong/MatcapMaterial
const exposePropertyNames = [
    'specular',
    'opacity',
fork icon1
star icon3
watch icon0

+ 4 other calls in file

44
45
46
47
48
49
50
51
52
53
if (SSAOShader_1.SSAOShader === undefined) {
    console.error('THREE.SSAOPass: The pass relies on SSAOShader.');
}
this.ssaoMaterial = new three_1.ShaderMaterial({
    defines: Object.assign({}, SSAOShader_1.SSAOShader.defines),
    uniforms: three_1.UniformsUtils.clone(SSAOShader_1.SSAOShader.uniforms),
    vertexShader: SSAOShader_1.SSAOShader.vertexShader,
    fragmentShader: SSAOShader_1.SSAOShader.fragmentShader,
    blending: three_1.NoBlending,
});
fork icon1
star icon3
watch icon0

+ 23 other calls in file

60
61
62
63
64
65
66
67
68
69
}
this.saoMaterial = new three_1.ShaderMaterial({
    defines: Object.assign({}, SAOShader_1.SAOShader.defines),
    fragmentShader: SAOShader_1.SAOShader.fragmentShader,
    vertexShader: SAOShader_1.SAOShader.vertexShader,
    uniforms: three_1.UniformsUtils.clone(SAOShader_1.SAOShader.uniforms),
});
this.saoMaterial.extensions.derivatives = true;
this.saoMaterial.defines['DEPTH_PACKING'] = this.supportsDepthTextureExtension ? 0 : 1;
this.saoMaterial.defines['NORMAL_TEXTURE'] = this.supportsNormalTexture ? 1 : 0;
fork icon1
star icon3
watch icon0

+ 9 other calls in file

622
623
624
625
626
627
628
629
630
  this.isDeferredShaderMaterial = true;
  this.params = params;
}

DeferredShaderMaterial.prototype.create = function () {
  var uniforms = THREE.UniformsUtils.clone(this.params.uniforms);

  for (var uniformId in this.params.uniforms) {
    var originalUniform = this.params.uniforms[uniformId];
fork icon0
star icon1
watch icon0

+ 9 other calls in file

119
120
121
122
123
124
125
126
127
128
scene = new THREE.Scene()

var geometry = new THREE.SphereGeometry(200, 40, 30)

shader = Shaders['earth']
uniforms = THREE.UniformsUtils.clone(shader.uniforms)

uniforms['texture'].value = THREE.ImageUtils.loadTexture(imgDir + 'world.jpg')

material = new THREE.ShaderMaterial({
fork icon491
star icon0
watch icon3

234
235
236
237
238
239
240
241
242
243
 *   The `vec3 vPosition` variable is available to `glsl` expressions; it
 *   contains the coordinates in Three-space of the texel currently being
 *   rendered.
 */
THREE.Terrain.generateBlendedMaterial = function(textures) {
    var uniforms = THREE.UniformsUtils.merge([THREE.ShaderLib.lambert.uniforms]),
        declare = '',
        assign = '';
    for (var i = 0, l = textures.length; i < l; i++) {
        // Uniforms
fork icon0
star icon2
watch icon3

+ 3 other calls in file

228
229
230
231
232
233
234
235
236
237
var map = new THREE.TextureLoader().load(texturePath);
var material;
if (this._simulation.isUsingLightSources()) {
    // TODO(ian): Follow recommendation for defining ShaderMaterials here:
    // https://discourse.threejs.org/t/cant-get-a-sampler2d-uniform-to-work-from-datatexture/6366/14?u=ianw
    var uniforms = THREE.UniformsUtils.merge([
        // TODO(ian): These failed due to type check. Remove?
        // THREE.UniformsLib.ambient,
        THREE.UniformsLib.lights,
        // THREE.UniformsLib.shadowmap,
fork icon0
star icon0
watch icon1

+ 12 other calls in file

586
587
588
589
590
591
592
593
594
595
if (THREE.CopyShader === undefined)
	console.error("THREE.OutlinePass relies on THREE.CopyShader");

var copyShader = THREE.CopyShader;

this.copyUniforms = THREE.UniformsUtils.clone(copyShader.uniforms);
this.copyUniforms["opacity"].value = 1.0;

this.materialCopy = new THREE.ShaderMaterial({
	uniforms: this.copyUniforms,
fork icon0
star icon0
watch icon1

+ 35 other calls in file

13
14
15
16
17
18
19
20
21
22

constructor(parameters) {

    parameters = parameters || {};

    parameters.uniforms = three.UniformsUtils.merge([
        three.ShaderLib.normal.uniforms,
        { linearize_depth: { value: parameters.linearize_depth ?? true } }
    ]);
    parameters.vertexShader = 'varying mat4 vProjectionMatrix;' + '\n'
fork icon0
star icon0
watch icon0

+ 19 other calls in file

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)