This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl

58 lines
1.1 KiB
GLSL
Raw Normal View History

2017-03-04 00:09:22 +01:00
uniform mat4 ViewProjectionMatrix;
#ifdef USE_WORLD_CLIP_PLANES
uniform mat4 ModelMatrix;
#endif
2017-03-04 00:09:22 +01:00
/* ---- Instantiated Attrs ---- */
2017-03-04 00:09:22 +01:00
in float pos;
/* ---- Per instance Attrs ---- */
2017-03-04 00:09:22 +01:00
in vec3 color;
in vec4 corners[2]; /* trouble fetching vec2 */
in float depth;
in vec4 tria;
in mat4 InstanceModelMatrix;
2017-03-05 20:29:21 +01:00
flat out vec4 finalColor;
2017-03-04 00:09:22 +01:00
void main()
{
vec3 pPos;
if (pos == 1.0) {
pPos = vec3(corners[0].xy, depth);
}
else if (pos == 2.0) {
pPos = vec3(corners[0].zw, depth);
}
else if (pos == 3.0) {
pPos = vec3(corners[1].xy, depth);
}
else if (pos == 4.0) {
pPos = vec3(corners[1].zw, depth);
}
else if (pos == 5.0) {
pPos = vec3(tria.xy, depth);
}
else if (pos == 6.0) {
vec2 ofs = tria.xy - corners[0].xy;
ofs.x = -ofs.x;
pPos = vec3(corners[1].zw + ofs, depth);
}
else if (pos == 7.0) {
pPos = vec3(tria.zw, depth);
}
else {
pPos = vec3(0.0);
}
gl_Position = ViewProjectionMatrix * InstanceModelMatrix * vec4(pPos, 1.0);
2017-03-05 20:29:21 +01:00
finalColor = vec4(color, 1.0);
#ifdef USE_WORLD_CLIP_PLANES
2019-01-26 15:00:03 +11:00
world_clip_planes_calc_clip_distance((ModelMatrix * InstanceModelMatrix * vec4(pPos, 1.0)).xyz);
#endif
2017-03-04 00:09:22 +01:00
}