Placeholder-Software / WetSurfaceDecals

14 stars 2 forks source link

HDRP Support #7

Open TomGillen opened 6 years ago

TomGillen commented 6 years ago

Wet Stuff currently does not support the High Definition Render Pipeline. There are a few issues that need to be resolved:

The final issue is the only major blocker here. Currently, the HDRP does not respect Camera.AddCommandBuffer, nor does it have its own equivalent API. We may need to submit our own PR to Unity to add this functionality ourselves. Alternatively, we may need to provide instructions for users on how to import the HDRP from source and make the modifications themselves, or fork the HDRP ourselves.

Forum thread regarding Camera.AddCommandBuffer: https://forum.unity.com/threads/hdrp-how-to-render-anything-custom.592093/

Updates

If you are interested in updates to HDRP support for Wet Stuff "Subscribe" to this issue. We'll post an update here as soon as there's some news!

Tanshaydar commented 5 years ago

May be a late update but what you're looking for is here:

https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/4317

It's already merged into 7.x

martindevans commented 5 years ago

Unfortunately that's not quite what we need (yet). The custom passes can only be injected into the pipeline at certain points and none of the currently supported points (Before Rendering, Before Transparent & Before PostProcess) are suitable for WetStuff - we need something after rendering to the GBuffer and before calculating reflections.

We talked to some Unity engineers at the Unite conference about this and they're not very keen on adding new points at the moment. Their view is that each new point in the pipeline reduces their future flexibility because they have to keep those points consistent - they couldn't rearrange the render pipeline without breaking passes injected at these points. They said that once HDRP is released fully stable they might consider adding more points.

Tanshaydar commented 5 years ago

I see, sorry then.

I really loved wet stuff plugin, and I want to use it in every project I have, but HDRP is a real dealbreaker at the moment. I hope it gets sorted out.

The link I provided solved a custom PP for my current project, so I thought it would solve it for wet stuff, too, but I should've considered the reflection pass too. I thought it just got it from reflection probe.

martindevans commented 5 years ago

Even if it's not quite what we needed, thanks very much for pointing it out to us! ❤️

danilofaugusto commented 4 years ago

Any plans to support URP?

martindevans commented 4 years ago

Unfortunately I don't think it's possible at the moment. The way that Wet Stuff works fundamentally requires a "Deferred" renderer, but URP is currently a "Forward" renderer.

According to the FAQ there are plans to support a deferred mode for URP. When that is released we might be able to support it (it depends on exactly how the deferred renderer is implemented, if we can access/modify the data needed to apply the effect).

danilofaugusto commented 4 years ago

Oh that's unfortunate. Thanks for the quick response :)

Hoxydev commented 4 years ago

2 years later still nothing on URP or HDRP .

RuchirRaj commented 4 years ago

Why isn't HDRP supported yet? it has a Deferred renderer and there is also an LTS version available

martindevans commented 4 years ago

Unfortunately it's not as simple as HDRP having a deferred renderer. The renderer also needs to store information in a way that's compatible with the effect and available for the effect to modify in an efficient way. For a long time HDRP didn't allow access to that data, we think that it does now but we still need to investigate in detail.

We have another asset coming out soon. Our plan is that when that's released we'll start working on investigating WetStuff:HDRP in detail.

StarChick971 commented 4 years ago

What about URP too? This is also a main blocker for most of new Unity projects...

martindevans commented 4 years ago

URP does support a deferred renderer, so in theory it's possible but the same caveat about efficient access still applies of course. We'll probably investigate URP support after looking into HDRP.

slacker-jake commented 3 years ago

Any chance this will ever be supported in URP and forward rendering?

martindevans commented 3 years ago

Unfortunately it almost certainly won't ever work with forward rendering - the way the effects works is by accessing and modifying the gbuffer (an important part of a deferred renderer). We'd have to come up with a completely new technique to work with a forward renderer.

Necka44 commented 3 years ago

Hi, URP 12.0 in Unity 2021.2 will support Deferred rendering (finally) - could that be the trigger to get an URP version of WetStuff ?

martindevans commented 3 years ago

