Editor icon indicating copy to clipboard operation
Editor copied to clipboard

Enabling motion blur crashes the editor

Open ernest4 opened this issue 3 years ago • 2 comments

OS: mac Env: just running default TPS project Recreate: go to Scene -> Rendering -> Motion Blur -> Enable

Screenshot 2021-12-05 at 07 59 52

Full error print out:

[ERROR]: Unable to compile effect:

[ERROR]: Uniforms: world, mBones, viewProjection, diffuseMatrix, view, previousWorld, previousViewProjection, mPreviousBones, morphTargetInfluences, bumpMatrix, reflectivityMatrix, vTangentSpaceParams, vBumpInfos, diffuseSampler, bumpSampler, reflectivitySampler

[ERROR]: Attributes: position, normal, matricesIndices, matricesWeights

[ERROR]: Defines:
#define POSITION
#define POSITION_INDEX 2
#define VELOCITY
#define VELOCITY_INDEX 3
#define BONES_VELOCITY_ENABLED
#define REFLECTIVITY
#define REFLECTIVITY_INDEX 4
#define NUM_BONE_INFLUENCERS 4
#define BonesPerMesh 68
#define RENDER_TARGET_COUNT 6

[ERROR]: Vertex code:

[ERROR]: #version 300 es
#define WEBGL2
#define POSITION
#define POSITION_INDEX 2
#define VELOCITY
#define VELOCITY_INDEX 3
#define BONES_VELOCITY_ENABLED
#define REFLECTIVITY
#define REFLECTIVITY_INDEX 4
#define NUM_BONE_INFLUENCERS 4
#define BonesPerMesh 68
#define RENDER_TARGET_COUNT 6
#define SHADER_NAME vertex:geometry
precision highp float;
precision highp int;
uniform mat4 mBones[BonesPerMesh];
uniform mat4 mPreviousBones[BonesPerMesh];
in vec4 matricesIndices;
in vec4 matricesWeights;
uniform mat4 world;
in vec3 position;
in vec3 normal;
uniform mat4 viewProjection;
uniform mat4 view;
out vec3 vNormalV;
out vec4 vViewPos;
out vec3 vPositionW;
uniform mat4 previousWorld;
uniform mat4 previousViewProjection;
uniform mat4 mPreviousBones[BonesPerMesh];
out vec4 vCurrentPosition;
out vec4 vPreviousPosition;
void main(void)
{
vec3 positionUpdated=position;
vec3 normalUpdated=normal;
mat4 finalWorld=world;
mat4 influence;
influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
finalWorld=finalWorld*influence;
vec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));
vNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));
vViewPos=view*pos;
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
mat4 previousInfluence;
previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);
vPositionW=pos.xyz/pos.w;
gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
}

[ERROR]: Fragment code:

[ERROR]: #version 300 es
#define WEBGL2
#define POSITION
#define POSITION_INDEX 2
#define VELOCITY
#define VELOCITY_INDEX 3
#define BONES_VELOCITY_ENABLED
#define REFLECTIVITY
#define REFLECTIVITY_INDEX 4
#define NUM_BONE_INFLUENCERS 4
#define BonesPerMesh 68
#define RENDER_TARGET_COUNT 6
#define SHADER_NAME fragment:geometry


precision highp float;
precision highp int;
in vec3 vNormalV;
in vec4 vViewPos;
in vec3 vPositionW;
in vec4 vCurrentPosition;
in vec4 vPreviousPosition;
in vec2 vReflectivityUV;
uniform sampler2D reflectivitySampler;
layout(location=0) out vec4 glFragData[RENDER_TARGET_COUNT];
void main() {
vec3 normalOutput;
normalOutput=normalize(vNormalV);
glFragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);
glFragData[1]=vec4(normalOutput,1.0);
glFragData[POSITION_INDEX]=vec4(vPositionW,1.0);
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
vec2 velocity=abs(a-b);
velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
glFragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
vec4 reflectivity=vec4(0.0,0.0,0.0,1.0);
glFragData[REFLECTIVITY_INDEX]=reflectivity;
}

[ERROR]: Offending line [30] in vertex code: uniform mat4 mPreviousBones[BonesPerMesh];

[ERROR]: Error: VERTEX SHADER ERROR: 0:30: 'mPreviousBones' : redefinition

Once it goes into that state it's basically crashed and editor needs to be restarted.

ernest4 avatar Dec 05 '21 08:12 ernest4

Hi @ernest4 ! Good catch thanks for reporting! I actually reproduced when the device doesn't support parallel compilation for shaders.

julien-moreau avatar Dec 07 '21 18:12 julien-moreau

Hi @ernest4 ! Fixed in branch using Babylon.JS v5.x Waiting for it to be deployed

julien-moreau avatar May 03 '22 17:05 julien-moreau