Graphics Reference
In-Depth Information
var basicShader =
THREE.ShaderLib['normal'];
In step 3, we'll reference this basicShader object to get the standard vertex
shader.
2. For our custom shader, we have some configuration options. These options
are passed into a shader using uniforms:
var uniforms = {};
uniforms.delta = {type: 'f', value:
0.0};
uniforms.mNear = { type: "f", value:
1.0 };
uniforms.mFar = { type: "f", value:
60.0 };
This means that in our shader code, we can access the delta , mNear , and
mFar values, all of which are floating point values, and we can use them to
calculate the colors we want to render.
3. Next, we can create the shader material:
var material = new
THREE.ShaderMaterial({
uniforms: uniforms,
vertexShader:
basicShader.vertexShader,
fragmentShader: document
getElementById('simple-fragment').text,
});
In the configuration of THREE.ShaderMaterial , we reference our uni-
form variable, the standard vertex shader, basicShader.vertexShader
provided by Three.js, and our own custom fragment shader. We'll show you
the definition of our custom shader in step 5.
Search WWH ::




Custom Search