Skip to content

Commit

Permalink
Updated Built-in Shaders to 2019.1.0f2
Browse files Browse the repository at this point in the history
  • Loading branch information
MattOstgard committed Apr 24, 2019
1 parent 803692b commit df86bd3
Show file tree
Hide file tree
Showing 52 changed files with 1,725 additions and 617 deletions.
2 changes: 2 additions & 0 deletions CGIncludes/HLSLSupport.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@
// this allows surface shaders to use _NOSAMPLER and similar macros, without using up a sampler register.
// Don't do that for mojoshader part, as that one can only parse DX9 style HLSL.

#define UNITY_SEPARATE_TEXTURE_SAMPLER

// 2D textures
#define UNITY_DECLARE_TEX2D(tex) Texture2D tex; SamplerState sampler##tex
#define UNITY_DECLARE_TEX2D_NOSAMPLER(tex) Texture2D tex
Expand Down
4 changes: 2 additions & 2 deletions CGIncludes/TerrainSplatmapCommon.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ void SplatmapVert(inout appdata_full v, out Input data)
v.tangent.xyz = cross(v.normal, float3(0,0,1));
v.tangent.w = -1;

data.tc.xy = v.texcoord;
data.tc.xy = v.texcoord.xy;
#ifdef TERRAIN_BASE_PASS
#ifdef UNITY_PASS_META
data.tc.xy = v.texcoord * _MainTex_ST.xy + _MainTex_ST.zw;
data.tc.xy = TRANSFORM_TEX(v.texcoord.xy, _MainTex);
#endif
#else
float4 pos = UnityObjectToClipPos(v.vertex);
Expand Down
1 change: 0 additions & 1 deletion CGIncludes/UnityCG.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ inline half3 DecodeHDR (half4 data, half4 decodeInstructions)

// Decodes HDR textures
// handles dLDR, RGBM formats
// Called by DecodeLightmap when UNITY_NO_RGBM is not defined.
inline half3 DecodeLightmapRGBM (half4 data, half4 decodeInstructions)
{
// If Linear mode is not supported we can skip exponent part
Expand Down
11 changes: 10 additions & 1 deletion CGIncludes/UnityInstancing.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
#define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO uint stereoTargetEyeIndex : SV_RenderTargetArrayIndex;
#define DEFAULT_UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output) output.stereoTargetEyeIndex = unity_StereoEyeIndex
#endif
#define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO_EYE_INDEX uint stereoTargetEyeIndex : BLENDINDICES0;
#define DEFAULT_UNITY_INITIALIZE_OUTPUT_STEREO_EYE_INDEX(output) output.stereoTargetEyeIndex = unity_StereoEyeIndex;
#define DEFAULT_UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(input, output) output.stereoTargetEyeIndex = input.stereoTargetEyeIndex;
#define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input) unity_StereoEyeIndex = input.stereoTargetEyeIndex;
#elif defined(UNITY_STEREO_MULTIVIEW_ENABLED)
Expand All @@ -134,12 +136,19 @@
#endif
#else
#define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO
#define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO_EYE_INDEX
#define DEFAULT_UNITY_INITIALIZE_OUTPUT_STEREO_EYE_INDEX(output)
#define DEFAULT_UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output)
#define DEFAULT_UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(input, output)
#define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input)
#endif


#if !defined(UNITY_VERTEX_OUTPUT_STEREO_EYE_INDEX)
# define UNITY_VERTEX_OUTPUT_STEREO_EYE_INDEX DEFAULT_UNITY_VERTEX_OUTPUT_STEREO_EYE_INDEX
#endif
#if !defined(UNITY_INITIALIZE_OUTPUT_STEREO_EYE_INDEX)
# define UNITY_INITIALIZE_OUTPUT_STEREO_EYE_INDEX(output) DEFAULT_UNITY_INITIALIZE_OUTPUT_STEREO_EYE_INDEX(output)
#endif
#if !defined(UNITY_VERTEX_OUTPUT_STEREO)
# define UNITY_VERTEX_OUTPUT_STEREO DEFAULT_UNITY_VERTEX_OUTPUT_STEREO
#endif
Expand Down
16 changes: 16 additions & 0 deletions CGIncludes/UnityStereoExtensions.glslinc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)

#ifndef GLSL_STEREO_EXTENSIONS_INCLUDED
#define GLSL_STEREO_EXTENSIONS_INCLUDED

#ifdef STEREO_MULTIVIEW_ON
#extension GL_OVR_multiview2 : require
#endif

#ifdef STEREO_INSTANCING_ON
#extension GL_NV_viewport_array2 : enable
#extension GL_AMD_vertex_shader_layer : enable
#extension GL_ARB_fragment_layer_viewport : enable
#endif

#endif // GLSL_STEREO_EXTENSIONS_INCLUDED
57 changes: 57 additions & 0 deletions CGIncludes/UnityStereoSupport.glslinc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)

#ifndef GLSL_STEREO_SETUP_INCLUDED
#define GLSL_STEREO_SETUP_INCLUDED

#if defined(STEREO_MULTIVIEW_ON) || defined(STEREO_INSTANCING_ON)
layout(std140) uniform UnityStereoGlobals {
mat4 unity_StereoMatrixP[2];
mat4 unity_StereoMatrixV[2];
mat4 unity_StereoMatrixInvV[2];
mat4 unity_StereoMatrixVP[2];
mat4 unity_StereoCameraProjection[2];
mat4 unity_StereoCameraInvProjection[2];
mat4 unity_StereoWorldToCamera[2];
mat4 unity_StereoCameraToWorld[2];
vec3 unity_StereoWorldSpaceCameraPos[2];
vec4 unity_StereoScaleOffset[2];
};
layout(std140) uniform UnityStereoEyeIndices {
vec4 unity_StereoEyeIndices[2];
};
#endif

#ifdef VERTEX
#ifdef STEREO_MULTIVIEW_ON
layout(num_views = 2) in;
#endif

uniform int unity_StereoEyeIndex;

int SetupStereoEyeIndex()
{
int eyeIndex = unity_StereoEyeIndex;

#if defined(STEREO_MULTIVIEW_ON)
eyeIndex = int(unity_StereoEyeIndices[gl_ViewID_OVR].x);
#elif defined(STEREO_INSTANCING_ON)
eyeIndex = int(gl_InstanceID & 1);
gl_Layer = eyeIndex;
#endif

return eyeIndex;
}

mat4 GetStereoMatrixVP(int eyeIndex)
{
mat4 stereoVP = unity_MatrixVP;

#if defined(STEREO_MULTIVIEW_ON) || defined(STEREO_INSTANCING_ON)
stereoVP = unity_StereoMatrixVP[eyeIndex];
#endif

return stereoVP;
}
#endif

#endif // GLSL_STEREO_SETUP_INCLUDED
Loading

0 comments on commit df86bd3

Please sign in to comment.