I would like to confirm that this “u_mose” can be implemented in nme
Yes, you will simply have to pass the mouse x and y coordinates from your js code.
If you use a vec2
input named MouseCoords
:
Then, in your js code, you can do:
yourNodeMaterial.getInputBlockByPredicate((block) => block.name === "MouseCoords").value = new BABYLON.Vector2(scene.pointerX, scene.pointerY);
Warning: code not tested!
ok,thank you ,get it ,
Help me check this nme, why this multipy connect err
i want to implement this shader
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
void main() {
vec2 st = gl_FragCoord.xy/u_resolution;
// float y = st.x;
// vec3 color = vec3(y);
color = smoothstep(0.02, 0.0, abs(st.y - st.x)) * vec3(0.0,1.0,0.0);
gl_FragColor = vec4(color,1.0);
}
If you want to multiply a node N with a type other than float with a float, you should link N to the left input, and the float to the right input:
Or you can also use the Scale
node, which makes it clear which is the float / other entry:
tks, i need try it
it ok
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
// Plot a line on Y using a value between 0.0-1.0
float plot(vec2 st) {
return smoothstep(0.02, 0.0, abs(st.y - st.x));
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution;
float y = st.x;
vec3 color = vec3(y);
// Plot a line
float pct = plot(st);
color = (1.0-pct)*color+pct*vec3(0.0,1.0,0.0);
// color = (1.0-pct)*color;
// color = pct*vec3(0.0,1.0,0.0);
gl_FragColor = vec4(color,1.0);
}