axmol/tests/cpp-tests/Source/shaders/cube_map.vert

25 lines
635 B
GLSL
Raw Normal View History

2023-07-22 23:59:17 +08:00
#version 310 es
2023-07-25 19:06:12 +08:00
layout(location = POSITION) in vec4 a_position;
layout(location = NORMAL) in vec3 a_normal;
2023-07-22 23:59:17 +08:00
2023-07-25 19:06:12 +08:00
layout(location = TEXCOORD0) out vec3 v_reflect;
2023-07-22 23:59:17 +08:00
//uniforms
layout(std140, binding = 0) uniform vs_ub {
mat4 u_MVPMatrix;
mat4 u_MVMatrix;
mat3 u_NormalMatrix;
};
void main(void)
{
gl_Position = u_MVPMatrix * a_position;
// compute reflect
vec4 positionWorldViewSpace = u_MVMatrix * a_position;
vec3 vEyeVertex = normalize(positionWorldViewSpace.xyz);
vec3 v_normalVector = u_NormalMatrix * a_normal;
v_reflect = normalize(reflect(-vEyeVertex, v_normalVector));
}