Skip to content

Commit 8e2008d

Browse files
committed
Fix URP shaders
1 parent acd6617 commit 8e2008d

7 files changed

+36
-76
lines changed

Assets/Shaders/URP/CrossSectionPlane.shader

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
}
77
SubShader
88
{
9-
PackageRequirements
10-
{
11-
"com.unity.render-pipelines.universal":"[10.0,10.5.3]"
12-
}
13-
149
Tags { "Queue"="Transparent" "RenderType"="Transparent" "RenderPipeline" = "UniversalPipeline" }
1510
LOD 100
1611
ZWrite Off
@@ -19,7 +14,7 @@
1914

2015
Pass
2116
{
22-
CGPROGRAM
17+
HLSLPROGRAM
2318
#pragma vertex vert
2419
#pragma fragment frag
2520

@@ -51,13 +46,13 @@
5146
return o;
5247
}
5348

54-
fixed4 frag (v2f i) : SV_Target
49+
half4 frag (v2f i) : SV_Target
5550
{
5651
// sample the texture
57-
fixed4 col = _MainTex.Sample(sampler_MainTex, i.uv);
52+
half4 col = _MainTex.Sample(sampler_MainTex, i.uv);
5853
return col;
5954
}
60-
ENDCG
55+
ENDHLSL
6156
}
6257
}
6358
}

Assets/Shaders/URP/CrossSectionSphere.shader

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ Shader "VolumeRendering/URP/CrossSectionSphere" {
66

77
SubShader
88
{
9-
PackageRequirements
10-
{
11-
"com.unity.render-pipelines.universal":"[10.0,10.5.3]"
12-
}
13-
149
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
1510
LOD 100
1611

1712
Pass
1813
{
1914
Blend SrcAlpha OneMinusSrcAlpha
2015

21-
CGPROGRAM
16+
HLSLPROGRAM
2217
#pragma vertex vert
2318
#pragma fragment frag
2419
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
@@ -49,20 +44,20 @@ Shader "VolumeRendering/URP/CrossSectionSphere" {
4944
return o;
5045
}
5146

52-
fixed4 frag(v2f i) : SV_Target
47+
half4 frag(v2f i) : SV_Target
5348
{
5449
// Calculate the rim effect
5550
float3 viewDirection = normalize(_WorldSpaceCameraPos - i.worldPos);
5651
float rim = 1.0 - saturate(dot(viewDirection, i.worldNormal));
5752
rim = (rim >= (1.0 - _RimThickness)) ? 1.0 : 0.0;
5853

59-
float4 col;
54+
half4 col;
6055
col.rgb = _RimColor.rgb * rim;
6156
col.a = rim * _RimColor.a;
6257

6358
return col;
6459
}
65-
ENDCG
60+
ENDHLSL
6661
}
6762
}
6863
FallBack "Diffuse"

Assets/Shaders/URP/DirectVolumeRenderingShader.shader

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
}
2121
SubShader
2222
{
23-
PackageRequirements {
24-
"com.unity.render-pipelines.universal":"[10.0,10.5.3]"
25-
}
26-
2723
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
2824
LOD 100
2925
Cull Front
@@ -33,7 +29,7 @@
3329

3430
Pass
3531
{
36-
CGPROGRAM
32+
HLSLPROGRAM
3733
#pragma multi_compile MODE_DVR MODE_MIP MODE_SURF
3834
#pragma multi_compile __ TF2D_ON
3935
#pragma multi_compile __ CROSS_SECTION_ON
@@ -100,7 +96,7 @@
10096
return o;
10197
}
10298

103-
ENDCG
99+
ENDHLSL
104100
}
105101
}
106102
}

Assets/Shaders/URP/SliceRenderingShader.shader

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@
77
}
88
SubShader
99
{
10-
PackageRequirements
11-
{
12-
"com.unity.render-pipelines.universal":"[10.0,10.5.3]"
13-
}
14-
1510
Tags { "Queue" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
1611
LOD 100
1712
Cull Off
1813

1914
Pass
2015
{
21-
CGPROGRAM
16+
HLSLPROGRAM
2217
#pragma vertex vert
2318
#pragma fragment frag
2419

@@ -63,25 +58,25 @@
6358
return o;
6459
}
6560

66-
fixed4 frag (v2f i) : SV_Target
61+
half4 frag (v2f i) : SV_Target
6762
{
6863
float3 dataCoord = i.relVert + float3(0.5f, 0.5f, 0.5f);
6964
// If the current fragment is outside the volume, simply colour it black.
7065
// Note: Unity does not seem to have support for clamping texture coordinates to a border value, so we have to do this manually
7166
if (dataCoord.x > 1.0f || dataCoord.y > 1.0f || dataCoord.z > 1.0f || dataCoord.x < 0.0f || dataCoord.y < 0.0f || dataCoord.z < 0.0f)
7267
{
73-
return float4(0.0f, 0.0f, 0.0f, 1.0f);
68+
return half4(0.0f, 0.0f, 0.0f, 1.0f);
7469
}
7570
else
7671
{
7772
// Sample the volume texture.
7873
float dataVal = _DataTex.Sample(sampler_DataTex, dataCoord);
79-
float4 col = _TFTex.Sample(sampler_TFTex, float2(dataVal, 0.0));
74+
half4 col = _TFTex.Sample(sampler_TFTex, float2(dataVal, 0.0));
8075
col.a = 1.0f;
8176
return col;
8277
}
8378
}
84-
ENDCG
79+
ENDHLSL
8580
}
8681
}
8782
}

