Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Unity includes a tool for baking SDF textures: 🧊 I made this experimental shader for fully volumetric glass shaped to any object using a 3D distance texture. Handles layered self-refraction in a single pass (look at the ears, when the model is rotated), + explicit backface rendering via another...

65,365 Aufrufe • vor 2 Monaten •via X (Twitter)

0 Kommentare

Keine Kommentare verfügbar

Kommentare vom Original-Post werden hier angezeigt

Ähnliche Videos

Great question! 🤔 How do you simulate *multiple* layers of glass/refraction in video games? In the last breakdown, I discussed how to create a glass shader in Unity URP. In essence, we were taking the render of the scene from the camera without any transparent objects. This is available in URP as the global _CameraOpaqueTexture. This is good enough for most use-cases, and more or less the classic way of doing it. 🔍 What is _CameraOpaqueTexture? As the name implies, there are no transparent objects rendered into this texture, so it's not possible by default to have something like a transparent-type ocean material/shader rendered through a refractive glass shader (which samples and distorts this texture to render on its surface, as if it's transparent). ⚠️ Why it’s tricky: It's much easier to sort without much further setup if you don't have refraction, and only a transparent material, because in that case you're not simulating the transparency yourself via sampling the rendered scene texture. But for refraction, it's required-- unless you want to go down the ray/path tracing route. You could simulate accurate, real dispersion... and that's about as expensive as it sounds, and it requires a rework of your entire rendering. --> 🚫 It's not a viable suggestion to offer. 📚 There are well-known terms regarding transparency sorting you can search up, but as you've specifically asked for refractive boxes, I'll discuss briefly about that. 🧱 Simulating layers of refraction: For this kind of rendering, you need some way to render the backfaces before rendering the front. And the backfaces that are rendered may contain whatever data you'd like for additional processing in the layer front-facing mesh render. 🧪 Examples: You could render the back face as a glass shader of its own, as an intermediate step after _CameraOpaqueTexture. Then you sample this texture instead and you end up with multi-layered refraction, "just like that". You can also render the back normals only, via a fully opaque shader, and use that to manually account for that during the front render. You could even bake in data needed for thickness in realtime. 🛠️ Without making it complicated for yourself, the most straightforward method is via render textures, and you can easily set some fractional resolution. Cameras in Unity have an open slot for target textures to render to. You can use custom render textures to process _SelfTexture2D. ⏱️ It's great to do low-resolution processing for more complex tasks, like blurring and caustics. You can get massive performance boosts, considering the square law and number of pixels/fragments that need calculations (quadratic scaling). 🚧 I've not fully exploited the possibilities myself, but research/development with PRISM is ongoing!

Mirza Beig

51,429 Aufrufe • vor 10 Monaten