Skip to content

Commit

Permalink
Fix InfinitePlane shaders
Browse files Browse the repository at this point in the history
after changes in gridColor function
  • Loading branch information
disusdev committed Jan 2, 2023
1 parent fa93842 commit 693c4a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion data/shaders/chapter07/VK03_InfinitePlane.frag
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include <data/shaders/chapter05/GridCalculation.h>

layout (location=0) in vec2 uv;
layout (location=1) in vec2 cameraPos;
layout (location=0) out vec4 out_FragColor;

void main()
{
out_FragColor = gridColor(uv);
out_FragColor = gridColor(uv, cameraPos);
}
7 changes: 7 additions & 0 deletions data/shaders/chapter07/VK03_InfinitePlane.vert
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <data/shaders/chapter05/GridParameters.h>

layout (location=0) out vec2 uv;
layout (location=1) out vec2 cameraPos;

layout(binding = 0) uniform UniformBuffer
{
Expand All @@ -20,6 +21,12 @@ void main()
int idx = indices[gl_VertexIndex];
vec3 position = pos[idx] * gridSize;

mat4 iview = inverse(ubo.view);
cameraPos = vec2(iview[3][0], iview[3][2]);

position.x += cameraPos.x;
position.z += cameraPos.y;

gl_Position = MVP * vec4(position, 1.0);
uv = position.xz;
}

0 comments on commit 693c4a8

Please sign in to comment.