Skip to content

what's the detail about diffuse light #168

Open
@linhaiwei123

Description

@linhaiwei123

this is the code in vertex.glsl
`precision mediump float;

attribute vec3 position;
attribute vec3 normal;

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

uniform mat4 inverseModel;
uniform mat4 inverseView;
uniform mat4 inverseProjection;

uniform vec3 ambient;
uniform vec3 diffuse;
uniform vec3 lightDirection;

varying vec3 fragNormal;

void main() {
gl_Position = projectionviewmodel*vec4(position, 1);
fragNormal = normal;
}
this is the code in fragment.glslprecision mediump float;

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

uniform mat4 inverseModel;
uniform mat4 inverseView;
uniform mat4 inverseProjection;

uniform vec3 ambient;
uniform vec3 diffuse;
uniform vec3 lightDirection;

varying vec3 fragNormal;

void main() {
float brightness = dot(fragNormal,lightDirection);
gl_FragColor = vec4(ambient + diffuse * max(brightness, 0.0),1);
// gl_FragColor = vec4(1,1,1,1);
}`
and i can't pass the test
anyone can give me some tips?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions