Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 803692b

Browse files
committed
Updated Built-in Shaders to 2018.3.13f1
1 parent 7a0e0f3 commit 803692b

File tree

59 files changed

+2322
-671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2322
-671
lines changed

CGIncludes/HLSLSupport.cginc

Lines changed: 19 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@
8585
# endif
8686
#endif
8787
#if !defined(SV_Target1)
88-
# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2)
88+
# if !defined(SHADER_API_XBOXONE)
8989
# define SV_Target1 COLOR1
9090
# endif
9191
#endif
9292
#if !defined(SV_Target2)
93-
# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2)
93+
# if !defined(SHADER_API_XBOXONE)
9494
# define SV_Target2 COLOR2
9595
# endif
9696
#endif
9797
#if !defined(SV_Target3)
98-
# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2)
98+
# if !defined(SHADER_API_XBOXONE)
9999
# define SV_Target3 COLOR3
100100
# endif
101101
#endif
@@ -125,13 +125,13 @@
125125
# endif
126126
#endif
127127

128-
#if (defined(SHADER_API_GLES3) && !defined(SHADER_API_DESKTOP)) || defined(SHADER_API_GLES) || defined(SHADER_API_PSP2) || defined(SHADER_API_N3DS)
128+
#if (defined(SHADER_API_GLES3) && !defined(SHADER_API_DESKTOP)) || defined(SHADER_API_GLES) || defined(SHADER_API_N3DS)
129129
#define UNITY_ALLOWED_MRT_COUNT 4
130130
#else
131131
#define UNITY_ALLOWED_MRT_COUNT 8
132132
#endif
133133

134-
#if (SHADER_TARGET < 30) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLES) || defined(SHADER_API_PSP2) || defined(SHADER_API_N3DS)
134+
#if (SHADER_TARGET < 30) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLES) || defined(SHADER_API_N3DS)
135135
//no fast coherent dynamic branching on these hardware
136136
#else
137137
#define UNITY_FAST_COHERENT_DYNAMIC_BRANCHING 1
@@ -164,8 +164,14 @@
164164
#define sampler3D_half sampler3D
165165
#define Texture2D_half Texture2D
166166
#define Texture2D_float Texture2D
167+
#define Texture2DArray_half Texture2DArray
168+
#define Texture2DArray_float Texture2DArray
169+
#define Texture2DMS_half Texture2DMS
170+
#define Texture2DMS_float Texture2DMS
167171
#define TextureCube_half TextureCube
168172
#define TextureCube_float TextureCube
173+
#define TextureCubeArray_half TextureCubeArray
174+
#define TextureCubeArray_float TextureCubeArray
169175
#define Texture3D_float Texture3D
170176
#define Texture3D_half Texture3D
171177
#endif
@@ -254,13 +260,6 @@
254260
#define asuint(x) asint(x)
255261
#endif
256262

257-
#if defined(SHADER_API_PSP2)
258-
// The PSP2 cg compiler does not define uint<N>
259-
#define uint2 unsigned int2
260-
#define uint3 unsigned int3
261-
#define uint4 unsigned int4
262-
#endif
263-
264263
// specifically for samplers that are provided as arguments to entry functions
265264
#if defined(SHADER_API_PSSL)
266265
#define SAMPLER_UNIFORM uniform
@@ -270,6 +269,10 @@
270269
#endif
271270

272271
#if defined(SHADER_API_PSSL)
272+
// variable modifiers
273+
#define nointerpolation nointerp
274+
#define noperspective nopersp
275+
273276
#define CBUFFER_START(name) ConstantBuffer name {
274277
#define CBUFFER_END };
275278
#elif defined(SHADER_API_D3D11)
@@ -304,34 +307,7 @@
304307
#define UNITY_REQUIRE_ADVANCED_BLEND(mode)
305308
#endif
306309

307-
308-
#if defined(SHADER_API_PSP2)
309-
// For tex2Dproj the PSP2 cg compiler doesn't like casting half3/4 to
310-
// float3/4 with swizzle (optimizer generates invalid assembly), so declare
311-
// explicit versions for half3/4
312-
half4 tex2Dproj(sampler2D s, in half3 t) { return tex2D(s, t.xy / t.z); }
313-
half4 tex2Dproj(sampler2D s, in half4 t) { return tex2D(s, t.xy / t.w); }
314-
315-
// As above but for sampling from single component textures, e.g. depth textures.
316-
// NOTE that hardware PCF does not work with these versions, currently we have to ensure
317-
// that tex coords for shadow sampling use float, not half; and for some reason casting half
318-
// to float and using tex2Dproj also does not work.
319-
half4 tex2DprojShadow(sampler2D s, in half3 t) { return tex2D<float>(s, t.xy / t.z); }
320-
half4 tex2DprojShadow(sampler2D s, in half4 t) { return tex2D<float>(s, t.xy / t.w); }
321-
322-
// ...and versions of tex2DprojShadow for float uv.
323-
half4 tex2DprojShadow(sampler2D s, in float3 t) { return tex2Dproj<float>(s, t); }
324-
half4 tex2DprojShadow(sampler2D s, in float4 t) { return tex2Dproj<float>(s, t); }
325-
#endif
326-
327-
328-
#if defined(SHADER_API_PSP2)
329-
#define UNITY_BUGGY_TEX2DPROJ4
330-
#define UNITY_PROJ_COORD(a) (a).xyw
331-
#else
332310
#define UNITY_PROJ_COORD(a) a
333-
#endif
334-
335311

336312
// Depth texture sampling helpers.
337313
// On most platforms you can just sample them, but some (e.g. PSP2) need special handling.
@@ -340,17 +316,6 @@
340316
// SAMPLE_DEPTH_TEXTURE_PROJ(sampler,uv): projected sample
341317
// SAMPLE_DEPTH_TEXTURE_LOD(sampler,uv): sample with LOD level
342318

343-
#if defined(SHADER_API_PSP2)
344-
half SAMPLE_DEPTH_TEXTURE(sampler2D s, float4 uv) { return tex2D<float>(s, (float3)uv); }
345-
half SAMPLE_DEPTH_TEXTURE(sampler2D s, float3 uv) { return tex2D<float>(s, uv); }
346-
half SAMPLE_DEPTH_TEXTURE(sampler2D s, float2 uv) { return tex2D<float>(s, uv); }
347-
# define SAMPLE_DEPTH_TEXTURE_PROJ(sampler, uv) (tex2DprojShadow(sampler, uv))
348-
# define SAMPLE_DEPTH_TEXTURE_LOD(sampler, uv) (tex2Dlod<float>(sampler, uv))
349-
# define SAMPLE_RAW_DEPTH_TEXTURE(sampler, uv) SAMPLE_DEPTH_TEXTURE(sampler, uv)
350-
# define SAMPLE_RAW_DEPTH_TEXTURE_PROJ(sampler, uv) SAMPLE_DEPTH_TEXTURE_PROJ(sampler, uv)
351-
# define SAMPLE_RAW_DEPTH_TEXTURE_LOD(sampler, uv) SAMPLE_DEPTH_TEXTURE_LOD(sampler, uv)
352-
half SAMPLE_DEPTH_CUBE_TEXTURE(samplerCUBE s, float3 uv) { return texCUBE<float>(s, uv); }
353-
#else
354319
// Sample depth, just the red component.
355320
# define SAMPLE_DEPTH_TEXTURE(sampler, uv) (tex2D(sampler, uv).r)
356321
# define SAMPLE_DEPTH_TEXTURE_PROJ(sampler, uv) (tex2Dproj(sampler, uv).r)
@@ -360,14 +325,9 @@
360325
# define SAMPLE_RAW_DEPTH_TEXTURE_PROJ(sampler, uv) (tex2Dproj(sampler, uv))
361326
# define SAMPLE_RAW_DEPTH_TEXTURE_LOD(sampler, uv) (tex2Dlod(sampler, uv))
362327
# define SAMPLE_DEPTH_CUBE_TEXTURE(sampler, uv) (texCUBE(sampler, uv).r)
363-
#endif
364328

365329
// Deprecated; use SAMPLE_DEPTH_TEXTURE & SAMPLE_DEPTH_TEXTURE_PROJ instead
366-
#if defined(SHADER_API_PSP2)
367-
# define UNITY_SAMPLE_DEPTH(value) (value).r
368-
#else
369-
# define UNITY_SAMPLE_DEPTH(value) (value).r
370-
#endif
330+
#define UNITY_SAMPLE_DEPTH(value) (value).r
371331

372332

