Wednesday, August 11, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


The node environment executes the rendering test and reports an error: unexpected token after conditional expression

Posted: 11 Aug 2021 08:48 AM PDT

AssertionError [ERR_ASSERTION]: ERROR: 0:29: 'M_NUM_VIDEOS' : unexpected token after conditional expression   ERROR: 0:37: 'M_NUM_VIDEOS' : unexpected token after conditional expression   

I wrote a source shader and defined some methods and macro definitions. I spliced the macro definitions through javascript code and integrated them with other shader code fragments (actually, the splicing of strings), but when I was in When performing a rendering test in a node environment, it will tell me an error. It feels like I did not define the M_NUM_VIDEOS variable, but I defined it and also passed gl

Below is my JavaScript code for stitching several shaders:

// NUM_VIDEOS is included in macros  const defines = configuration.defines().concat(this._setMicroDefines(macros));    const fragmentSource = defines.concat(shaders.prelude.fragmentSource,shaders.unpackAll.fragmentSource, source.fragmentSource).join("\n");    ...    const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);  gl.shaderSource(fragmentShader, fragmentSource);  gl.compileShader(fragmentShader);  assert(gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS), (gl.getShaderInfoLog(fragmentShader): any));  gl.attachShader(this.program, fragmentShader);      ...    _setMicroDefines(macros: GLSL_MACRO_DEFINITIONS & GLOBAL_MACRO_DEFINITION) {          let microStr = "";          for (const key in macros) {              if (typeof macros[key] === "boolean") {                  if (macros[key]) {                      microStr += `#define M_${key} \n`;                  }              } else {                  microStr += `#define M_${key} ${macros[key]} \n`;              }          }            return microStr;      }  

Below is my glsl code:

#pragma glslify: encodeFloat = require(../function/math/encode-float.glsl)  #pragma glslify: decodeFloat = require(../function/math/decode-float.glsl)  #pragma glslify: getBlinnPhongColor = require(../function/light/blinn-phong-color.glsl)    uniform float u_fade_t;  uniform float u_opacity;  uniform sampler2D u_image0;  uniform sampler2D u_image1;    ...    #if M_NUM_VIDEOS > 0  uniform highp mat4 u_VIDEOMATCH_MVPMATRIX[M_NUM_VIDEOS];  uniform bool u_HAS_VIDEOMATCHMAP[M_NUM_VIDEOS];  uniform float u_Alpha[M_NUM_VIDEOS];  uniform highp sampler2D u_VideoSampler[M_NUM_VIDEOS];  uniform bool u_active_clip_videoTexture[M_NUM_VIDEOS];  uniform vec3 u_clipColors[M_NUM_VIDEOS];  

No comments:

Post a Comment