Page MenuHome

Parallax mapping implementation for viewport and BGE.
Needs ReviewPublic

Authored by Jorge Bernal (lordloki) on Feb 4 2016, 7:45 PM.

Details

Summary

Parallax mapping method is faking dynamic texture which gives us the impression of more complex models. It is useful for walls, rocks, grounds, etc.

This patch is a simplified version of Angelo Miner patch about parallax mapping. If this option is enabled in texture panel the user will have to pass a texture with a alpha channel cooresponding to depth of the texture.

The UI for parallax is composed of 4 values:

  • Height Bias
  • Step
  • Depth
  • Discard Edges

To fix the majority of the artefacts, an interpolation method was implemented, it smooths between previous and next parallax step considering the weight between the both steps. It let us use 5 steps instead of 40.
The code was inspired of http://www.learnopengl.com/#!Advanced-Lighting/Parallax-Mapping.

Authors: Angelo Miner, Ulysse Martin, Diego Lopes and Tristan Porteries.


Diff Detail

Repository
rB Blender
Branch
parallax

Event Timeline

Ulysse Martin (youle) edited edge metadata.EditedFeb 4 2016, 8:39 PM

Hi! @Jorge Bernal (lordloki): Thanks to have adapt it for Blender official :) I agree with what we have done hehe. The only thing to know is that it doesn't work in orthographic view. We haven't found a solution yet but maybe there's just a simple formula to make it work in orthographic view... But I accept the revision :) (I can't apply the patch with the last Blender sources)

Jorge Bernal (lordloki) updated this revision to Diff 5964.

update to current master

Overall it looks fine to me. Is this a setting that should be restricted to the Blender Game render engine? I'll need to apply the patch this evening to play around with it and get a feel for the user experience.

Has this been tested to see how well it interacts with other texture effects such as normal maps and the new cubemap reflections?

Ulysse Martin (youle) added a comment.EditedFeb 5 2016, 1:00 AM

@Daniel Stokes (kupoman): The thing is this parallax works only with an appropriate UV mapping. The normal map texture has the parallax depth encoded in its alpha channel. I made tutos on how to use it here: https://doc.upbge.fr/releases.php?id=0.0.3 .
I briefly tested yesterday with cubemap reflections but I tried with Suzanne and I didn't obtained good result. But I guess with a cube it can be fine.

@Jorge Bernal (lordloki): Thanks for the update to the current master. I'll try it.

EDIT: Hehe good to see it in the bge :)

Here are textures to test:

Why is a checkbox needed under mapping? It looks like the Height Scale checkbox could be used for the same thing, especially since it looks like they are the same thing based on tooltips. The tooltips don't seem very helpful, especially since I don't know what SPOM is. Is there any documentation other than youtube videos?

For parallax mapping settings, a better approach might be to do something like the bump mapping settings further down in the panel.

  • Why a checkbox needed under mapping? this checkbox is a boolean and is used to enable MTEX_PARALLAX_UV flag that is needed in gpu_material.c .
  • In properties_textures.py, you can see that use_parallax_uv is used both for the checkbox under mapping and for "parallax uv shift", so if you enable use parallax uv, it enables parallax uv shift and if you enable parallax uv shift, it enables use parallax uv... This could be changed indeed.
  • We didn't modify RNA tooltips from Angelo Miner (I think. I didn't modified it), but the tooltips could be improved with USA or UK or Australia or commonwealth natives people (or english teachers). SPOM means silhouette parallax occlusion mapping. (And I agree to say that "height Scale" is not a good name for parallax_uv_shift :) ).

What is problematic is how to correctly use parallax (how to create textures and how to use it in Blender) and I think the videos (with video comments) are the best way to explain it. Or a good tuto in tutorialsforblender, but I don't know if Blender official web site can host such documentation...

@Jorge Bernal (lordloki): In the picture you made in the summary, I guess the image is purple/violet because Angelo Miner in his test file used a .tif as colorMap and you have to choose to build WITH_IMAGE_TIFF to have .tif support.

I will unify checkboxes and I will improve tooltips and tutorial. Thanks for commenting

@Jorge Bernal (lordloki): Hi! We had a problem with size: http://www.pasteall.org/pic/show.php?id=99218 . To fix it: http://www.pasteall.org/64601/diff

EDIT: It seems this fix works only with some textures. All textures can't be scaled. They have to be seamless but must respect some criterias too to be scaled

EDIT2: Finally panzergame found the right fix about scale: https://github.com/UPBGE/blender/commit/95d6e409ebd770af64e310e84e77646bcbcef47b

And he added another for discard option: https://github.com/UPBGE/blender/commit/6cfac1c33573b521f0d1fa9943622cfd743d5104

Jorge Bernal (lordloki) updated this revision to Diff 6193.
  • Use parallax transition for edge discarding
  • rework UI & internals removing Use Parallax UV option
  • Fix Parallax texture size centered.
  • do_versions

I will update the summary with example and tutorials the next days.