Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Adding a vertex shader "prepass" to every object in-scene

Discussion in 'Universal Render Pipeline' started by a52, Sep 16, 2023.

  1. a52

    a52

    Joined:
    Mar 15, 2018
    Posts:
    16
    I'm interested in (roughly) emulating the look of older 3d games, where vertices stuttered around to fixed gridpoints (this was especially famous and prevalent on the PS1).

    Is it possible to perform some kind of universal vertex->vertex shader on all objects in the scene, after they're transformed to camera space but before they're transformed to screen-space, using the URP? I know you can do post-processing on the final image, so I'm wondering if there's some kind of preprocessing I can do that affects vertices instead of pixels. I'm familiar with writing shaders, but I don't know how the pipeline stuff works and what it can do.

    Or is my best bet just to make a custom shader that does this and make sure all my materials in my scene use it?
     
  2. a52

    a52

    Joined:
    Mar 15, 2018
    Posts:
    16
    Short update:

    It looks like most transforms in the URP are handled through
    ShaderLibrary/ShaderVariablesFunctions.hlsl/GetVertexPositionInputs()
    . So if you overwrote that (or the TransformXtoY functions it uses), you could quickly but hackily modify how every shader performs its vertex pass.

    However, Unity (sensibly) detects the change and reinstalls the package, reverting it.

    Furthermore, this would also affect the LightMap pass shaders, which probably shouldn't be given any vertex jitter.

    Hmm...
     
  3. a52

    a52

    Joined:
    Mar 15, 2018
    Posts:
    16
    Alright, looks like this is impossible, going to just download somebody else's shader and use it for all my materials.