I'm working on a project in which players mix transparent colored meshes together in the RGB sense. Here's a screenshot: What you see here are red and green pillars mixing to form yellow as planned. On the left are the settings for the red and green materials using the standard shader as Transparent. Unfortunately, the colors that don't intersect still add to each other, as shown here. The blue and red meshes do not physically intersect, but look like they do. This causes a lot of confusion for players. Is there a way to make a shader that builds on the standard settings but allows only for intersecting objects to provide additive color? P.S. I'd also like to add functionality that lets you see the material while the camera is inside of the mesh.
Maybe use two cameras? Have all the mixing done using a separate camera to a render texture, then you can blend that texture with the rest of your scene using a different form of (non additive) transparency.
This is a non-trivial task. Knowing if two transparent meshes are intersecting alone is basically impossible. This requires true transparency sorting using an a buffer or linked list rendering, neither of which are supported out of the box by Unity (and may not even be plausible to implement within the existing confines of Unity’s c# graphics APIs). The only real option is to use in shader raytracing/raymarching and analytical shapes so you just draw all of the transparent objects as a full screen image effect.
https://iquilezles.org/www/articles/distfunctions/distfunctions.htm https://github.com/hecomi/uRaymarching