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,
  });
fork icon259
star icon3
watch icon0

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 }
    },
fork icon34
star icon217
watch icon8

+ 27 other calls in file

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 }
    },
fork icon34
star icon216
watch icon8

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 }
    },
fork icon34
star icon216
watch icon8

+ 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);
fork icon15
star icon120
watch icon9

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 },
fork icon5
star icon23
watch icon3

+ 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,
fork icon18
star icon1
watch icon3

+ 15 other calls in file

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,
  }),
fork icon260
star icon0
watch icon0

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,
fork icon260
star icon0
watch icon2

+ 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 },
fork icon398
star icon9
watch icon1

+ 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",
fork icon14
star icon0
watch icon2

+ 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 },
fork icon0
star icon1
watch icon6

+ 5 other calls in file

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.] },
fork icon236
star icon0
watch icon2

+ 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 },
fork icon159
star icon0
watch icon1

+ 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 }
    },
fork icon1
star icon3
watch icon0

+ 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 */

fork icon0
star icon1
watch icon0

+ 9 other calls in file

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() }
    },
fork icon0
star icon0
watch icon0

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,
fork icon0
star icon0
watch icon0

+ 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 }
	},
fork icon0
star icon0
watch icon0

+ 2 other calls in file

Other functions in three

Sorted by popularity

function icon

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