BabylonNative icon indicating copy to clipboard operation
BabylonNative copied to clipboard

ScreenSpaceReflectionPostProcess: Exception in HostFunction: ERROR: 0:8: 'step' : redefinition

Open sebavan opened this issue 4 years ago • 11 comments

Reporting back https://github.com/BabylonJS/Babylon.js/issues/11298 from @igorroman777

I just wanted to integrate ScreenSpaceReflectionPostProcess into babylonjs react native.!

My Code is:

  var ssr = new ScreenSpaceReflectionPostProcess("ssr", scene, 1.0, camera);
      ssr.reflectionSamples = 32;
      ssr.strength = 2; 
      ssr.reflectionSpecularFalloffExponent = 3; 

Repro

  • Current result: ERROR BJS - [21:39:25]: Error: Exception in HostFunction: ERROR: 0:8: 'step' : redefinition ERROR: 1 compilation errors. No code generated.

Android phone:

  • Samsung
  • Babylonjs react native
  • Version: "@babylonjs/core": "5.0.0-alpha.44", "@babylonjs/loaders": "5.0.0-alpha.44", "@babylonjs/react-native": "0.4.0-alpha.33",

sebavan avatar Oct 18 '21 19:10 sebavan

@darraghjburke Looks like something is wrong in the shader translation code.

bghgary avatar Oct 18 '21 20:10 bghgary

There is a uniform called step https://github.com/BabylonJS/Babylon.js/blob/5e6321d887637877d8b28b417410abbbeb651c6e/src/Shaders/screenSpaceReflection.fragment.fx#L14

It's a reserved keyword. Changing the name in the shader will fix it. I find it weird that there is no error reported by the browser.

CedricGuillemet avatar Oct 19 '21 09:10 CedricGuillemet

BTW, is there a way to get all shaders from BJS (with variants) and get them through glslang/spirv translation? With UnitTests? I'm sure there are other shaders with such kind of issue. I've already fixed one or two some months ago.

CedricGuillemet avatar Oct 19 '21 09:10 CedricGuillemet

@CedricGuillemet nice find! Will submit a PR for BJS.

As far as testing, that sounds like something we should do, but what would we be testing? If it's the visual output, it should be a validation test probably. If it's the shader output, how would we generate the correct outputs to compare it to?

darraghjburke avatar Oct 19 '21 16:10 darraghjburke

Was the error caused by glslang? The driver? Can we close this issue?

CedricGuillemet avatar Oct 26 '21 13:10 CedricGuillemet

I have tested with:

    "@babylonjs/core": "5.0.0-alpha.57",
    "@babylonjs/loaders": "5.0.0-alpha.57",
    "@babylonjs/react-native": "0.4.0-alpha.39",

I am now getting another problem:

 LOG  BJS - [18:40:26]: Babylon Native (v5.0.0-alpha.57) launched
 ERROR  BJS - [18:40:26]: PrePassRenderer needs WebGL 2 support.
Maybe you tried to use the following features that need the PrePassRenderer :
 + Subsurface Scattering 

igorroman777 avatar Oct 27 '21 16:10 igorroman777

@igorroman777 To support SSR,we need to add support for the PrePassRenderer to Babylon Native. We're taking a look at what we need to do to make this happen. Thanks for bringing this to our attention!

darraghjburke avatar Oct 27 '21 20:10 darraghjburke

@CedricGuillemet the error came from program.addShader() online 32 in ShaderCompilerD3D, so glslang. My best guess would be that glslang is just more strict about shader compilation than WebGL

darraghjburke avatar Oct 27 '21 20:10 darraghjburke

There are options in glslang that we could perhaps play with that may reduce the strictness.

bghgary avatar Oct 27 '21 21:10 bghgary

Hey @igorroman777,

The changes to support this feature will be nontrivial. This relies on the createMultipleRenderTarget function, which we don't currently support in Babylon Native. We want to support it eventually, but it isn't currently on our radar.

Is it a must-have for your project?

I have created an issue to track progress on this feature (#945).

darraghjburke avatar Nov 02 '21 23:11 darraghjburke

some postprocess now works https://github.com/BabylonJS/BabylonNative/pull/1354 SSR not working yet

CedricGuillemet avatar Feb 07 '24 14:02 CedricGuillemet