Skip to content

Commit 0ffd50c

Browse files
CopilotMStachowicz
andcommitted
Implement bone grid - grid now follows camera movement
Co-authored-by: MStachowicz <14092934+MStachowicz@users.noreply.github.com>
1 parent 80adf9b commit 0ffd50c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/OpenGL/GLSL/grid.vert

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ out vec4 FragmentColour;
1414

1515
void main()
1616
{
17-
gl_Position = viewProperties.projection * viewProperties.view * vec4(VertexPosition, 1.0);
17+
// Snap camera position to grid units to create bone grid effect
18+
// This makes the grid follow the camera while maintaining grid alignment
19+
vec3 camera_pos = viewProperties.camera_position.xyz;
20+
vec3 snapped_camera_pos = floor(camera_pos);
21+
22+
// Offset the grid position by the snapped camera position
23+
vec3 world_position = VertexPosition + snapped_camera_pos;
24+
25+
gl_Position = viewProperties.projection * viewProperties.view * vec4(world_position, 1.0);
1826
FragmentColour = VertexColour;
1927
}

0 commit comments

Comments
 (0)