Created
August 2, 2023 07:23
-
-
Save otanodesignco/1b93b7aa594d49df90d434badf1eb053 to your computer and use it in GitHub Desktop.
glsl view position of the camera based on the model position in three.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* calculate view position of the camera */ | |
out vec3 vViewDirection; | |
void main() | |
{ | |
vec4 worldPosition = modelMatrix * vec4( position, 1.0 ); | |
vViewDirection = normalize( cameraPosition - worldPosition.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