2
$\begingroup$

I'm trying to write code (in any language) to render this 3D grid, matching the look and colors as closely as possible:

enter image description here

$\endgroup$
  • 5
    $\begingroup$ What have you tried and what are you stuck on? We're not a code writing site, but we can help you figure things out if you can be more specific about what you've tried. If you haven't tried anything, do that first and come back with questions about whatever isn't working. $\endgroup$ – user1118321 Nov 10 '18 at 3:41
2
$\begingroup$

You can do it by only rendering a flat plane and then making a grid in fragment shader. This is actually a nice exercise.

To get these two color values, you can use color selector, which is available in any graphic software for example MS Paint

Some code hints:

vec2 coord = worldPos.xz / stepSize; //square size in world space
vec2 frac = fract(coord); //fractional parts of squares
//interpolation, grad is smoothness of line gradients
vec2 mult = smoothstep(0.0, grad, frac) - smoothstep(1.0-grad, 1.0, frac);
vec3 col = mix(col1, col2, mult.x * mult.y);
$\endgroup$
1
$\begingroup$

Make a tiling texture of a cross. When this texture repeats in all dimensions, it will make a grid-like pattern. Next render a ground plane as above and unwrap the texture on it with the appropriate tiling rate. Change the intensity of the color based on the dot product of the ground plane normal and the view direction to get the lighting/fade effect (you can experiment with different falloff functions and ranges).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.