deltaphc / raylib-rs

Rust bindings for raylib
Other
786 stars 139 forks source link

vertexNormals are not getting set #202

Open 0x177 opened 2 months ago

0x177 commented 2 months ago

i have a vertex shader that passes the normal of the vertex to the fragment shader. i can confirm that whatever fragNormal is set do does get passed to the fragment shader. the problem is that all the normals are 0,0,0. here are the relevant parts of code:

drawing geometry:

let mut d2 = d2.begin_shader_mode(&shader);

d2.draw_plane(
    Vector3::new(0.0, 0.0, 0.0),
    Vector2::new(32.0, 32.0),
    Color::LIGHTGRAY,
);

d2.draw_cube(Vector3::zero(),2.0,4.0,2.0,Color::WHITE);

vertex shader:

#version 330

in vec3 vertexNormal;

uniform mat4 matNormal;

out vec3 fragNormal;

void main()
{
    fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
}
RoseApollo commented 1 month ago

i am also experiencing this issue

IoIxD commented 3 weeks ago

Can either of you reproduce this with the unstable branch on raylib-rs/raylib-rs (the repo where development happens more often), which adds a closure-based start_shader_mode?