diff --git a/shaders/cube.frag b/shaders/cube.frag index d980196..95894e0 100644 --- a/shaders/cube.frag +++ b/shaders/cube.frag @@ -2,17 +2,22 @@ // vim: ft=c // clang-format off +layout(binding = 1) uniform samplerCube combined_image; + layout(location = 0) out vec4 outColor; layout(location = 0) in vec4 normal; layout(location = 1) in vec4 pos_pre; +layout(location = 2) in vec4 view_orig; layout(push_constant, std430) uniform pc { layout(offset=48) vec4 data; }; 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) { // outColor = vec4(1.0); //} diff --git a/shaders/cube.vert b/shaders/cube.vert index 6a0402f..a8375c7 100644 --- a/shaders/cube.vert +++ b/shaders/cube.vert @@ -19,6 +19,7 @@ layout(push_constant, std430) uniform pc { layout (location = 0) out vec4 normal; layout (location = 1) out vec4 pos_pre; +layout (location = 2) out vec4 view_orig; const float PI = 3.14159; // Forgive me for I have sinned @@ -28,6 +29,7 @@ void main() { // assign outs normal = pos.posnrm[gl_VertexIndex].norm; pos_pre = pos.posnrm[gl_VertexIndex].pos; + view_orig = cam_orig; // define constants const float zFar = 100.0;