I have a simple graphics program written in c++ that uses opengl for rendering. I have a plane that I draw at the origin and I want to add a procedural grid texture to it. In my current fragment shader I only do some lighting calculations:
#version 330 core
out vec4 FragColor;
in vec3 Normal;
in vec2 TexCoord;
in vec3 FragPos;
uniform vec3 objectColor;
uniform vec3 lightColor;
uniform vec3 lightPos;
void main()
{
float ambientStrength = 0.5;
vec3 ambient = ambientStrength * lightColor;
vec3 norm = normalize(Normal);
vec3 lightDir = normalize(lightPos - FragPos);
float diff = max(dot(norm, lightDir), 0.0);
vec3 diffuse = diff * lightColor;
vec3 result = (((ambient + diffuse) * objectColor) * 0.5) ;
FragColor = vec4(result, 1.0);
}
My question is if modifying the fragment shader is the best way of having a procedural grid on my plane and if so how should I go about writing such a shader?