Comments (6)
Yes this is a common problem with refract surfaces like water. I brainstormed some "solutions" below, but i dont think any of them are perfect..
Solution A: Render your transparents as opaque..!? Sounds dumb but maybe with it can be faked to look transparent or something!
Solution B: Render using alpha test - if this helps at all?
Solution C: If you're using TAA, you might be able to go full stochastic transparency - render as alpha test and randomly accept or reject pixels using a noise function and the desired alpha as the probability. I'd be surprised if this can work really well but its possible i guess..
Solution D: Refuse to accept that alpha does not work and strong arm it into submission:
- Render your alpha towards the end of the opaque pass (!) - perhaps queue 2450 or something (so Geometry+450). EDIT: as i've just discovered the hard way, Renderer.sortingOrder takes priority over the queue setting it seems, so additionally you'll need to see the sortingOrder to less than say -16, to render before any ocean lods.
- When it blends onto the background it will need to fake depth fog between itself and the opaque surface behind. So if it is 5m above the sea floor, it should compute scattering using the same technique as the ocean shader, using the same density values. This will give an alpha value and colour which it should be able to incorporate into its final colour, so it will appear to have water behind it when it blends onto the opaque geom. The problem is knowing how far you are from the sea floor - perhaps that can be fed to the shader using raycasts etc. Or perhaps you know your stuff will always be some distance from a relatively flat sea floor. I'm sure this step 2 is very confusing - you might experiment with faking stuff/tweaking by hand before going full math and trying to get all of this working.
- The shader needs to write depth (turn ZWrite On). The ocean will use this depth later to do refraction and depth fog/scattering for water in front of the alpha surface.
- Hope that two jellyfish do not overlap! This does not support overlapping surfaces.
This is not a robust, general solution, but could get your across the line for specific cases.
Solution E: Turn on MSAA and use alpha to coverage. I have never used alpha to coverage so I'd need to refer you to google.
Out of all the above, i think E is the only once i really believe in, but it relies on MSAA and i've never used it in practice so i cant speak to the trade offs..
What do you think? If others have ideas please add them!
from crest.
( @Midda-C - probably of interest )
from crest.
Yeah, we did notice this limitation early on, but pretty much wrote it off as a thing we'd need to live with. I don't think we'll need to display any transparent objects under water (the one thing we were we simply changed to dithered alphatest which looks better for us anyway). Solution C is interesting, though. I have wondered how using a simple bluenoise flipbook might look (not for this issue specifically, just for avoiding transparency in general). Unrelated, but I should play with that some more. :)
from crest.
Ha option C, i like it! If you do happen to experiment with this there are some GPU-friendly noise functions that might be useful for quick experiments. https://twitter.com/stormoid/status/1021397559699558401
And of course it would be very interesting to discuss any results!
from crest.
Will need to play with opt C. Right now we are doing dithering when spawning stuff or despawning things like fish where the dither into and out of existence. Works really well but have not tried it with something like persistent alpha objects like jelly or bottles.
from crest.
I think I will close this - for now - as I don't think much will be done from my side for now or in the near future, although I'll definitely keep it in mind and return to it if I have thoughts or if I see something that could be of use.
I would of course be very happy to hear any experiences you guys have if you try this stuff out, please do post back if you do.
from crest.
Related Issues (20)
- Boat Physics - Adding colliders and player to boat causing big issues HOT 1
- Problems when rendering HOT 1
- Shader broken on 2022.2.4 on Metal HOT 5
- URP reflection error when using two cameras after build. HOT 3
- Updating ShapeFFT parameters runtime, generates a lot of garbage HOT 5
- HDRP underwater volumetric lights not working properly HOT 2
- Local / movable spectrums or crest shapes HOT 3
- Foam / wake vibration when approaching whirlpools HOT 20
- Pressing the Windows Key in the editor disables underwater rendering HOT 3
- Wake / foam artifacts when moving the camera quickly HOT 11
- Delayed LOD / tile enabling when using large clipping areas HOT 5
- Depth Cache not populated - Exported Image is Black HOT 8
- Water interaction is not visible when moving camera away from the sea level HOT 1
- Underwater broken with XR multi-pass rendering HOT 1
- No caustics, no shadow data and/or constant shadowing on iOS
- Error of Does not exist some Classes. HOT 1
- Sporadic gaps / precision errors in tiles. HOT 35
- SphereWaterInteraction and RegisterDynamicWavesInput do not work correctly inside a flow area HOT 11
- Activating flow in the material when oceanrenderer is running does only work in editor HOT 2
- FindObjectsSortMode HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crest.