Custom vertex attributes in chunk

Sure.

I have an effect which adds one more component to vertex semantic. I set this to UV coords of screen space.

Then I patch getAlbedo method in FS.
I use this coords to sample2D from current render buffer.

 this.material.chunks.startVS = [
        "attribute vec2 vertex_screenCoords; ",
        "varying vec2 vVertex_screenCoords; ",
        "void main(void) { ",
        "   gl_Position = getPosition();",
        "   vVertex_screenCoords = vertex_screenCoords;",
    ].join("\n");
    
    this.material.chunks.diffusePS = [
        "#ifdef MAPCOLOR",
        "uniform vec3 material_diffuse;",
        "#endif",
        "#ifdef MAPTEXTURE",
        "uniform sampler2D texture_diffuseMap;",
        "varying vec2 vVertex_screenCoords;",
        "uniform sampler2D texture_refractMap;",
        "uniform sampler2D texture_screenMap;",
        "uniform float uInvisiblePower;",
        "#endif",
        "void getAlbedo() {",
        "    dAlbedo = vec3(1.0);",
        "    #ifdef MAPCOLOR",
        "        dAlbedo *= material_diffuse.rgb;",
        "    #endif",
        "    #ifdef MAPTEXTURE",
        "   float refractHeight = texture2D(texture_refractMap, vUv0).r;",
        "   if (refractHeight > uInvisiblePower) ",
        "        dAlbedo *= texture2DSRGB(texture_diffuseMap, vUv0).rgb;",
        "   else",
        "        dAlbedo *= texture2DSRGB(texture_screenMap, vVertex_screenCoords).rgb;",
        "    #endif",
        "    #ifdef MAPVERTEX",
        "        dAlbedo *= gammaCorrectInput(saturate(vVertexColor.$VC));",
        "    #endif",
        "}"
    ].join("\n");
    

So I have a nice effect of invisibility.

I had to patch standard program in order to set custom attributes

this.app.graphicsDevice.programLib.unregister("standard")
this.app.graphicsDevice.programLib.register("standard", pc.programlib.standardFixed);