Skip to content

Commit 340190e

Browse files
sebastienlagardeJulienIgnace-UnityJordanL8robcupisz
authored
Various SRP and HDRP backport (#4069)
* Temporarily disabled warnings in Core shader library for gles platforms. (#3931) * Temporarily disabled warnings in Core shader library for gles platforms. * Move the pragma warning to all the specific files instead of globally * Added mobile preprocessor guards around half conversion warning pragmas (#4009) * Added missing implicit conversion from TextureHandle to Texture (#4013) * Moved path tracing limitations to the path tracing documentation and added information about streaming virtual texturing. (#4014) * Fix spot light near plane gizmo (#4026) * Added information clarifying what ambient occlusion is available in AOVs (#4042) Co-authored-by: JulienIgnace-Unity <julien@unity3d.com> Co-authored-by: Lewis Jordan <lewis.jordan@hotmail.co.uk> Co-authored-by: Robert Cupisz <robertcupisz@gmail.com>
1 parent 3c84b59 commit 340190e

File tree

19 files changed

+167
-43
lines changed

19 files changed

+167
-43
lines changed

com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceTexture.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ public struct TextureHandle
2323
internal TextureHandle(int handle, bool shared = false) { this.handle = new ResourceHandle(handle, RenderGraphResourceType.Texture, shared); }
2424

2525
/// <summary>
26-
/// Cast to RTHandle
26+
/// Cast to RenderTargetIdentifier
2727
/// </summary>
2828
/// <param name="texture">Input TextureHandle.</param>
29-
/// <returns>Resource as a RTHandle.</returns>
30-
public static implicit operator RTHandle(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null;
29+
/// <returns>Resource as a RenderTargetIdentifier.</returns>
30+
public static implicit operator RenderTargetIdentifier(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : default(RenderTargetIdentifier);
3131

3232
/// <summary>
33-
/// Cast to RenderTargetIdentifier
33+
/// Cast to Texture
3434
/// </summary>
3535
/// <param name="texture">Input TextureHandle.</param>
36-
/// <returns>Resource as a RenderTargetIdentifier.</returns>
37-
public static implicit operator RenderTargetIdentifier(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : default(RenderTargetIdentifier);
36+
/// <returns>Resource as a Texture.</returns>
37+
public static implicit operator Texture(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null;
3838

3939
/// <summary>
4040
/// Cast to RenderTexture
@@ -43,6 +43,13 @@ public struct TextureHandle
4343
/// <returns>Resource as a RenderTexture.</returns>
4444
public static implicit operator RenderTexture(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null;
4545

46+
/// <summary>
47+
/// Cast to RTHandle
48+
/// </summary>
49+
/// <param name="texture">Input TextureHandle.</param>
50+
/// <returns>Resource as a RTHandle.</returns>
51+
public static implicit operator RTHandle(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null;
52+
4653
/// <summary>
4754
/// Return true if the handle is valid.
4855
/// </summary>

com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,13 @@ internal RTHandle(RTHandleSystem owner)
6262
}
6363

6464
/// <summary>
65-
/// Implicit conversion operator to RenderTexture
65+
/// Implicit conversion operator to RenderTargetIdentifier
6666
/// </summary>
6767
/// <param name="handle">Input RTHandle</param>
68-
/// <returns>RenderTexture representation of the RTHandle.</returns>
69-
public static implicit operator RenderTexture(RTHandle handle)
68+
/// <returns>RenderTargetIdentifier representation of the RTHandle.</returns>
69+
public static implicit operator RenderTargetIdentifier(RTHandle handle)
7070
{
71-
// If RTHandle is null then conversion should give a null RenderTexture
72-
if (handle == null)
73-
return null;
74-
75-
Debug.Assert(handle.rt != null, "RTHandle was created using a regular Texture and is used as a RenderTexture");
76-
return handle.rt;
71+
return handle != null ? handle.nameID : default(RenderTargetIdentifier);
7772
}
7873

7974
/// <summary>
@@ -92,13 +87,18 @@ public static implicit operator Texture(RTHandle handle)
9287
}
9388

9489
/// <summary>
95-
/// Implicit conversion operator to RenderTargetIdentifier
90+
/// Implicit conversion operator to RenderTexture
9691
/// </summary>
9792
/// <param name="handle">Input RTHandle</param>
98-
/// <returns>RenderTargetIdentifier representation of the RTHandle.</returns>
99-
public static implicit operator RenderTargetIdentifier(RTHandle handle)
93+
/// <returns>RenderTexture representation of the RTHandle.</returns>
94+
public static implicit operator RenderTexture(RTHandle handle)
10095
{
101-
return handle != null ? handle.nameID : default(RenderTargetIdentifier);
96+
// If RTHandle is null then conversion should give a null RenderTexture
97+
if (handle == null)
98+
return null;
99+
100+
Debug.Assert(handle.rt != null, "RTHandle was created using a regular Texture and is used as a RenderTexture");
101+
return handle.rt;
102102
}
103103

104104
internal void SetRenderTexture(RenderTexture rt)

com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef __ACES__
22
#define __ACES__
33

4+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
5+
#pragma warning (disable : 3205) // conversion of larger type to smaller
6+
#endif
7+
48
/**
59
* https://github.com/ampas/aces-dev
610
*
@@ -1316,4 +1320,8 @@ half3 ODT_P3DCI_48nits(half3 oces)
13161320
return outputCV;
13171321
}
13181322

1323+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
1324+
#pragma warning (enable : 3205) // conversion of larger type to smaller
1325+
#endif
1326+
13191327
#endif // __ACES__

com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef UNITY_BSDF_INCLUDED
22
#define UNITY_BSDF_INCLUDED
33

4+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
5+
#pragma warning (disable : 3205) // conversion of larger type to smaller
6+
#endif
7+
48
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
59

610
// Note: All NDF and diffuse term have a version with and without divide by PI.
@@ -637,4 +641,9 @@ real3 D_KajiyaKay(real3 T, real3 H, real specularExponent)
637641

638642
return dirAttn * norm * PositivePow(sinTHSq, 0.5 * n);
639643
}
644+
645+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
646+
#pragma warning (enable : 3205) // conversion of larger type to smaller
647+
#endif
648+
640649
#endif // UNITY_BSDF_INCLUDED

com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef UNITY_COLOR_INCLUDED
22
#define UNITY_COLOR_INCLUDED
33

4+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
5+
#pragma warning (disable : 3205) // conversion of larger type to smaller
6+
#endif
7+
48
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl"
59

610
//-----------------------------------------------------------------------------
@@ -731,4 +735,8 @@ half3 DecodeRGBM(half4 rgbm)
731735
return rgbm.xyz * rgbm.w * kRGBMRange;
732736
}
733737

738+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
739+
#pragma warning (enable : 3205) // conversion of larger type to smaller
740+
#endif
741+
734742
#endif // UNITY_COLOR_INCLUDED

com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef UNITY_COMMON_INCLUDED
22
#define UNITY_COMMON_INCLUDED
33

4+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
5+
#pragma warning (disable : 3205) // conversion of larger type to smaller
6+
#endif
7+
48
// Convention:
59

610
// Unity is Y up and left handed in world space
@@ -1341,4 +1345,8 @@ float SharpenAlpha(float alpha, float alphaClipTreshold)
13411345
// These clamping function to max of floating point 16 bit are use to prevent INF in code in case of extreme value
13421346
TEMPLATE_1_REAL(ClampToFloat16Max, value, return min(value, HALF_MAX))
13431347

1348+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
1349+
#pragma warning (enable : 3205) // conversion of larger type to smaller
1350+
#endif
1351+
13441352
#endif // UNITY_COMMON_INCLUDED

com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef UNITY_COMMON_LIGHTING_INCLUDED
22
#define UNITY_COMMON_LIGHTING_INCLUDED
33

4+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
5+
#pragma warning (disable : 3205) // conversion of larger type to smaller
6+
#endif
7+
48
// Ligthing convention
59
// Light direction is oriented backward (-Z). i.e in shader code, light direction is -lightData.forward
610

@@ -455,4 +459,8 @@ bool IsMatchingLightLayer(uint lightLayers, uint renderingLayers)
455459
return (lightLayers & renderingLayers) != 0;
456460
}
457461

462+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
463+
#pragma warning (enable : 3205) // conversion of larger type to smaller
464+
#endif
465+
458466
#endif // UNITY_COMMON_LIGHTING_INCLUDED

com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef UNITY_COMMON_MATERIAL_INCLUDED
22
#define UNITY_COMMON_MATERIAL_INCLUDED
33

4+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
5+
#pragma warning (disable : 3205) // conversion of larger type to smaller
6+
#endif
7+
48
//-----------------------------------------------------------------------------
59
// Define constants
610
//-----------------------------------------------------------------------------
@@ -329,4 +333,9 @@ real3 LerpWhiteTo(real3 b, real t)
329333
real oneMinusT = 1.0 - t;
330334
return real3(oneMinusT, oneMinusT, oneMinusT) + b * t;
331335
}
336+
337+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
338+
#pragma warning (enable : 3205) // conversion of larger type to smaller
339+
#endif
340+
332341
#endif // UNITY_COMMON_MATERIAL_INCLUDED

com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef UNITY_ENTITY_LIGHTING_INCLUDED
22
#define UNITY_ENTITY_LIGHTING_INCLUDED
33

4+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
5+
#pragma warning (disable : 3205) // conversion of larger type to smaller
6+
#endif
7+
48
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
59
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
610

@@ -355,5 +359,8 @@ real3 SampleDirectionalLightmap(TEXTURE2D_LIGHTMAP_PARAM(lightmapTex, lightmapSa
355359
return bakeDiffuseLighting;
356360
}
357361

362+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
363+
#pragma warning (enable : 3205) // conversion of larger type to smaller
364+
#endif
358365

359366
#endif // UNITY_ENTITY_LIGHTING_INCLUDED

com.unity.render-pipelines.core/ShaderLibrary/ImageBasedLighting.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef UNITY_IMAGE_BASED_LIGHTING_INCLUDED
22
#define UNITY_IMAGE_BASED_LIGHTING_INCLUDED
33

4+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
5+
#pragma warning (disable : 3205) // conversion of larger type to smaller
6+
#endif
7+
48
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
59
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
610
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl"
@@ -738,4 +742,8 @@ float InfluenceFadeNormalWeight(float3 normal, float3 centerToPos)
738742
return saturate((-1.0f / 0.4f) * dot(normal, centerToPos) + (0.6f / 0.4f));
739743
}
740744

745+
#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3
746+
#pragma warning (enable : 3205) // conversion of larger type to smaller
747+
#endif
748+
741749
#endif // UNITY_IMAGE_BASED_LIGHTING_INCLUDED

0 commit comments

Comments
 (0)