cables-gl / cables_docs

cables documentation docs.cables.gl
https://cables.gl/docs/docs
45 stars 16 forks source link

PerlinAreaDeform fails if calc normals are set while rendering a tesselated mesh #849

Open esperanc opened 2 months ago

esperanc commented 2 months ago

Link to simple, reproducible example patch https://cables.gl/edit/ZZy3Hn

Describe the bug In the example patch you can see what's going on. I have a simple tesselated plane rendered with RenderGeometry which is deformed with the PerlinAreaDeform op. If you set the calc normals flag, it fails with the following message:

[LoadingStatus] finished loading 1 assets in 0.069s [LoadingStatus] finished loading 1 assets in 0.236s [platform] slow request: GET /api/changelog?num=1: 427ms [cgl_shader] bad line: 306: norm=mod1930_calcNormal(mod1930_p.xyz,norm.xyz,tangent,bitangent); [cgl_shader] bad line: 319: tangent=mod1930_newTangent; [cgl_shader] bad line: 320: bitangent=mod1930_newBiTangent; [cgl_shader] ERROR: 0:306: 'tangent' : undeclared identifier ERROR: 0:306: 'bitangent' : undeclared identifier ERROR: 0:306: 'mod1930_calcNormal' : no matching overloaded function found ERROR: 0:306: '=' : dimension mismatch ERROR: 0:306: 'assign' : cannot convert from 'const mediump float' to 'out highp 3-component vector of float' ERROR: 0:319: 'tangent' : undeclared identifier ERROR: 0:319: 'assign' : l-value required (can't modify a const) ERROR: 0:319: '=' : dimension mismatch ERROR: 0:319: 'assign' : cannot convert from 'highp 3-component vector of float' to 'const highp float' ERROR: 0:320: 'bitangent' : undeclared identifier ERROR: 0:320: 'assign' : l-value required (can't modify a const) ERROR: 0:320: '=' : dimension mismatch ERROR: 0:320: 'assign' : cannot convert from 'highp 3-component vector of float' to 'const highp float' [cgl_shader] Wireframe Material copy shader linking fail... Screenshot 2024-09-08 at 11 43 05

How To Reproduce

  1. Open Example patch
  2. Click on Calc Normals input of PerlinAreaDeform.

Platform

Dev Tools Console messages after crash:

VERTEX_SHADER
cables.js:1011 [cgl_shader] bad line: `306:         norm=mod1930_calcNormal(mod1930_p.xyz,norm.xyz,tangent,bitangent);
`
cables.js:1011 [cgl_shader] bad line: `319:     tangent=mod1930_newTangent;
`
cables.js:1011 [cgl_shader] bad line: `320:     bitangent=mod1930_newBiTangent;
`
cables.js:12773 Shader error  Wireframe Material copy ERROR: 0:306: 'tangent' : undeclared identifier<br/>ERROR: 0:306: 'bitangent' : undeclared identifier<br/>ERROR: 0:306: 'mod1930_calcNormal' : no matching overloaded function found<br/>ERROR: 0:306: '=' : dimension mismatch<br/>ERROR: 0:306: 'assign' : cannot convert from 'const mediump float' to 'out highp 3-component vector of float'<br/>ERROR: 0:319: 'tangent' : undeclared identifier<br/>ERROR: 0:319: 'assign' : l-value required (can't modify a const)<br/>ERROR: 0:319: '=' : dimension mismatch<br/>ERROR: 0:319: 'assign' : cannot convert from 'highp 3-component vector of float' to 'const highp float'<br/>ERROR: 0:320: 'bitangent' : undeclared identifier<br/>ERROR: 0:320: 'assign' : l-value required (can't modify a const)<br/>ERROR: 0:320: '=' : dimension mismatch<br/>ERROR: 0:320: 'assign' : cannot convert from 'highp 3-component vector of float' to 'const highp float'<br/> ƒ (_cgl, _name, _op)
{
    if (!_cgl) throw new Error("shader constructed without cgl " + _name);

    this._log = new Logger("cgl_shader");
    this._cgl = _cgl;

    if (!_name) this._log.stack("no s…
cables.js:12448 shaderprogram validation failed...
cables.js:12449 Wireframe Material copy programinfo:  Program has not been successfully linked.

cables.js:993 [cgl_shader] ERROR: 0:306: 'tangent' : undeclared identifier
ERROR: 0:306: 'bitangent' : undeclared identifier
ERROR: 0:306: 'mod1930_calcNormal' : no matching overloaded function found
ERROR: 0:306: '=' : dimension mismatch
ERROR: 0:306: 'assign' : cannot convert from 'const mediump float' to 'out highp 3-component vector of float'
ERROR: 0:319: 'tangent' : undeclared identifier
ERROR: 0:319: 'assign' : l-value required (can't modify a const)
ERROR: 0:319: '=' : dimension mismatch
ERROR: 0:319: 'assign' : cannot convert from 'highp 3-component vector of float' to 'const highp float'
ERROR: 0:320: 'bitangent' : undeclared identifier
ERROR: 0:320: 'assign' : l-value required (can't modify a const)
ERROR: 0:320: '=' : dimension mismatch
ERROR: 0:320: 'assign' : cannot convert from 'highp 3-component vector of float' to 'const highp float'

warn @ cables.js:993
Shader._linkProgram @ cables.js:12460
Shader._createProgram @ cables.js:12405
Shader.compile @ cables.js:11773
Shader.bind @ cables.js:11808
Mesh.render @ cables.js:10067
render.onTriggered @ code:67852
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:73165
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
doRender @ code:71018
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:32681
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:52768
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
triggerAll @ code:107746
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render @ code:50912
Patch.emitOnAnimFrameEvent @ cables.js:15646
Patch.renderFrame @ cables.js:15659
Patch.exec @ cables.js:15706
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725Understand this warning
cables.js:982 [cgl_shader] Wireframe Material copy shader linking fail...
error @ cables.js:982
Shader._linkProgram @ cables.js:12462
Shader._createProgram @ cables.js:12405
Shader.compile @ cables.js:11773
Shader.bind @ cables.js:11808
Mesh.render @ cables.js:10067
render.onTriggered @ code:67852
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:73165
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
doRender @ code:71018
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:32681
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:52768
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
triggerAll @ code:107746
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render @ code:50912
Patch.emitOnAnimFrameEvent @ cables.js:15646
Patch.renderFrame @ cables.js:15659
Patch.exec @ cables.js:15706
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725Understand this error
cables.js:12464 Wireframe Material copy programinfo:  Program has not been successfully linked.

cables.js:12465 Shader {_log: Logger, _cgl: Context, _name: 'Wireframe Material copy', glslVersion: 300, _materialId: 11, …}
105WebGL: INVALID_OPERATION: getUniformLocation: program not linkedUnderstand this warning
15WebGL: INVALID_OPERATION: getAttribLocation: program not linkedUnderstand this warning
136WebGL: INVALID_OPERATION: useProgram: program not validUnderstand this warning
cables.js:11837 WebGL: too many errors, no more errors will be reported to the console for this context.
Shader.bind @ cables.js:11837
Mesh.render @ cables.js:10067
render.onTriggered @ code:67852
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:73165
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
doRender @ code:71018
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:32681
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render.onTriggered @ code:52768
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
triggerAll @ code:107746
Port._onTriggered @ cables.js:3242
Port.trigger @ cables.js:3009
render @ code:50912
Patch.emitOnAnimFrameEvent @ cables.js:15646
Patch.renderFrame @ cables.js:15659
Patch.exec @ cables.js:15706
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725
requestAnimationFrame
Patch.exec @ cables.js:15725Understand this warning