Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Light is given in model space and not in eye space in standard mesh rendering #187

Open
TsurHerman opened this issue Jul 25, 2017 · 1 comment

Comments

@TsurHerman
Copy link
Contributor

TsurHerman commented Jul 25, 2017

Hi Simon,
in util.vert function render

void render(vec3 vertex, vec3 normal, mat4 viewmodel, mat4 projection, vec3 light[4])
{
    vec4 position_camspace = viewmodel * vec4(vertex,  1);
    // normal in world space
    o_normal               = normal;
    // direction to light
    o_lightdir             = normalize(light[3] - vertex);
    // direction to camera
    o_vertex               = -position_camspace.xyz;
    // screen space coordinates of the vertex
    gl_Position            = projection * position_camspace;
}

which is used for the standard mesh rendering, the light position is relative to the vertex
which is in model space , it should be relative to model*vertex (world space) the position in camspace

I would issue a PR but in entails changing the signature of render , which in turn would cause a wide change in the various calls to render.

@TsurHerman
Copy link
Contributor Author

A quick run through some openGL tutorials reveals that the convention is that light position is given in
eye (Camera) space. therefore it is easy to issue a PR , I am on it.

@TsurHerman TsurHerman changed the title Light is given in model space and not in world space in standard mesh rendering Light is given in model space and not in eye space in standard mesh rendering Jul 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant