There is a problem with the relative reference directory of Shader Chunk

RunoseAI-3.8.3

Directory Structure

resources/

  • chunks
    • my_common.chunk
  • myShader
    • Demo1.effect

In Demo1.effect, referencing my_common.chunk will result in an error

#include "../chunks/my_common.chunk"


The error is as follows:
/Demo1.effect - my_common:vert: Error EFX2001: can not resolve ‘my_common’

The quoted chunk code is correct, the code is as follows:

precision highp float;
#include <cc-global>
#if USE_LOCAL
  #include <cc-local>
#endif

#if SAMPLE_FROM_RT
  #include <common/common-define>
  //老版本引用
  //#include <common>
#endif

in vec3 a_position;
in vec2 a_texCoord;
in vec4 a_color;
out vec4 i_color;
out vec2 uv0;
out vec2 uv1;
out vec3 v_position;

vec4 vert () {
  vec4 pos = vec4(a_position, 1);
  #if USE_LOCAL
    pos = cc_matWorld * pos;
  #endif
  #if USE_PIXEL_ALIGNMENT
    pos = cc_matView * pos;
    pos.xyz = floor(pos.xyz);
    pos = cc_matProj * pos;
  #else
    pos = cc_matViewProj * pos;
  #endif
  uv0 = a_texCoord;
  #if SAMPLE_FROM_RT
    uv1 = uv0;
    CC_HANDLE_RT_SAMPLE_FLIP(uv1);
  #endif
  i_color = a_color;
  return pos;
}

1 Like

If placed in the same directory, the reference is changed to

#include “my_common.chunk”

It’s back to normal, but this doesn’t allow chunk reuse

Delete the effect and re-import it.

I tried it, but it doesn’t
work. It still says path not found even when it crosses directories.
I suspect the path chunk is wrong when parsing it.

If the two directories are placed in the assets/ directory, it is normal.

Can only be placed in the root directory.

Are you from the engine group? Can the official website documentation be improved later?
Relative paths are only partially supported

Help, I thought I had been writing it wrong

If you look carefully, there is a chunk directory in the engine root directory. I guess the two directories will be merged when compiled, and the sizes must be the same. I also suffered this loss.

I changed the name but it didn’t work.
Relative path
It works fine in the first level directory under the assets/ directory.
It gives an error in a multi-level directory like assets/resources/shader/xxxx

My level doesn’t work either. I :joy:have to put it in asset/chunks or internal/chunks. What’s going on?