Is there the way to use Parallax Mapping for node material?

@Evgeni_Popov was braver than me :wink:

Hmm, when i try to load this page (Babylon.js Node Material Editor) i got an a error:

And i cant find a parallax block on NME page.Sorry if i dont understand smth. :sweat_smile:

*parallax property in perturb normal block

The changes are not deployed to the Playground yet.

And i cant find a parallax block on NME page.Sorry if i dont understand smth. :sweat_smile:

It’s not a new block, it’s the existing PerturbNormal block that will have some new inputs/outputs when the changes are deployed to the Playground:
image

Got that, Thanks!

@Evgeni_Popov You are a hero! Thanks, will test this ASAP!

Note that the Playground is not updated yet (probably tomorrow).

Playground is now updated!

Really cool to see this implemented! Is there an example on how to use the parallax offset?
I tried to add it to the UV before plugging it into the albedo texture. But the shader doesn’t compile anymore.

Here is a playground: https://playground.babylonjs.com/#NSG82E#3
There should be another cube that looks like the first. But it isn’t rendered because of the shader not compiling. If I connect the UV directly to the albedo texture it works. But of course no offset.

This is the error:

10:52:28: Shader compilation error: VERTEX SHADER ERROR: 0:195: ‘dFdx’ : no matching overloaded function found ERROR: 0:195: ‘=’ : dimension mismatch ERROR: 0:195: ‘=’ : cannot convert from ‘const mediump float’ to ‘highp 3-component vector of float’ ERROR: 0:196: ‘dFdy’ : no matching overloaded function found ERROR: 0:196: ‘=’ : dimension mismatch ERROR: 0:196: ‘=’ : cannot convert from ‘const mediump float’ to ‘highp 3-component vector of float’ ERROR: 0:197: ‘dFdx’ : no matching overloaded function found ERROR: 0:197: ‘=’ : dimension mismatch ERROR: 0:197: ‘=’ : cannot convert from ‘const mediump float’ to ‘highp 2-component vector of float’ ERROR: 0:198: ‘dFdy’ : no matching overloaded function found ERROR: 0:198: ‘=’ : dimension mismatch ERROR: 0:198: ‘=’ : cannot convert from ‘const mediump float’ to ‘highp 2-component vector of float’ ERROR: 0:269: ‘gl_FrontFacing’ : undeclared identifier ERROR: 0:269: ‘’ : boolean expression expected

Thanks in advance!

You need to help the system a bit so that the parallax code is generated in the fragment shader and not in the vertex shader by setting the target of the Add block to Fragment:

https://playground.babylonjs.com/#NSG82E#4

1 Like

Perfect! Thank you!