diff options
author | iurii <[email protected]> | 2024-09-05 22:46:40 +0200 |
---|---|---|
committer | iurii <[email protected]> | 2024-09-05 22:46:40 +0200 |
commit | 6add0f74e9c8a0a1b1252a8bab01a2d677555e63 (patch) | |
tree | 3fcde746673a7b3c8b4ff5c748f061b26423e979 | |
parent | 4009a194178f1f85bf8936faeca2bf14dcff2c08 (diff) | |
download | funhalla-6add0f74e9c8a0a1b1252a8bab01a2d677555e63.tar.gz |
update shader to struct
-rw-r--r-- | res/shaders/colors.fs | 9 | ||||
-rw-r--r-- | src/main.odin | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/res/shaders/colors.fs b/res/shaders/colors.fs index 8d51645..df02754 100644 --- a/res/shaders/colors.fs +++ b/res/shaders/colors.fs @@ -2,7 +2,7 @@ struct Material { vec3 ambient; vec3 diffuse; - vec3 specula; + vec3 specular; float shininess; }; @@ -20,19 +20,20 @@ uniform Material material; void main() { // ambient vec3 ambient = light_color * material.ambient; - + // diffuse vec3 norm = normalize(Normal); vec3 light_dir = normalize(light_position - FragPos); float diff = max(dot(norm, light_dir), 0.0); vec3 diffuse = light_color * (diff * material.diffuse); - + // specular vec3 view_dir = normalize(view_position - FragPos); vec3 reflect_dir = reflect(-light_dir, norm); float spec = pow(max(dot(view_dir, reflect_dir), 0.0), material.shininess); vec3 specular = light_color * (spec * material.specular); - + vec3 result = ambient + diffuse + specular; FragColor = vec4(result, 1.0); } + diff --git a/src/main.odin b/src/main.odin index a21a891..ea37cc0 100644 --- a/src/main.odin +++ b/src/main.odin @@ -399,11 +399,11 @@ main :: proc() { shader.use(lighting_shader) light_color := Vec3{1.0, 1.0, 1.0} - shader.set_vec3(lighting_shader, cstring("light_color"), &light_color) material_ambient := Vec3{1.0, 0.5, 0.31} material_diffuse := Vec3{1.0, 0.5, 0.31} material_specular := Vec3{0.5, 0.5, 0.5} + shader.set_vec3(lighting_shader, cstring("light_color"), &light_color) shader.set_vec3(lighting_shader, cstring("material.ambient"), &material_ambient) shader.set_vec3(lighting_shader, cstring("material.diffuse"), &material_diffuse) shader.set_vec3(lighting_shader, cstring("material.specular"), &material_specular) |