godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.34k stars 21.06k forks source link

Problem with Depth In Spatial Material #17953

Closed NHodgesVFX closed 6 years ago

NHodgesVFX commented 6 years ago

Godot version: 3.02

OS/device including version: Windows 10 64bit, Nvidia Geforce 980

Issue description: I cannot get depth in the spatial material to work for me. I assume the depth uses a height map as a texture. The stone material with depth does seem to work in the material demo but i can not get any of my own textures to work very well.

Most of the time what happens is when the texture is attached the object gets blurry and starts moving around with the camera. Decreasing the scale seems to fix this but i see very little depth in the material regardless of the scale setting or the Deep Parallax setting.

I think it would be better if we had something like substance Player\painters Parallax Onclusion Mapping. When looking at substance painter POM it looks as if its tessellated but then when you pan the camera down to looking across the edge you can tell its flat.

The lighting in the below examples is different but the material is the same. Substance has better depth. Im not sure if im using Godot's depth wrong or if it has a bug. It also possible that substance is using a different method then Godot

If the current depth functions as intended it would be nice to improve the implementation when Vulcan is implemented. While in the meantime it would be helpful to have better docs for Godot's Depth.

Godot Depth godot_depth

Substance Designer POM substance_depth

Minimal reproduction project: Depth_.zip

EzraT commented 6 years ago

I'm not entirely sure, but I think this is a problem caused by faulty normal/tangent generation on some of the built-in primitives, After applying your material to a Blender Cube mesh I exported with the Better Collada plugin, and making sure the "Tangent Arrays" option was checked, this was the result:

01

It works on the cube, while the same issues still remain on the PlaneMesh primitive. Depth can only function properly if the mesh has proper normals/tangents.

Depth_.zip

And from what I understand, height-maps are inverted in SpatialMaterial, meaning that black is no depth, and white is more depth downwards into the mesh so to speak, so I changed the depth value in your example to -0.1.

zoopp commented 6 years ago

16096 seems to touch on this issue.

akien-mga commented 6 years ago

Seems to be a duplicate of #15934 if I'm not mistaken (if I am, feel free to ask me to reopen).