galacean / engine

A typescript interactive engine, support 2D, 3D, animation, physics, built on WebGL and glTF.
https://galacean.antgroup.com/
MIT License
4.05k stars 289 forks source link

Fix compiling error introduced by preprocessor #2028

Closed Sway007 closed 4 months ago

Sway007 commented 4 months ago

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  1. Fix compiling to GLSL error when exist global function contained in a macro and the function implementation include varying struct property access
  2. Fix compiling to GLSL error when #define macro exist in #ifdef macro body, like the snippet below

    ......
    #ifdef xxx
      mediump sampler2DShadow scene_ShadowMap;
      #define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)
      #define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap
    #endif
    
    float sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap), vec3 shadowCoord, vec4 shadowMapSize) {
    ......
  3. Fix macro extend error due to preprocessor not ignoring comments