thanks for your reply.
My project doesnt mapp the texture, i want to display the distorted texture (outpuiting to a projection system mapped onto a physical 'real ’ sphere). Here is my attempt of porting to HDRP so far, somehow seems mixed with the current display (see images below), what am I missing?
Shader "FullScreen/NewFullScreenCustomPass"
{
Properties{
_Color("Color", Color) = (1,1,1,1)
}
HLSLINCLUDE
#pragma vertex Vert
//#pragma vertex vert
#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl"
// The PositionInputs struct allow you to retrieve a lot of useful information for your fullScreenShader:
// struct PositionInputs
//{
// float3 positionWS; // World space position (could be camera-relative)
// float2 positionNDC; // Normalized screen coordinates within the viewport : [0, 1) (with the half-pixel offset)
// uint2 positionSS; // Screen space pixel coordinates : [0, NumPixels)
// uint2 tileCoord; // Screen tile coordinates : [0, NumTiles)
// float deviceDepth; // Depth from the depth buffer : [0, 1] (typically reversed)
// float linearDepth; // View space Z coordinate : [Near, Far]
// };
// To sample custom buffers, you have access to these functions:
// But be careful, on most platforms you can't sample to the bound color buffer. It means that you
// can't use the SampleCustomColor when the pass color buffer is set to custom (and same for camera the buffer).
// float4 SampleCustomColor(float2 uv);
// float4 LoadCustomColor(uint2 pixelCoords);
// float LoadCustomDepth(uint2 pixelCoords);
// float SampleCustomDepth(float2 uv);
// There are also a lot of utility function you can use inside Common.hlsl and Color.hlsl,
// you can check them out in the source code of the core SRP package.
float4 _Color;
float M_PI = 3.141592654f;
// sampler2D _MainTex;
// TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
float4 _MainTex_ST;
float4 FullScreenPass(Varyings varyings) : SV_Target
// fixed4 FullScreenPass(Varyings varyings) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(varyings);
float depth = LoadCameraDepth(varyings.positionCS.xy);
PositionInputs posInput = GetPositionInput(varyings.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
float2 uv = posInput.positionNDC.xy * _RTHandleScale.xy;
float theta = (uv.x*2 + 1) * 3.141592654;
//float theta = (varyings.positionCS.x*2 + 1) * 3.141592654;
float phi = (-(uv.y * 2 - 1) * 3.141592654) / 2;
// float phi = (-(varyings.positionCS.y * 2 - 1) * 3.141592654) / 2;
float x = cos(phi) * sin(theta);
float y = sin(phi);
float z = cos(phi) * cos(theta);
float scale;
float2 px;
float2 offset;
// float3 viewDirection = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
float4 colortest = float4(posInput.positionNDC.x, posInput.positionNDC.y, posInput.positionNDC.x, 0.9);
float c = float4(0,0,0,1);
// Load the camera color buffer at the mip 0 if we're not at the before rendering injection point
// if (_CustomPassInjectionPoint != CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING)
// float4 color = float4(CustomPassLoadCameraColor(varyings.positionCS.xy, 0), 1);
// Pull from each of the 6 textures based on the phi/theta pair
if (abs(x) >= abs(y) && abs(x) >= abs(z))
{
if (x < 0)
{
scale = -1.0 / x;
px.x = (z * scale + 1.0) / 2.0f;
px.y = (y * scale + 1.0) / 2.0f;
// Left
// colortest = float4 ( 0.9, 0.0, 0.9 ,0.0);
// return float4 ( 0.8, 0.5, 0.9 ,1.0);
// return tex2D(_MainTex, float2(px.x / 4, 1 - ((px.y + 1) / 3 )));
// float4 c = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, float2(px.x / 4, 1 - ((px.y + 1) / 3 )));
// colortest = c;
// return float4(c.rgb, 0.5);
c = tex2Dlod (sampler_MainTex, float4(px.x / 4, 1 - ((px.y + 1) / 3 ), 0,1));
return c;
//return Texture2D(_MainTex, float2(px.x / 4, 1 - ((px.y + 1) / 3 )));
}
else
{
scale = 1.0 / x;
px.x = (-z * scale + 1.0) / 2.0f;
px.y = (y * scale + 1.0) / 2.0f;
offset.x = 2;
offset.y = 1;
// Right
colortest = float4 ( 0.5, 0.5, 0.5 ,0.5);
c = tex2Dlod (sampler_MainTex, float4(px.x / 4 + .5f, 1 - ((px.y + 1) / 3), 0, 1));
return c;
// return tex2D(_MainTex, float2(px.x / 4 + .5f, 1 - ((px.y + 1) / 3)));
}
}
else if (abs(y) >= abs(z))
{
if (y < 0)
{
scale = -1.0f / y;
px.x = (x * scale + 1.0) / 2.0f;
px.y = (z * scale + 1.0) / 2.0f;
// Top
colortest = float4 ( 0.0, 0.9, 0.0 ,0.5);
c = tex2Dlod (sampler_MainTex, float4(px.x / 4 + .25f, 1 - (px.y / 3), 0,1));
return c;
// return tex2D(_MainTex, float2(px.x / 4 + .25f, 1 - (px.y / 3)));
}
else
{
scale = 1.0 / y;
px.x = (x * scale + 1.0) / 2.0f;
px.y =1 - (-z * scale + 1.0) / 2.0f;
// Bottom
colortest = float4 ( 0.9, 0.2, 0.2 ,0.5);
c = tex2Dlod (sampler_MainTex, float4(px.x / 4 + .25f, (px.y / 3), 0,1));
return c;
// return tex2D(_MainTex, float2(px.x / 4 + .25f, px.y / 3));
}
}
else
{
if (z < 0)
{
scale = -1.0 / z;
px.x = (-x * scale + 1.0) / 2.0f;
px.y = (y * scale + 1.0) / 2.0f;
// Back
colortest = float4 ( 0.5, 0.8, 0.5 ,0.5);
c = tex2Dlod (sampler_MainTex, float4(px.x / 4 + .75f, 1 - ((px.y + 1) / 3 ), 0, 1));
c= float4
return c;
//return tex2D(_MainTex, float2(px.x / 4 + .75f, 1 - ((px.y + 1) / 3 )));
}
else
{
scale = 1.0 / z;
px.x = (x * scale + 1.0) / 2.0f;
px.y = (y * scale + 1.0) / 2.0f;
// Front
colortest = float4 ( 0.2, 0.0, 0.5 ,0.5);
c = tex2Dlod (sampler_MainTex, float4(px.x / 4 + .25f, 1 - ((px.y + 1) / 3), 0, 1));
return c;
// return tex2D(_MainTex, float2(px.x / 4 + .25f, 1 - ((px.y + 1) / 3)));
}
}
// Should never come here
// Fade value allow you to increase the strength of the effect while the camera gets closer to the custom pass volume
return float4 ( colortest.rgb ,_Color.a);
}
ENDHLSL
SubShader
{
Pass
{
Name "Custom Pass 0"
ZWrite Off
ZTest LEqual//Always
Blend SrcAlpha OneMinusSrcAlpha
Cull Off //Front
HLSLPROGRAM
#pragma fragment FullScreenPass
ENDHLSL
}
}
Fallback Off
}

