Skip to content

Instantly share code, notes, and snippets.

@otanodesignco
Created August 3, 2023 06:50
Show Gist options
  • Save otanodesignco/4a739b7e21fac0711d568a219eb4bfd1 to your computer and use it in GitHub Desktop.
Save otanodesignco/4a739b7e21fac0711d568a219eb4bfd1 to your computer and use it in GitHub Desktop.
How to transform normals to world space for lighting
out vec3 vWorldSpaceNormal;
void main()
{
vec4 worldSpaceNormal = modelMatrix * vec4( normal, 0.0 );
vWorldSpaceNormal = normalize( worldSpaceNormal.xyz );
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment