Reflective cube

master
Avery 1 week ago
parent 3da43d5a69
commit 8168eebf7b
Signed by: Avery
GPG Key ID: 4E53F4CB69B2CC8D

@ -2,17 +2,22 @@
// vim: ft=c // vim: ft=c
// clang-format off // clang-format off
layout(binding = 1) uniform samplerCube combined_image;
layout(location = 0) out vec4 outColor; layout(location = 0) out vec4 outColor;
layout(location = 0) in vec4 normal; layout(location = 0) in vec4 normal;
layout(location = 1) in vec4 pos_pre; layout(location = 1) in vec4 pos_pre;
layout(location = 2) in vec4 view_orig;
layout(push_constant, std430) uniform pc { layout(push_constant, std430) uniform pc {
layout(offset=48) vec4 data; layout(offset=48) vec4 data;
}; };
void main() { void main() {
outColor = vec4(data.rgb*(1.0+dot(normal.xyz, normalize(vec3(-0.7, -0.5, -0.1))))/2.0, 1.0); vec4 ray = pos_pre - view_orig;
outColor = texture(combined_image, vec3(reflect(ray, normal)));
// outColor = vec4(data.rgb*(1.0+dot(normal.xyz, normalize(vec3(-0.7, -0.5, -0.1))))/2.0, 1.0);
//if(pos_post.z <= 0.0) { //if(pos_post.z <= 0.0) {
// outColor = vec4(1.0); // outColor = vec4(1.0);
//} //}

@ -19,6 +19,7 @@ layout(push_constant, std430) uniform pc {
layout (location = 0) out vec4 normal; layout (location = 0) out vec4 normal;
layout (location = 1) out vec4 pos_pre; layout (location = 1) out vec4 pos_pre;
layout (location = 2) out vec4 view_orig;
const float PI = 3.14159; const float PI = 3.14159;
// Forgive me for I have sinned // Forgive me for I have sinned
@ -28,6 +29,7 @@ void main() {
// assign outs // assign outs
normal = pos.posnrm[gl_VertexIndex].norm; normal = pos.posnrm[gl_VertexIndex].norm;
pos_pre = pos.posnrm[gl_VertexIndex].pos; pos_pre = pos.posnrm[gl_VertexIndex].pos;
view_orig = cam_orig;
// define constants // define constants
const float zFar = 100.0; const float zFar = 100.0;

Loading…
Cancel
Save