Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something wrong with Depth/Parallax Mapping in Spatial Material #15934

Closed
wlodeqp opened this issue Jan 21, 2018 · 8 comments
Closed

Something wrong with Depth/Parallax Mapping in Spatial Material #15934

wlodeqp opened this issue Jan 21, 2018 · 8 comments
Assignees
Milestone

Comments

@wlodeqp
Copy link

wlodeqp commented Jan 21, 2018

Godot version:
Godot 3.0 RC 2

OS/device including version:
Ubuntu 16.04 64-bit

Issue description:
The default parallax mapping change bump angle when you rotate scene view.

I changed this line of code:
vec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT,-BINORMAL,NORMAL));
to this one (removed minus)
vec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT,BINORMAL,NORMAL))
and it works but I don't know it is real fix.

Steps to reproduce:
Open the project and slowly rotate scene view above the planes

Minimal reproduction project:
Test5.zip

@Bauxitedev
Copy link

I had the same problem, I thought it was a problem with my parallax maps at first. Good to know there's a workaround for now.

@Biliogadafr
Copy link
Contributor

Looks like parallax also affected by this #16009. I did some tests and I see that different inbuilt geometry (planes, quads) shows different parallax behavior. For example material with fix in test scene from this issue will work for inbuilt Plane, but will not work for Quad and for imported geometry.

@Calinou
Copy link
Member

Calinou commented Apr 2, 2018

Unfortunately, this fix does not work with all meshes. I wanted to submit a pull request (Calinou@fd54b81) also incorporating changes from #15794, but while it looks good on a cube exported from Blender, it looks broken on the test mesh from the Material Tester demo.

Good depth mapping:
depth_mapping_good

Broken depth mapping:
depth_mapping_bad

@Biliogadafr
Copy link
Contributor

Biliogadafr commented Apr 3, 2018

Tangents are different for various importers/formats and inbuilt geometry. They affect how normal maps and parallax works. I've tried to unify tangents in my fix #16096 (not merged) to match those from Material Tester and to work correctly with OpenGL style normal maps, like in Material Tester. (But maybe something was changed since then?)

@reduz
Copy link
Member

reduz commented Sep 6, 2018

I am not really sure about this because, as mentioned before, it really depends on the application, Maybe options to flip binormal/tangent should be added..

@reduz reduz self-assigned this Sep 6, 2018
@fracteed
Copy link

fracteed commented Oct 5, 2018

After doing a lot of experimenting with parallax maps in Godot, I also could only get them to work using the same method as @wlodeqp , by removing the minus from the binormal code. As noted by @Biliogadafr in #16009 parallax mapping will not work on Godot's native primitives.

Also, care must be taken to use an actual depth map with white as the furthest depth, as Substance and other engines/renderers use a height/displacement map which has white as the closest depth.

I have attached a project file with 2 parallax materials using the aforementioned steps. Since I posted this on twitter and my website, I have heard no feedback that this approach doesn't work on various hardware configurations. Hopefully this easy fix (removing the negative sign) can be added before 3.1 is released.

parallax_heads.zip

parallax_heads_screenshot1

@Calinou
Copy link
Member

Calinou commented Oct 5, 2018

Also, care must be taken to use an actual depth map with white as the furthest depth,

Note that in 3.1 alpha and later, you can invert the color of an image directly in its Import settings without having to modify it manually.

I still think it would lead to a better user experience if depth maps were inverted to work like in most other software though.

@reduz
Copy link
Member

reduz commented Nov 14, 2018

I am not quite sure what to do with this one. Technically, it can fail completely depending on the geometry and how it was created, given tangent space is not warranted to be universal.

I will add an option to flip x and y in tangent space to make sure it can work with everything, but it needs to be done manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants