| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- //
- // Physically Based Shading of a microfacet surface material - Vertex Shader
- // Modified from reference implementation at https://github.com/KhronosGroup/glTF-WebGL-PBR
- //
- #include <attributes>
- // Model uniforms
- uniform mat4 ModelViewMatrix;
- uniform mat3 NormalMatrix;
- uniform mat4 MVP;
- #include <morphtarget_vertex_declaration>
- #include <bones_vertex_declaration>
- // Output variables for Fragment shader
- out vec3 Position;
- out vec3 Normal;
- out vec3 CamDir;
- out vec2 FragTexcoord;
- void main() {
- // Transform this vertex position to camera coordinates.
- Position = vec3(ModelViewMatrix * vec4(VertexPosition, 1.0));
- // Transform this vertex normal to camera coordinates.
- Normal = normalize(NormalMatrix * VertexNormal);
- // Calculate the direction vector from the vertex to the camera
- // The camera is at 0,0,0
- CamDir = normalize(-Position.xyz);
- // Output texture coordinates to fragment shader
- FragTexcoord = VertexTexcoord;
- vec3 vPosition = VertexPosition;
- mat4 finalWorld = mat4(1.0);
- #include <morphtarget_vertex>
- #include <bones_vertex>
- gl_Position = MVP * finalWorld * vec4(vPosition, 1.0);
- }
|