Assets/Shaders/URP/TransferFunction2DShader.shader

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,17 @@
66
}
77
SubShader
88
{
9-
PackageRequirements
10-
{
11-
"com.unity.render-pipelines.universal":"[10.0,10.5.3]"
12-
}
13-
149
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
1510
LOD 100
1611

1712
Blend SrcAlpha OneMinusSrcAlpha
1813

1914
Pass
2015
{
21-
CGPROGRAM
16+
HLSLPROGRAM
2217
#pragma vertex vert
2318
#pragma fragment frag
24-
// make fog work
25-
#pragma multi_compile_fog
26-
19+
2720
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
2821

2922
struct appdata
@@ -35,7 +28,6 @@
3528
struct v2f
3629
{
3730
float2 uv : TEXCOORD0;
38-
UNITY_FOG_COORDS(1)
3931
float4 vertex : SV_POSITION;
4032
};
4133

@@ -50,14 +42,14 @@
5042
return o;
5143
}
5244

53-
fixed4 frag (v2f i) : SV_Target
45+
half4 frag (v2f i) : SV_Target
5446
{
55-
fixed4 col = _TFTex.Sample(sampler_TFTex, i.uv);
47+
half4 col = _TFTex.Sample(sampler_TFTex, i.uv);
5648
//col.a = 1.0f;
57-
49+
5850
return col;
5951
}
60-
ENDCG
52+
ENDHLSL
6153
}
6254
}
6355
}

Assets/Shaders/URP/TransferFunctionPaletteShader.shader

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,17 @@
66
}
77
SubShader
88
{
9-
PackageRequirements
10-
{
11-
"com.unity.render-pipelines.universal":"[10.0,10.5.3]"
12-
}
13-
149
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
1510
LOD 100
1611

1712
Blend SrcAlpha OneMinusSrcAlpha
1813

1914
Pass
2015
{
21-
CGPROGRAM
16+
HLSLPROGRAM
2217
#pragma vertex vert
2318
#pragma fragment frag
24-
// make fog work
25-
#pragma multi_compile_fog
26-
19+
2720
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
2821

2922
struct appdata
@@ -37,7 +30,6 @@
3730
{
3831
UNITY_VERTEX_OUTPUT_STEREO
3932
float2 uv : TEXCOORD0;
40-
UNITY_FOG_COORDS(1)
4133
float4 vertex : SV_POSITION;
4234
};
4335

@@ -54,18 +46,18 @@
5446
return o;
5547
}
5648

57-
fixed4 frag (v2f i) : SV_Target
49+
half4 frag (v2f i) : SV_Target
5850
{
59-
fixed4 col = _TFTex.Sample(sampler_TFTex, float2(i.uv.x, 0.0f));
51+
half4 col = _TFTex.Sample(sampler_TFTex, float2(i.uv.x, 0.0f));
6052
col.a = 1.0f;
6153
#if !UNITY_COLORSPACE_GAMMA
6254
#define INVERSA_GAMMA 0.4545454
63-
col.rgb = pow(col.rgb, float3(INVERSA_GAMMA, INVERSA_GAMMA, INVERSA_GAMMA));
55+
col.rgb = pow(col.rgb, half3(INVERSA_GAMMA, INVERSA_GAMMA, INVERSA_GAMMA));
6456
#endif
65-
57+
6658
return col;
6759
}
68-
ENDCG
60+
ENDHLSL
6961
}
7062
}
7163
}

Assets/Shaders/URP/TransferFunctionShader.shader

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@
77
}
88
SubShader
99
{
10-
PackageRequirements
11-
{
12-
"com.unity.render-pipelines.universal":"[10.0,10.5.3]"
13-
}
14-
1510
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
1611
LOD 100
1712

1813
Blend SrcAlpha OneMinusSrcAlpha
1914

2015
Pass
2116
{
22-
CGPROGRAM
17+
HLSLPROGRAM
2318
#pragma vertex vert
2419
#pragma fragment frag
2520

@@ -51,22 +46,22 @@
5146
return o;
5247
}
5348

54-
fixed4 frag (v2f i) : SV_Target
49+
half4 frag (v2f i) : SV_Target
5550
{
5651
float density = i.uv.x;
5752
float histY = _HistTex.Sample(sampler_HistTex, float2(density, 0.0f)).r;
58-
fixed4 tfCol = _TFTex.Sample(sampler_TFTex, float2(density, 0.0f));
59-
float4 histCol = histY > i.uv.y ? float4(1.0f, 1.0f, 1.0f, 1.0f) : float4(0.0f, 0.0f, 0.0f, 0.0f);
60-
53+
half4 tfCol = _TFTex.Sample(sampler_TFTex, float2(density, 0.0f));
54+
half4 histCol = histY > i.uv.y ? half4(1.0f, 1.0f, 1.0f, 1.0f) : half4(0.0f, 0.0f, 0.0f, 0.0f);
55+
6156
float alpha = tfCol.a;
6257
if (i.uv.y > alpha)
6358
tfCol.a = 0.0f;
6459

65-
float4 col = histCol * 0.5f + tfCol * 0.7f;
66-
60+
half4 col = histCol * 0.5f + tfCol * 0.7f;
61+
6762
return col;
6863
}
69-
ENDCG
64+
ENDHLSL
7065
}
7166
}
7267
}

0 commit comments

Comments
 (0)