4
$\begingroup$

For clarification, I am trying to create a Supergrid:

  • Put a 2m x 2m grid texture on a mesh.
  • When I move or scale the mesh, the grid will increase as the mesh does
    (the 2m x 2m does not stretch or distort, but instead increases the number of lines which represent the 2m grid)
  • The grid is shown equally on XYZ faces of a mesh.

A bonus would be changing colors, as boxing out a whole level in one color could be confusing.


Details:
I was trying to set up a grid material(s) for blocking out game levels. A short effort to make a simple material seems to have drained my day without a solution, if anyone could help I would greatly appreciate it.

Something similar or exactly like Supergrid for UE4. Skip to 1:10 for basic function. https://m.youtube.com/watch?v=NxUq_rD8PVM#

I was trying to use a grid node created by Anton Nevesolv. https://m.youtube.com/watch?v=gsZoJBeAWGc Though, this might not be ideal for creating the desired results?

If we take the above grid and use it in a cube material node,

  • then attach the Object socket of a Texture Coordinate node to the vector of the Grid node,
  • then use the eye dropper on the Texture Coordinate to assign a plane as the mesh that will represent the ground of a level,

This seems to work similarly to what is happening in Supergrid for UE4. However, the sides of the cube becomes lines instead of a grid.

The same things happens if you use an image of the grid. However, if you change the texture coordinate from Object to UV, we get a nice grid on all sides of the mesh, but now it wont slide in relation to the ground plane, and it also distorts when scaling the mesh.

Any help would be greatly appreciated. I have been trying for hours and I don't see a solution in sight.

$\endgroup$

2 Answers 2

6
$\begingroup$

enter image description here

This will work for mesh with planar surfaces aligned to the world axis.

That can be this kind of settings, based on world coordinates as input:

enter image description here

It adds the object location to object coordinates so that the result is sensible to the mesh location. Then, it takes a cross product with the normal, in order to avoid limit values to appear when calculating the grid (you'll can test the difference, using it or not).

The grid itself is just a comparison to some value, of the fraction part of the scaled coordinates. More precisely, if the value is around 0.5 (again to avoid limit cases we may encounter if comparing to 0 or 1).

enter image description here

Edit

enter image description here

If you want the grid to be stable from the object position, change the input like that (the object location is substrated from the surface location in world coordinates):

enter image description here

Is you want the grid to be aligned to the object (if its origin is in a corner), change the node group shifting it 0.5/scale (see below on left).

And to avoid limit cases, keep only one positive test (below on right).

enter image description here

Updated blend file:

$\endgroup$
9
  • $\begingroup$ Thank you so much! This looks exactly what I am looking for. However, when I try to recreate or Open the blender file you generously provided, the cube is white. Any Idea of what might be happening? $\endgroup$
    – Shinyu
    Commented Oct 25, 2020 at 17:06
  • $\begingroup$ Should not be white. Or does it appear in solid mode? (or your blender version is not 2.9?) $\endgroup$
    – lemon
    Commented Oct 25, 2020 at 17:20
  • $\begingroup$ 2.9 fixed it! Thank you so much! I posted this question in a few different places. If you don't mind, I would like to credit you in those places by posting a link to this solution. I wonder if there is a way to replicate this effect (having the grid expand when a mesh is scaled or size changed) by using the local object. That way when a mesh is moved around the map, the grid will always represent the scale of the mesh. (Example, a 2m x 2m cube. No matter where you move it, there will be a 2x2 grid on it. If scaled by 2.0, the grid will now show 4x4.) I can't thank you enough! $\endgroup$
    – Shinyu
    Commented Oct 25, 2020 at 19:12
  • 2
    $\begingroup$ @vklidu, done. Edited the last part according to Shinyu comments. Though, I should add more explaination about some points. Will try to do it when possible. $\endgroup$
    – lemon
    Commented Oct 26, 2020 at 8:17
  • 1
    $\begingroup$ @vklidu, by the way, I think this tricky one may interest you blender.stackexchange.com/questions/199977/… $\endgroup$
    – lemon
    Commented Oct 26, 2020 at 19:05
4
$\begingroup$

For now based on image texture. Cube is scaling in all axis from corner, for that texture coordinates are assigned to Empty object.

Empty object uses Location Costraint of Cube to keep coordinates in corener when Cube is moved. (Ussually I parent empty to object , but in this case scaling would destroy texture proportions.)

enter image description here

The grid itself - I didnt check OP reference, but I will. I wanted to make it easier for me, but at the end the crucial part was to mix image on sides of Cube without UVmap. It is not a problem let texture project from three sides and mix with Multiply, but issue raised when cube started to scale - it changed the color of shorted face = result of mixed textures. So I created node mask (stored in Node Group) for sides in XYZ and thouse I used for mixing.

enter image description here

enter image description here

$\endgroup$
7
  • $\begingroup$ This is also amazing! Any idea why I am getting strange white glare? ibb.co/TP4Q0Wx $\endgroup$
    – Shinyu
    Commented Oct 25, 2020 at 19:51
  • $\begingroup$ Looks like a nice solution! I think a sketched explanation of how it works, even if it seems obvious to you, would really improve the answer? $\endgroup$
    – Robin Betts
    Commented Oct 25, 2020 at 20:32
  • $\begingroup$ @vklidu, do you also have this kind of issues with your blend on your computer? i.sstatic.net/amywM.jpg . Most of the "complicated" things in mine were about get rid of this. $\endgroup$
    – lemon
    Commented Oct 26, 2020 at 8:22
  • $\begingroup$ @vklidu, here both Eevee and Cycles causes the problem. This is some kind of z fighting in the face normal axis. That's why I've used a cross product (which eliminates the vector componant that is along this normal). Will try to explain that in my answer when possible (will ping you when done). $\endgroup$
    – lemon
    Commented Oct 26, 2020 at 15:27
  • $\begingroup$ @lemon Ha ... also Shinyu was referring to that (I missed his screen), yes seems like a z-fight. Can you check updated blend? Should be fixed. Just from couriousity. Since I could see that only in Cycles I'm not sure what others see. Thanks $\endgroup$
    – vklidu
    Commented Oct 26, 2020 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .