Hi,
I want to make some trail like one in this game : Color Ball
in three Js
Im reading about shader material for two weeks now but I cant figure it out, also I cant find any tutorial about it.
I want to write it myself not use some code like TrailRenderer.
can anybody help?
Ok let me be more specific this is vertex shader from : GitHub - mkkellogg/TrailRendererJS: 3D object trail renderer for Three.js
attribute float nodeID;
attribute float nodeVertexID;
attribute vec3 nodeCenter;
uniform float minID;
uniform float maxID;
uniform float trailLength;
uniform float maxTrailLength;
uniform float verticesPerNode;
uniform vec2 textureTileFactor;
uniform vec4 headColor;
uniform vec4 tailColor;
varying vec4 vColor;
void main() {
float fraction = ( maxID - nodeID ) / ( maxID - minID );
vec4 realPosition = vec4( ( 1.0 - fraction ) * position.xyz + fraction * nodeCenter.xyz, 1.0 );
gl_Position = projectionMatrix * viewMatrix * realPosition;
vColor = ( 1.0 - fraction ) * headColor + fraction * tailColor;
}
can anyone describe what’s fraction do? or whats MaxID or MinID
and whats nodeCenters?
I know what is and. how to use attribute or uniform.
what I cant solve is how to fill thats uniform and attributes.
I need help please.
1 Like
Is there anybody can explain ?
1 Like