373333
// Macros to declare and sample shadow maps.
@@ -411,15 +371,6 @@
411371
#define UNITY_SAMPLE_SHADOW(tex,coord) tex.SampleCmpLOD0(sampler##tex,(coord).xy,(coord).z)
412372
#define UNITY_SAMPLE_SHADOW_PROJ(tex,coord) tex.SampleCmpLOD0(sampler##tex,(coord).xy/(coord).w,(coord).z/(coord).w)
413373
#define UNITY_SAMPLE_TEXCUBE_SHADOW(tex,coord) tex.SampleCmpLOD0(sampler##tex,(coord).xyz,(coord).w)
414-
#elif defined(SHADER_API_PSP2)
415-
// Vita
416-
#define UNITY_DECLARE_SHADOWMAP(tex) sampler2D tex
417-
#define UNITY_DECLARE_TEXCUBE_SHADOWMAP(tex) samplerCUBE tex
418-
// tex2d shadow comparison on Vita returns 0 instead of 1 when shadowCoord.z >= 1 causing artefacts in some tests.
419-
// Clamping Z to the range 0.0 <= Z < 1.0 solves this.
420-
#define UNITY_SAMPLE_SHADOW(tex,coord) tex2D<float>(tex, float3((coord).xy, clamp((coord).z, 0.0, 0.999999)))
421-
#define UNITY_SAMPLE_SHADOW_PROJ(tex,coord) tex2DprojShadow(tex, coord)
422-
#define UNITY_SAMPLE_TEXCUBE_SHADOW(tex,coord) texCUBE<float>(tex, float3((coord).xyz, clamp((coord).w, 0.0, 0.999999)))
423374
#else
424375
// Fallback / No built-in shadowmap comparison sampling: regular texture sample and do manual depth comparison
425376
#define UNITY_DECLARE_SHADOWMAP(tex) sampler2D_float tex
@@ -631,18 +582,13 @@
631582
#endif
632583

633584

634-
// Declare position that is also available for read in fragment shader
635-
#if defined(SHADER_API_PSP2) && defined(SHADER_STAGE_FRAGMENT) && SHADER_TARGET >= 30
636-
#define UNITY_POSITION(pos) float4 pos : VPOS
637-
#else
638585
// On D3D reading screen space coordinates from fragment shader requires SM3.0
639586
#define UNITY_POSITION(pos) float4 pos : SV_POSITION
640-
#endif
641587

642588
// Kept for backwards-compatibility
643589
#define UNITY_ATTEN_CHANNEL r
644590

645-
#if defined(SHADER_API_D3D11) || defined(SHADER_API_PSP2) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH)
591+
#if defined(SHADER_API_D3D11) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH)
646592
#define UNITY_UV_STARTS_AT_TOP 1
647593
#endif
648594

@@ -665,19 +611,11 @@
665611
// UNITY_ENABLE_REFLECTION_BUFFERS - render reflection probes in deferred way, when using deferred shading
666612

667613

668-
#if defined(SHADER_API_PSP2)
669-
// To get acceptable precision from the SGX interpolators when decoding RGBM type
670-
// textures we have to disable sRGB reads and then convert to gamma space in the shader
671-
// explicitly.
672-
#define UNITY_FORCE_LINEAR_READ_FOR_RGBM
673-
#endif
674-
675-
676614
// On most platforms, use floating point render targets to store depth of point
677615
// light shadowmaps. However, on some others they either have issues, or aren't widely
678616
// supported; in which case fallback to encoding depth into RGBA channels.
679617
// Make sure this define matches GraphicsCaps.useRGBAForPointShadows.
680-
#if defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) || defined(SHADER_API_PSP2)
618+
#if defined(SHADER_API_GLES) || defined(SHADER_API_GLES3)
681619
#define UNITY_USE_RGBA_FOR_POINT_SHADOWS
682620
#endif
683621

@@ -730,7 +668,7 @@
730668
#endif
731669

732670
// define use to identify platform with modern feature like texture 3D with filtering, texture array etc...
733-
#define UNITY_SM40_PLUS_PLATFORM (!((SHADER_TARGET < 30) || defined (SHADER_API_MOBILE) || defined (SHADER_API_PSP2) || defined(SHADER_API_GLES)))
671+
#define UNITY_SM40_PLUS_PLATFORM (!((SHADER_TARGET < 30) || defined (SHADER_API_MOBILE) || defined(SHADER_API_GLES)))
734672

735673
// Ability to manually set descriptor set and binding numbers (Vulkan only)
736674
#if defined(SHADER_API_VULKAN)

0 commit comments

Comments
 (0)