0beqz / realism-effects

SSGI, Motion Blur, TRAA - Effects to enhance your three.js scene's realism
https://realism-effects-obeqz.vercel.app/
MIT License
1.4k stars 61 forks source link

getting uvundefined and constructor errors #44

Open pranavmalikk opened 4 months ago

pranavmalikk commented 4 months ago

I get a couple of errors when i'm calling SSGI in the latest version of the repo. I built this myself since npm was a little behind. I also tested this on the older npm version and i get the same errors. I'm using a couple gltf's and a boxGeometry. I thought this had to do with uv's but it seems boxGeometry has accurate uv's so that can't be the issue. And my GLTF's rendered fine in the previous version but now they don't render at all with the updated build.

THREE.WebGLProgram: Shader Error 0 - VALIDATE_STATUS false

Material Name: undefined
Material Type: MeshPhysicalMaterial

Program Info Log: Vertex shader is not compiled.

VERTEX

ERROR: 0:400: 'uvundefined' : undeclared identifier
ERROR: 0:400: 'constructor' : not enough data provided for construction

  395: void main() {
  396: #if defined( USE_UV ) || defined( USE_ANISOTROPY )
  397:  vUv = vec3( uv, 1 ).xy;
  398: #endif
  399: #ifdef USE_MAP
> 400:  vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  401: #endif
  402: #ifdef USE_ALPHAMAP
  403:  vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  404: #endif
  405: #ifdef USE_LIGHTMAP
  406:  vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;

I tried these configurations

Latest Github Repo build:

<postEffectsComposer ref={composerRef} args={[gl]}>
        <postRenderPass args={[scene, camera]} attach={(parent, self) => parent.addPass(self)} />
        <velocityDepthNormalPass
          ref={velocityDepthNormalPassRef}
          args={[scene, camera]}
          attach={(parent, self) => parent.addPass(self)}
        />
        {velocityDepthNormalPassRef.current && composerRef.current && (
          <postEffectPass
            args={[camera, new SSGIEffect(composerRef.current, scene, camera, velocityDepthNormalPassRef.current)]}
            attach={(parent, self) => parent.addPass(self)}
          />
        )}

Previous NPM install 1.1.2:

<postEffectsComposer ref={composerRef} args={[gl]}>
      <postRenderPass args={[scene, camera]} attach={(parent, self) => parent.addPass(self)} />
      <velocityDepthNormalPass
        ref={velocityDepthNormalPassRef}
        args={[scene, camera]}
        attach={(parent, self) => parent.addPass(self)}
      />
      {velocityDepthNormalPassRef.current && (
        <postEffectPass
          args={[camera, new SSGIEffect(scene, camera, velocityDepthNormalPassRef.current)]}
          attach={(parent, self) => parent.addPass(self)}
        />
      )}
  )

One thing i want to note is that i'm able to successfully utilize the following:

{velocityDepthNormalPassRef.current && composerRef.current && (
          <postEffectPass
            args={[
              camera,
              // new HBAOEffect(composerRef.current, camera, scene),
              new MotionBlurEffect(velocityDepthNormalPassRef.current),
              new SharpnessEffect(0.5),
              // new TRAAEffect(scene, camera, velocityDepthNormalPassRef.current),
              (() => {
                const effect = new SMAAEffect({
                  preset: SMAAPreset.MEDIUM,
                  edgeDetectionMode: EdgeDetectionMode.COLOR,
                  predicationMode: PredicationMode.DEPTH,
                });
                if (effect.edgeDetectionMaterial) {
                  const edgeDetectionMaterial = effect.edgeDetectionMaterial;
                  edgeDetectionMaterial.edgeDetectionThreshold = 0.02;
                  edgeDetectionMaterial.predicationThreshold = 0.002;
                  edgeDetectionMaterial.predicationScale = 1;
                }
                return effect;
              })(),
            ]}
            attach={(parent, self) => {
              parent.addPass(self);
              return () => {
              };
            }}
          />
        )}

specifically MotionBlur and SharpnessEffect

pranavmalikk commented 4 months ago

i've tried multiple solutions, but none seem to work. For some reason i'm able to do processes like HBAOEffect, MotionBlurEffect, TRAAEffect. Just the SSGI is giving me the above error. I've tried reworking the threejs libraries to get the right versioning, tried multiple different rendering codes, and pretty much everything available but it doesn't work. It states my error is here:

useFrame((state, delta) => { gl.autoClear = true; composerRef.current?.render(delta); }, 1);

specifically on composerRef.current?.render(delta); but it's strange that the code works perfectly with the other post processing just not ssgi