Custom SRP 2.0.0 Render Graph
Version 2.0.0 of our custom SRP makes the switch to exclusively using the Render Graph API. This is just the first step, with minimal refactoring to rely on the API. Proper usage of it and better code separation will follow in the next versions.
Note that this, like all future releases, is both a project update and a tutorial. The tutorial introduces the render graph and contains all conversion steps while keeping our RP fully functional.
Comments (4)
I'm interested in a SRP manner for doing "Screen Space Vertex Manipulations" -- in other engines we use this technique for "In-Scene UI", to balance between "Size Decimation" vs. "Readability". So far in Unity, I haven't seen anyone show a way to manipulate vertices in Screen Space for SRP. We do it like this: For each Billboard, the Positions are the same.... then we use the UVCoordinate Vec2 data to specify the "Screen Space XY offset from the center Point"... so the vertex shader then calculates "Distance From Camera" + "Scaling Factor" -- to correctly calculate Screen Space Offset from the Center Point.. Now you don't have to do anymore Transform Rotations (to match Camera Forward), or scaling to keep it large enough. In a typical In-Scene UI, we might Decimate the SIZE by "Square-Root of Distance from Camera" -- such that objects 4x as far away are 1/2 as big (instead of 1/4 as big, which might be too small to read). Also, our vertex shader employs Clamping -- so that it can't get any larger than "MAX" size, nor ever get smaller than "MIN" size (if you choose to set these). Additionally, you can more easily manipulate Camera Z-Depth, to bias them to be on top of surrounding 3D meshes. Last we checked the SRP Shader Graph doesn't permit us to customize Vertex Clip-Space positions directly. That's the stopper for us, currently. ==== Currently we're using NovaUI for our UI (both HUD/Screen UI, and in-scene Labels) - and we're using the traditional model of "rotating transforms" and "Scaling to make readable" -- all in C# (when we'd rather do this in the vertex shader). Alternatively, we were considering Compute Shaders to get this same job (replacing C#), which should also work -- but seems, to me, less preferable than just doing it all inside the Vertex Shader.
That's all in the realm of shaders, independent of the rendering pipeline, no custom SRP required. Fundamentally this is a Shader Graph issue, specifically that Unity's master nodes only accept object space positions and don't allow any nonstandard functionality in that regard. You can do it as you want for HDRP/URP but you'd have to write a shader yourself instead of using Shader Graph. You could use the graph and edit its generated shader, but that's an awkward workflow. If your shader is simple just write it yourself.
I have a weird question for you... Have you heard of 4Dtoys.com by Marc ten Bosch? Besides playing with interactive 4D worlds, he has replaced the awkward 3D quaternion math with a generalizable nD one. For fun, he is creating 4D worlds in which to play. Scanning through your latest tutorial, I was wondering if we could apply Unity SRP features to building 4D (or higher) scenes with better UI controls. Users would have to bend their minds a bit ;) but this might result in a useful visualization tool, especially for the emerging AI analytics (where we are constantly smashing hundreds of dimensions into 2 or 3). https://marctenbosch.com/ndphysics/ https://marctenbosch.com/ndphysics/NDrigidbody.pdf https://dl.acm.org/action/downloadSupplement?doi=10.1145%2F3386569.3392483&file=a55-ten-bosch.mp4 5-min video, note UI controls on right
I know about it but am not into it. SRPs are really about data flow and computations, specialized for rendering but at a high level. It's tangential to how many dimensions you're working with, apart from which specific data flows you use and the data you pass around. The 4D stuff would be all in the shaders and custom matrices.
