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.41k stars 63 forks source link

SSGI Instacned & GPUComputationRenderer support #45

Open momentchan opened 5 months ago

momentchan commented 5 months ago

I used GPUComputationRenderer to compute the position and velocity for particles and save them as texture, and pass them to instancedMesh for rendering.

<instancedMesh>
       <boxGeometry args={[0.2, 0.2, 0.6]}>
               <instancedBufferAttribute attach="attributes-uvs" args={[uvs, 3]} />
        </boxGeometry>
        <ThreeCustomShaderMaterial/>
</instancedMesh>

In the vertex shader of the material for instancedMesh, I did something like this:

 void main() {
         vec3 pos = texture2D(positionTex, uvs.xy).xyz;
         csm_PositionRaw =  projectionMatrix * modelViewMatrix * vec4( position + pos, 1.0 );
},

When I apply the SSGI, all particles become bunch of boxes in the origin, and the positions I modified with the positionTex are not correctly reflected. Is it some kind of the limit of SSGI?

螢幕擷取畫面 2024-04-13 153801 螢幕擷取畫面 2024-04-13 153920