0 votes

A foundamental question for me is how are sizes in Godot 3D?
What is their relations to real-world sizes?
Each unit in Godot 3D is equal to how long in real-world?

Nowhere in docs or net does not explains such questions clearly, so may be they are silly questions, but I need them because we want to develop a high-precision flight simulator with Godot.

My specific question is, for example if we want to use Zylann HeightMap plugin for terrain generations, what should be dimentions of terrain for simulating 8*8km area?

in Engine

## 3 Answers

+1 vote

I wrote my assumptions about this here:
https://godotforums.org/discussion/18480/godot-3d-vector-physics-cheat-sheet

You could basically use any scale you want but perhaps the physics default values (i.e. gravity with 9.8m/sec²) would have to be adjusted.

I assume that 1 size unit is 1 meter. Mass is in kilogram. And this works well here.

I also create my 3D models in blender in that scale. -> 1 unit = 1m.

But I've no experience with Zylanns HeightMap plugin. I assume that the size would be 8000x8000. You could simply try it out by creating a mesh with a known size of i.e. 100x100m and compare this with a (smaller) heightmap in the editor.

by (3,240 points)

With a consider to above assumptions, a 2 by 2 by 2 default cube mesh in the below images is 2 meters each side. A 2048*2048 pixels texture applied to terrain mesh. As you can see it is not so realistic. What should I do to show it more real?
Should I resize the texture to smaller size?

Terrain texturing is often done with "Splatmap" shaders. I guess that Zylanns plugin already comes with one.

If you just use a single texture then you can just let that repeat. You need a repeatable also called "seamless" texture for that to look good. If used on meshes, you adjust the UV accordingly.
If you use a cube mesh of godot then I think there's some kind of UV-multiplier/scale which you can adjust. If you use a 3D editor like Blender then this has its own UV-editor.

For zylanns plugin there's a splatmap shader (as far as I know).
A Splatmap is one texture that is used as index to combine multiple high-res (repearting) textures.

So while that splatmaps resolution seems very coarse it is just "replaced" by other terrain textures in higher resolution.

https://www.youtube.com/watch?v=eZuvfIHDeT4

Thanks for your descriptions about Splatmap shading and texturing a mesh, you are correct and Zylanns plugin use Splatmap technique for shading terrain.

But let me describe a bit more about my question. I mean the cube is a criterion and it's not a part of final terrain. The cube shows us 2 meters as well, so in front of that terrain's texture can be measured. As you can see in Top view image, some stones that may be are few centimeters in real world, looks 1 meters (for example) in image. This does not make it look real.

In another words, small stones that must be centimeters long, looks so big as meters, How we can correct this?

The scale of a texture is generally controlled by the UV.
If you got a square surface of a mesh then you have 4 corners where you set those UV coordinates which are actually texture x/y coordinates. Values/Factors from 0 to 1 are used to be scalable independent of the actual texture size.

So you can i.e. set the UV from the upper left corner to 0,0 and the UV from the lower right corner to 1.0, 1.0. Then the texture covers exactly the square. But if you set the lower right corner to 2.0, 2.0 then the texture coordinates would go out of bounds after leaving the upper left quarter of the square. That's where the "Repeat" flag (set when importing a texture) comes into play.

If repeat is enabled than the texture would just be starting again at 0 when passing 1.0. So the texture will be tiled on the surface. With UVs from 0,0 to 2,2 the texture will be repeated in 4 tiles.

Those UVs are either assigned in the 3D editor, or from code if you create a mesh/surface in i.e. GDScript.

If you use predefined meshes from Godot like i.e. the CubeMesh then the UVs are predefined from code. But you can alter them a bit in the SpatialMaterial "Uv1" settings. You can alter the Scale (usually x/y) and let therefore let your rocks appear smaller or larger. Offsets will move the location of the origin inside the texture.

On meshes with a splatmap shader the UVs of the Mesh will typically index the splatmap which is the lookup index which decides which texture to use on a certain "location".

So for example the terrain mesh is i.e. 1km x 1km big and the UVs are mapped from 0,0 from one corner to 1,1 on the other corner. The texture may be 1024x1024 pixel large so it can roughly define a separate texture (not pixel) for each square meter. (Texture changes will be blended typically by texture lookup interpolation)
So if you define to have sand in the center of the map. You then set the pixel 512,512 of the splatmap to i.e. full red (assuming red is mapped to a sand texture). The UV of the terrain mesh on the center is (using the mapping defined above) 0.5, 0.5. This will be calculated to 0.5 * 1024 = 512. (If the texture would be 2048x2048pixel then this would address it's center pixel as well, 0.5*2048 = 1024)

Ok, so now the splatshader selects sand but how how to define how big a grain of sand is? This is typically done by assigning a scale value (in the splat shaders parameters) for each texture.
So when the UV (x and y) for 1 m² on the mesh will actually move from 0.500 to 0.501 you apply a factor to this to get the actual UVs for the sand texture. Let's say the factor is 1000 then you calculate the UVs 500 to 501 from that. As the sand texture is set to repat this would be the same as the range from 0 to 1. So with factor 1000 the sand texture is set to repeat each 1m² in this case.

I don't know how the scaling parameter exactly look like on zylanns addon. But I assume that they are there.

So much thanks! Expansive step by step texturing tutorial which could be nice enough for every starter like me! :-) Although I knew some parts of that, but putting all together give me a nice big picture! I think it's better to create a specific question for better use of everyone.

As I understand, every texture can be scaled, and with the scale value we can define grain of sand. So in the splatshading technique, every texture has a scale value. For example if sand texture is on R channel, we should scale down sand texture on R channel to achieve finer grain of sand.

The first below image shows Zylann texture selecting steps, as you can see, there is nowhere to define texture scale value. I changed texture scale inside import window (second image) in reimport texture but does not affect. I know my question is more related to Zylann plugin rather than this topic now, but maybe you can help me and of course get a nice result from this conversation!

0 votes

It's actually written in the docs: Introduction to 3D

Godot uses the metric system for everything. 3D Physics and other areas are tuned for this, so attempting to use a different scale is usually a bad idea (unless you know what you are doing).

When working with 3D assets, it’s always best to work in the correct scale (set your DCC to metric). Godot allows scaling post-import and, while this works in most cases, in rare situations it may introduce floating point precision issues (and thus, glitches or artifacts) in delicate areas, such as rendering or physics, so make sure your artists always work in the right scale!

by (4,015 points)
0 votes

So what is relations to pixels?
How many pixels used for rendering each unit? (that is equal to 1 meter)

by (81 points)

This is in 3D. So that depends on your camera `projection mode`, `fov` or `size` and your relative camera position to your objects (if the `projection mode` is `Perspective`), that is, 1 meter closer to camera looks bigger than 1 meter farther away.

Docs for Camera node.

I knew some projections and parameters effects on final count of pixels, but I think some base values must be defined according to resolutions or somethings else that affected by these settings you mentioned. so What is base value and how can change it? or better question is what is straight function from 1 unit to pixel counts without effect of these you mentioned?