Converting volumeric shader to LWRP

Hi all, I’m currently facing some problems trying to convert my volumeric shader to LWRP. My shader reads in a 3D texture as a .asset file that is pre-generated by reading in pixels from a series of dicom files and uses raymarching to sample and render what I need.

Below is an image of the supposed effect after moving out from UnityCG.cginc into Core.hlsl
The left side of the picture shows the volume without the custom render pipeline applied.
The volume is totally not rendered in the LWRP.

Note: I’m currently using 2019.1.0f2
4458730--409201--raymarching.png

Some snippets of the code

SubShader{
            Tags { "RenderType" = "Transparent" }
            LOD 200
            Blend One OneMinusSrcAlpha // Premultiplied transparency
            ZWrite Off
            Pass
            {
                HLSLPROGRAM
                #pragma prefer_hlslcc gles
                #pragma vertex vert
                #pragma fragment frag
           
                 #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl"

                v2f vert(appdata v)
                {
                    v2f o;
                    o.local = v.vertex;
                    o.vertex = mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorld, v.vertex));
                    //o.vertex = UnityObjectToClipPos(v.vertex);
                    o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
                    o.screenPos = ComputeGrabScreenPos(o.vertex);
                    return o;
                }

    half4 frag(v2f i) : SV_Target
     {    
         float4 outColor = float4(0.0,0.0,0.0,1.0);
          float eyeDepth = LinearEyeDepth(tex2Dproj(_CameraDepthTexture, i.screenPos), _ZBufferParams);
          //other variables  here. Most of the functions used here are not from UnityCG.cginc

           [loop]
           for (int i = 0; i < iterations; i++)
           {
               //raymarching operations are done here to modify outColor ... 
 
            }

         
           return outColor;
     }
ENDHLSL
}

Most of the functions were substituted with the ones from common.HLSL with the exception of the following functions from UnityCG.cginc where i redefined them because I couldnt find the appropriate substitute.

                inline float4 ComputeGrabScreenPos(float4 pos)
                {
                    #if UNITY_UV_STARTS_AT_TOP
                    float scale = -1.0;
                    #else
                    float scale = 1.0;
                    #endif
                    float4 o = pos * 0.5f;
                    o.xy = float2(o.x, o.y*scale) + o.w;
                    #ifdef UNITY_SINGLE_PASS_STEREO
                    o.xy = TransformStereoScreenSpaceTex(o.xy, pos.w);
                    #endif
                    o.zw = pos.zw;
                    return o;
                }
                // Computes object space view direction
                inline float3 ObjSpaceViewDir(in float4 v)
                {
                    float3 objSpaceCameraPos = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos.xyz, 1)).xyz;
                    return objSpaceCameraPos - v.xyz;
                }
                // Tranforms position from object to camera space
                inline float3 UnityObjectToViewPos(in float3 pos)
                {
                    return mul(UNITY_MATRIX_V, mul(unity_ObjectToWorld, float4(pos, 1.0))).xyz;
                }

Some of the things I’ve done to attempt to convert the shader.

  1. I’ve tested the rendering of a simple 3D texture without raymarching and it renders fine in LWRP.
  2. All CGProgram and functions replaced with HLSLProgram
  3. I also tried to do this in shadergraph but I’m not sure how to go about implementing a custom node for n iteration raymarching,

I would appreciate it if some of the shader experts would enlighten me on this subject as I’m still new to LWRP. Thanks!

I forgot to include

 Tags{ "RenderPipeline" = "LightweightPipeline" }

now its working! Thanks for viewing.