“attribute vec3 customColor;”
“attribute float customOpacity;”,
“attribute float customSize;”,
“attribute float customAngle;”,
Vertex shaders don’t receive customColor ,other values(customOpacity……) is ok.
what happend?who could help me?
“attribute vec3 customColor;”
“attribute float customOpacity;”,
“attribute float customSize;”,
“attribute float customAngle;”,
Vertex shaders don’t receive customColor ,other values(customOpacity……) is ok.
what happend?who could help me?
I don’t think you can store colors wherever you are storing them. Did you try just doing three floats?
color->float? RGB to float? How do I use it?
Something like
var myNumber = myColor.r
If you want it in an array you can do this:
var array_of_numbers = [
myColor0.r,
myColor1.g,
distance_to_hong_kong
]
function arrayOfColorsToRaw(array){
const typed = new Float32Array(array.length * 3)
for( let i = 0, c=0 ; i < array.length; i++){
typed[c++] = array[i].r
typed[c++] = array[i].g
typed[c++] = array[i].b
}
}
attribute vec3 customColor;->attribute float customColorR;attribute float customColorG;attribute float customColorB; this way is ok
I don’t understand how vertexAttrib1fv works. and Vertex shaders 's vec3 how to receive ?
I don’t understand why you are looking at threes source. There is a higher level api to this.
Vertex shaders 's vec3 don’t recevie value.
in this way:
this.particleMaterial.defaultAttributeValues.customColor.value[i] = new THREE.Color({r,g,b}) ; this way is wrong. i dont‘t understand.
Do it like so:
var color = new THREE.Color();
var colors = [];
for ( var i = 0; i < positionAttribute.count; i ++ ) {
color.set( 0xffffff * Math.random() ); // generate random color
colors.push( color.r, color.g, color.b ); // layout is [ r, g, b, r, g, b, ... ]
}
geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );
Array of objects are not supported. You always have to store primitive values in your attribute buffer.
I don’t think there is a type c
or any other type for that matter.
Yeah, your attribute definitions look strange. Where have you seen this approach?
in this demo:Particle Engine (Three.js) js:ParticleEngine.js,but it used three version was 60. I want to update to the latest version.
Ancient history There is no need for any of that i think, just make your attributes and call them from the shader.