COSC-3P98-Assigment-3/include/shaders/geometry.geom

56 lines
1.1 KiB
Plaintext
Raw Normal View History

2023-04-02 23:49:58 -04:00
#ifdef __cplusplus
#include <string>
std::string shader_geom = R"("
2023-04-02 22:11:47 -04:00
#version 460
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
2023-04-02 23:49:58 -04:00
in vec4 pos_[];
out vec2 uv_;
out float index;
const vec3 vertices[] = {
vec3(0.5f, 0.5f, 0.0f),
vec3(0.5f, -0.5f, 0.0f),
vec3(-0.5f, -0.5f, 0.0f),
vec3(-0.5f, 0.5f, 0.0f)
};
uniform mat4 pvm;
uniform vec4 up;
uniform vec4 right;
void emitTransformed(vec3 pos){
// passthough index
index = pos_[0].w;
//gl_Position = pvm * vec4(pos_[0].xyz + vertices[0], 1.0);
gl_Position = pvm * vec4(pos, 1.0);
}
2023-04-02 22:11:47 -04:00
void main() {
2023-04-02 23:49:58 -04:00
const float quad_size = 0.5;
vec3 pos = pos_[0].xyz;
2023-04-02 22:11:47 -04:00
2023-04-02 23:49:58 -04:00
emitTransformed(pos + up.xyz * quad_size + right.xyz * quad_size);
uv_ = vec2(0, 0);
EmitVertex();
emitTransformed(pos + up.xyz * quad_size - right.xyz * quad_size);
uv_ = vec2(0, 1);
EmitVertex();
emitTransformed(pos - up.xyz * quad_size + right.xyz * quad_size);
uv_ = vec2(1, 0);
EmitVertex();
emitTransformed(pos - up.xyz * quad_size - right.xyz * quad_size);
uv_ = vec2(1, 1);
EmitVertex();
EndPrimitive();
2023-04-02 22:11:47 -04:00
}
2023-04-02 23:49:58 -04:00
")";
#endif