So, currently, I’m working on a PS1 inspired retro horror game set in space. During the Jam this project started in, I was using the standard Unity shader pipeline with a custom PS1 shader I found here:
Now that I’m developing the project out more though, I’ve decided to convert my project to utilize the HDRP lighting system. I’ve converted all the materials over, but I’m having a lot of issues when it comes to figuring out just how to take the code from the custom shaders I was using and translate that into the Shader Graph, or utilize a modified version of the code in a custom HDRP Shader. Does anyone know how I might go about recreating these effects? I’d at least like to try and apply some sort of Gouraud-based vertex lighting and texture stretching.
I know this question is somewhat vague, but any assistance would be appreciated, even if it’s just towards general shader knowledge that might be able to help me.
Basically impossible to do in HDRP. Shader Graph doesn’t let you control what you do in the vertex shader vs. the fragment shader, so all lighting calculations are done in the fragment shader. That means it’s not possible to do gouraud shading using Shader Graph. More to the point, HDRP’s entire lighting system is explicitly designed for per pixel lighting only. It’d be very difficult to get it to work per vertex at all even not using Shader Graph. Disabling perspective correction on texture sampling requires being able to modify the UV in the vertex shader, which also isn’t possible in Shader Graph.
About the only thing you should be able to do in Shader Graph is the vertex snapping. Though even that is fraught with problems. It should be possible to convert vertex positions to clip space, do the snapping, then convert back to object space (which is what the Shader Graph master node needs the vertex positions in). The problem is it seems like the inverse projection matrix (used to transform from clip space to view space) isn’t always set, and the inverse view projection matrix (for going from clip space to world space) is … wrong? Not really sure what’s going on there, but it’s definitely not doing the correct transform.
The closest you can get is to fake it by applying the vertex snapping in world space, but that’s a very loose approximation of the kind of visual artifacts the PSX had.
Not unexpected, to be honest. Since most elements aren’t possible with Shader Graph, could the effects I’m interested in be created using a custom HDRP shader instead? More importantly, how difficult, approximately, would it be to code?
The HDRP shaders are monstrously complex. The default lit shader’s properties list alone is longer than many shaders I use. And if you want to do per vertex lighting you have to use the forward pass which is one of the most complex passes it has. Figuring out how to wrangle that into something that does per vertex lighting, which as I mentioned before the HDRP was explicitly designed not to handle, would be quite the feat.
My question to you is … why the HDRP? If you’re going to replace all of the super complicated per pixel PBR shading with basic per vertex gouraud, what’s the point? The built in renderer is more than capable of doing this quite easily, or the URP has much more straightforward shaders to modify, Making a per vertex lit URP shader would be relatively easy and has some benefits over the built in rendering path. But using the HDRP for this is like getting yourself an expensive mobile phone and then taping it to the wall to use as a clock. Sure, it’d work, but it’s way overkill, inconvenient, and removing most of the reason to use it to begin with.
Honestly? The fog. Since I’m working on an atmospheric horror game, I wanted nice volumetric fog, and HDRP delivered on that. Now, there might be a better way to create this with URP, but HDRP is kind of just what I saw and landed on. If I can wrangle it into doing what I want, great, but if another solution would be easier while still retaining the effects I want, also great.
You might want to look at Aura 2, or even the free Aura or Vapor volumetric fog assets out there. Supposedly the URP is getting official volumetric fog support at some point too, though who knows when that’ll happen.
The HDRP’s fog does have a number of enhancements over any of the ones on the asset store, but those other options may serve your needs.
Thanks for the recommendations. I’ll keep looking into the HDRP shader code and see if maybe I can work something out, but it might be better overall to switch my pipeline over to Standard or URP.
So, I managed to get a VERY rough version of this working using a custom shader pass. However, unfortunately, the test object is rendering at a distance and I’m not really sure why.