Closed Niutonian closed 1 month ago
I push a fix for that issue recently. Please update the node.
Other wise you can change the line
color = vec4(uv, sin(u_time) * 0.5 + 0.5, 1.0);
for
color = vec4(st, sin(u_time) * 0.5 + 0.5, 1.0);
ok, it works now, but other codes do not, I'm sorry, I'm really new at GLSL so I have no clue what the results should look like. Do you have a website you could recomend to get started?
one last questiom, this code outputs a black square, do you know why?
uniform vec2 u_resolution;
varying vec4 v_position;
varying vec3 v_normal;
void main(void) {
vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
vec2 pixel = 1.0/u_resolution;
vec2 st = gl_FragCoord.xy * pixel;
#if defined(BACKGROUND)
// Draw a ciruclar gradient background
float dist = distance(st, vec2(0.5));
color.rgb += 1.0-dist;
#else
// Basic diffuse shading from directional light
vec3 N = normalize(v_normal);
vec3 L = vec3(1.0, 1.0, 0.0);
vec3 Ld = normalize(L - v_position.xyz);
color.rgb += dot(N, Ld) * 0.5 + 0.5;
#endif
gl_FragColor = color;
}
Hi @Niutonian That example utilize vertex shaders and have a some #defines that only works on GlslViewer that loads models. Also depending the version number gl_FragColor
is deprecated.
I recomend you to start by reading The Book of Shaders The examples there should work on the editor. (probably you need to change gl_FragColor
for fragColor
+ adding out vec4 fragColor;
at the top)
Hello, I've been trying to run your node, but I get this error