We'll probably wait a while for it to stabilise (Wet Stuff fiddles around with some of the renderer internals which are generally not intended to be stable and can be broken by minor updates, so we need to wait a while to make sure we can provide good support). It's definitely something we'll like to investigate in the future though.

Since Deferred support in HDRP is much more mature than deferred support in URP I've created a separate issue to track URP support.

themars2011 commented 3 years ago

Are there any news on this? Really looking forward to it!

martindevans commented 3 years ago

Unfortunately there's bad news on this: @TomGillen did an investigation last month to work out feasbility and came to the conclusion that's still not possible to build Wet Stuff for HDRP. He came up with three different ways to implement the effect (each with some slightly different tradeoffs) and did a writeup on each different technique (and ultimately why it wouldn't work with the limitations of HDRP).

This means that there is no chance WetStuff:HDRP will be happening this year. There is a small chance it might become possible in the Unity 2022 release cycle (see the HDRP Decals section below), in which case we'll look into it again.

To summarise Tom's notes on the topic:

GBuffer Modification

This is how WetStuff works with the legacy renderer - directly reading and writing the data in the GBuffer. HDRP does not allow documented read/write access to the gbuffer. To quote this forum post:

we have no plan of exposing the GBuffer to users as it would lock our layout (we want to keep the possibility to re-arrange the GBuffer layout to our needs for optimizations or other purposes).

There are workarounds to get access to the GBuffer, but they could break at any time so we can't use that in an asset.

HDRP Decals

HDRP includes a fairly powerful decal system, this renders to a screen space buffer which is then blended into both deferred and forward materials later. This would actually be a huge improvement on WetStuff because it would apply to all materials (even forward rendered!).

However, WetStuff requires access to smoothness and metalness data (to correctly change the effect according to surface properties). HDRP does allow access to screen-space smoothness (through GetNormalBuffer), but there is no access to metalness. Based on comments from Unity developers responding to other people asking about this kind of thing there's a possibility that this will be available in the future, but not during the Unity 2021 cycle - at best it might be available in Unity 2022.

Shader Replacement (Shader Graph)

End users can modify HDRP built in shaders through shader graph. There are master nodes for all of the HDRP shaders (Lit, StackLit, etc) which allow you to plug in material properties and it does the rest. It would be quite simple to create our own Shader Graph block which applies the material modifications we need and plug that into these master nodes.

However, these master nodes require setting many of the shader's feature flags in the graph node settings; they are not exposed in the material settings when the shader is used. This means we would need a Shader Graph for every permutation of every feature flag (of which there are many), which is completely impractical.

Roland09 commented 3 years ago

Did you guys evaluate the option of using Better Shaders? Might be an alternative.

Hoxydev commented 3 years ago

For the people who are trying to do a wet effect with hdrp it seems that another package is available on unity HDRP - Wet Shaders and another guy made something call Better Lit Shader and both seems to do the same effect.

FYI I didn't try those yet.

Sry for WetSurfaceDecals but the purpose here is to find solution for endusers. Hope you will understand it.

martindevans commented 3 years ago

Wet Shaders and another guy made something call Better Lit Shader and both seems to do the same effect.

These don't do quite the same thing as Wet Stuff. Both of them require swapping out the material on an object to make the entire object look wet. This is kind of the opposite of Wet Stuff which allows you to place decals that make everything within the decal look wet (no matter what material it uses).

Both approaches have their advantages - for example it might make sense to make big things (e.g. roads) in your scene use Wet Shaders but then have a script that places dynamic splashes along the pavement when a car drives by (using Wet Stuff).

Did you guys evaluate the option of using Better Shaders?

We didn't, but I don't think we could depend on users buying a €71 to make our €15 asset work :(

slipster216 commented 3 years ago

For clarity, Better Shaders doesn't require the user to buy Better Shader to use the resulting shaders created with it. It can export to a single file which, at import time, becomes the shader for the installed pipeline (and SRP version), and thus acts like a universal shader that just works on all pipelines.

Roland09 commented 3 years ago

Did you guys evaluate the option of using Better Shaders?

We didn't, but I don't think we could depend on users buying a €71 to make our €15 asset work :(

I asked Jason to contribute since I'm not familiar with the technical details. All I can tell is that he was able to pull off what Unity couldn't: Create a unified shader for all render pipelines. It's an option that would also get you to URP. I love Wet Stuff and I'd really love to see it in other render pipelines.

martindevans commented 3 years ago

Better Shaders doesn't require the user to buy Better Shader

Oh that is interesting, I'll take a closer look at it. If that works then it might enable us to do option 3 (material replacement).

slipster216 commented 3 years ago

The nice thing you can do is write all of your wet shader stuff as a stackable- basically Better Shaders allows you to chain multiple shaders together kind of like a photoshop stack- then you could ship your replacement shader for HDRP, but include the stackable's source so anyone who wants to add support for your system can easily add it by stacking your code onto theirs (assuming they are writing their shaders with Better Shaders). Better Shaders has an example for puddles, which also does wetness, like this, and there are a bunch of integrations for shaders included as stackables (vegetation studio, bakery, etc). It makes it much easier for asset store authors to include each others stuff..

787992 commented 2 years ago

Any updates?

martindevans commented 2 years ago

Tom has spent the last couple of days investigating using Better Shaders to build a new version of Wet Stuff that's compatible with HDRP/URP, unfortunately it looks like it still doesn't solve all of the problems. The concept is good, but the base shaders are missing a number of features compared to the standard HDRP ones, so users of Wet Stuff would find themselves missing out on certain HDRP features (or we would have to re-implement e.g. our own base lit shader and keep it on par with HDRP/URP over time).

787992 commented 2 years ago

Tom has spent the last couple of days investigating using Better Shaders to build a new version of Wet Stuff that's compatible with HDRP/URP, unfortunately it looks like it still doesn't solve all of the problems. The concept is good, but the base shaders are missing a number of features compared to the standard HDRP ones, so users of Wet Stuff would find themselves missing out on certain HDRP features (or we would have to re-implement e.g. our own base lit shader and keep it on par with HDRP/URP over time).

Fingers crossed, this is the only wet solution that makes everything consistent and realistic

mblackritter commented 2 years ago

Fingers crossed, this is the only wet solution that makes everything consistent and realistic

True, true... [Having a Bud]! 😻 🥳🎉

slipster216 commented 2 years ago

Better Shaders is an authoring system, and supports all HDRP inputs- the examples are just examples- and are not trying to be a replacement for the HDRP shaders. But you can implement any feature of an HDRP shader in Better Shaders.

On Fri, May 27, 2022 at 2:40 PM Martin Evans @.***> wrote:

Tom has spent the last couple of days investigating using Better Shaders to build a new version of Wet Stuff that's compatible with HDRP/URP, unfortunately it looks like it still doesn't solve all of the problems. The concept is good, but the base shaders are missing a number of features compared to the standard HDRP ones, so users of Wet Stuff would find themselves missing out on certain HDRP features (or we would have to re-implement e.g. our own base lit shader and keep it on par with HDRP/URP over time).

— Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/WetSurfaceDecals/issues/7#issuecomment-1139932164, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAWC67O7UNOTXMFIOKIZG3VMEJI7ANCNFSM4FRHTZMA . You are receiving this because you commented.Message ID: @.***>

martindevans commented 2 years ago

The problem as I understand it (please do tell me if I'm wrong!) is that if we wanted to ship an asset that required using better shaders it would be easy - we'd just ship a wet stuff shader which could be added into any better shaders stack.

However, we don't want to require the end user owns better shaders! Instead we would have to precompile all of the shaders for the package, which would mean we would need a complete replacement shader for HDRP materials with all features included (which is a moving target and would probably require hundreds of variants compiled).

Tanshaydar commented 2 years ago

The problem as I understand it (please do tell me if I'm wrong!) is that if we wanted to ship an asset that required using better shaders it would be easy - we'd just ship a wet stuff shader which could be added into any better shaders stack.

However, we don't want to require the end user owns better shaders! Instead we would have to precompile all of the shaders for the package, which would mean we would need a complete replacement shader for HDRP materials with all features included (which is a moving target and would probably require hundreds of variants compiled).

Nope.

You just create a shader using Better Shaders stack. Then compile it against SRP, URP, and HDRP. You then release it as it is. No one needs to have Better Shader or Better Lit Shader for it to work. Example case: https://carloswilkes.com/Documentation/SpaceGraphicsToolkit#SRP

martindevans commented 2 years ago

I think SpaceGraphicsToolkit may actually be a good demonstration of the problem with a better shaders based approach.

With the way Wet Stuff works in the legacy renderer if you wanted to make the surface of a planet look wet you could do that easily - you render the planet with SGT materials and then WS tweaks the GBuffer to make it look wet, the two shaders are completely independent.

However, if we've published a set of shaders which include the wetness effect then you can either use the SGT planet shader or the WS replacement shader. Not being able to do the overlaid wetness in decals really make the system much less useful.

DieZone19 commented 2 years ago

Hi, Can't you just do wet stuff in HDRP in the custom passes? https://user-images.githubusercontent.com/6877923/195407733-1e73b63c-5ba6-488f-829d-d4cb0d0b1412.mp4

Screen Space Wetness from the HDRP Custom Pass. Can be seen at the bottom. https://github.com/alelievr/HDRP-Custom-Passes

I wonder if this would also be done with snow D;

martindevans commented 2 years ago

HDRP custom passes were an option we evaluated quite a while ago. I asked @TomGillen about why we couldn't use custom passes:

[Martin]: what was the reason we can't do that again? The wetness effect linked here is pretty good.

[TomGillen]: that effect only modifies normal and smoothness, whereas we also want to modify diffuse, which is a really important part of the effect for anything other than actual fully saturated puddles - and even then it won't look right on something like soil. [TomGillen]: It kinda works on metal and smooth plastic surfaces. [TomGillen]: We also can't read metalness, which greatly impacts how diffuse is modified. [TomGillen]: This effect would look entirely wrong on something like dirt, concrete, or cloth and we cant fix that as HDRP does not expose metalness or diffuse colour to custom passes. [TomGillen]: It does expose the final lit colour, which we could darken as an approximation for darkening the diffuse colour, but it won't look right (e.g. it will darken emissive, and specular highlights), and we would have to just pick either metal or dialectric to assume for the surface.

jackmartison commented 1 year ago

What do you think about this one? It's also made with custom passes https://www.youtube.com/watch?v=neZcIzEQDEQ

Rough explanation from author: "for the collision detection I created a standard orthograpic camera and used the custom renderer API so that only the depth are rendered into a singlechannel 128x128 render texture where each pixel is a half unit. Then I sampled this textures in a decal shader that compares the depth of the texture and the Z distance from the decal. A simple branch does the rest. To hide the hard edges i warped the uv with a simple noise. For the VFX I did the same... First sample the RT with the particle XZ position as UV, then set the collided particles to dead and created new particles for the drops on impact So almost everything is done on the GPU."

martindevans commented 1 year ago

That's a very cool way to generate the decal map! We considered something similar early on in the development of Wet Stuff but thought it would probably be too expensive and never prototyped it, I wish we had after seeing that video!

However generating the decal map is only the first stage in deciding what things in the scene are wet, after that you need to modify things to actually look wet. I would imagine this effect will probably have the same limitations as mentioned in my previous comment about custom passes - i.e. it will only look correct on some materials and not others because the relevant information isn't available in a custom pass.

Cap4lin commented 7 months ago

Tom has spent the last couple of days investigating using Better Shaders to build a new version of Wet Stuff that's compatible with HDRP/URP, unfortunately it looks like it still doesn't solve all of the problems. The concept is good, but the base shaders are missing a number of features compared to the standard HDRP ones, so users of Wet Stuff would find themselves missing out on certain HDRP features (or we would have to re-implement e.g. our own base lit shader and keep it on par with HDRP/URP over time).

I would really thankful for the URP compatible version, even if it's not that good. Please could you share that with us? I would happily pay for that on unity asset store.

martindevans commented 7 months ago

I'm afraid we've stopped working on URP and/or HDRP support. None of the things Tom prototyped ever quite solved the problem in a usable way :(

SwingLowSweetChariot commented 7 months ago

That's a pity, but it can't be helped. Perhaps if down the line I am working on a project that has the budget for it, I could try and commission a custom implementation from you guys. Something that wouldn't need to keep up with future versions of Unity. At the very least, I'd gladly pay just to access your expertise.