three.js - ThreeJS pass uv coordinates to RawShaderMaterial? -
i'm trying create shader texture map on scratch. looking @ other materials (shaders) , sources, seems have "uv" attribute passed them. i'm having hard time figuring out uv attribute generated , assigned. set on geometry, material, or both?
i'm using default three.geometry objects, three.spheregeometry
. assumed have attributes set on them, when inspect meshes scene children don't see attribute key/value set on them.
this example of shader generated shadermaterial
or other:
vertex shader
attribute vec2 uv; varying vec2 vuv; void main() { vuv = uv;
fragment shader
varying vec2 vuv; uniform sampler2d map; void main() { vec4 texel = texture2d( map, vuv );
however, when attempt above, shader (with rawshadermaterial) goes blank , "could not compile."
is there magic in 3 sets relationship between shader, object , attributes?
i found three.js generate uv coordinate question, again, i'm guessing 3 default object has uv attributes set correctly?
i want use rawshadermaterial in case. can point me place in 3 source uvs generated objects / passed shaders, or tell me how set uvs use in fragment / vertex @ runtime?
Comments
Post a Comment