Search Unity

Any info or tutorials on what needs to be done to convert a custom shader to HDRP?

Discussion in 'High Definition Render Pipeline' started by MostHated, Nov 10, 2019.

  1. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Hey all,
    I have a custom shader from an asset but have unfortunately not heard anything back from the developer on getting it upgraded to work with SRP so I started working on doing it myself. It was hand-coded, so I can't just adjust it in Amplify or Shader graph, but I can just edit the shader itself. I have it somewhat working, but it's just not working properly. It's a blood shader that makes use of multiple textures, specular reflection, and some other things.

    I have not dealt with shaders much outside of making adjustments in Amplify such as just changing a few boxes to switch some of them to HDRP lit and things of that nature, so I am not exactly sure what all it might take to make it work *properly*. I would venture a guess that Amplify or Shader Graph don't have any sort of import/auto conversion for custom written shaders? At least not that I have come across.

    To get it working as I have currently I just went on github and tried to look at different shaders to see if I could spot similarities between them that look like adjustments I could make, but the majority of them I saw used HLSLPROGRAM / HLSLIMPORT and this one primarily uses CGPROGRAM and .cginc's. I did add "RenderPipeline" = "HDRenderPipeline", changed LightMode from ForwardBase to ForwardOnly and then removed some of the forwardbase definitions. It still says in the shader properties that SRP batch is not compatible but the shader itself is no longer showing the ErrorShader purple color and it renders in scene, but if there is any scene light it showed up as a blindingly white color instead of letting any of the red show.

    I was able to go in to all of the materials and if I adjusted their "Light Strength" property to 0 instead of the default 0.75 it was at, they are no longer blindingly white and the red shows, but I also had to go into the HDR color spots of each of them white was set to white and change it to a darker red otherwise when the texture would move around while the particle was playing it would end up having a bunch of white mix in.

    I tried making more changes based on different shaders I saw but the more I tried the farther I got from it working at all, either by simply not rendering anything or starting to throw different errors that were unfortunately just out of scope of my familiarity, such as having to do with vertex, fog coordinates, etc.

    All that being said, I realize I am a bit over my own head here but if anyone has perhaps any useful links or info they might be able to share I would greatly appreciate it!

    Thanks,
    -MH