mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-03 04:34:26 -07:00
Initial commit
This commit is contained in:
@@ -0,0 +1,244 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
#ifndef AUTOLIGHT_INCLUDED
|
||||
#define AUTOLIGHT_INCLUDED
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
#include "UnityShadowLibrary.cginc"
|
||||
|
||||
#define unityShadowCoord float
|
||||
#define unityShadowCoord2 float2
|
||||
#define unityShadowCoord3 float3
|
||||
#define unityShadowCoord4 float4
|
||||
#define unityShadowCoord4x4 float4x4
|
||||
|
||||
// ----------------
|
||||
// Shadow helpers
|
||||
// ----------------
|
||||
|
||||
// If none of the keywords are defined, assume directional?
|
||||
#if !defined(POINT) && !defined(SPOT) && !defined(DIRECTIONAL) && !defined(POINT_COOKIE) && !defined(DIRECTIONAL_COOKIE)
|
||||
#define DIRECTIONAL
|
||||
#endif
|
||||
|
||||
// ---- Screen space direction light shadows helpers (any version)
|
||||
#if defined (SHADOWS_SCREEN)
|
||||
|
||||
#if defined(UNITY_NO_SCREENSPACE_SHADOWS)
|
||||
UNITY_DECLARE_SHADOWMAP(_ShadowMapTexture);
|
||||
#define TRANSFER_SHADOW(a) a._ShadowCoord = mul( unity_WorldToShadow[0], mul( unity_ObjectToWorld, v.vertex ) );
|
||||
inline fixed unitySampleShadow (unityShadowCoord4 shadowCoord)
|
||||
{
|
||||
#if defined(SHADOWS_NATIVE)
|
||||
fixed shadow = UNITY_SAMPLE_SHADOW(_ShadowMapTexture, shadowCoord.xyz);
|
||||
shadow = _LightShadowData.r + shadow * (1-_LightShadowData.r);
|
||||
return shadow;
|
||||
#else
|
||||
unityShadowCoord dist = SAMPLE_DEPTH_TEXTURE(_ShadowMapTexture, shadowCoord.xy);
|
||||
// tegra is confused if we use _LightShadowData.x directly
|
||||
// with "ambiguous overloaded function reference max(mediump float, float)"
|
||||
unityShadowCoord lightShadowDataX = _LightShadowData.x;
|
||||
unityShadowCoord threshold = shadowCoord.z;
|
||||
return max(dist > threshold, lightShadowDataX);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else // UNITY_NO_SCREENSPACE_SHADOWS
|
||||
UNITY_DECLARE_SCREENSPACE_SHADOWMAP(_ShadowMapTexture);
|
||||
#define TRANSFER_SHADOW(a) a._ShadowCoord = ComputeScreenPos(a.pos);
|
||||
inline fixed unitySampleShadow (unityShadowCoord4 shadowCoord)
|
||||
{
|
||||
fixed shadow = UNITY_SAMPLE_SCREEN_SHADOW(_ShadowMapTexture, shadowCoord);
|
||||
return shadow;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define SHADOW_COORDS(idx1) unityShadowCoord4 _ShadowCoord : TEXCOORD##idx1;
|
||||
#define SHADOW_ATTENUATION(a) unitySampleShadow(a._ShadowCoord)
|
||||
#endif
|
||||
|
||||
// -----------------------------
|
||||
// Shadow helpers (5.6+ version)
|
||||
// -----------------------------
|
||||
// This version depends on having worldPos available in the fragment shader and using that to compute light coordinates.
|
||||
// if also supports ShadowMask (separately baked shadows for lightmapped objects)
|
||||
|
||||
half UnityComputeForwardShadows(float2 lightmapUV, float3 worldPos, float4 screenPos)
|
||||
{
|
||||
//fade value
|
||||
float zDist = dot(_WorldSpaceCameraPos - worldPos, UNITY_MATRIX_V[2].xyz);
|
||||
float fadeDist = UnityComputeShadowFadeDistance(worldPos, zDist);
|
||||
half realtimeToBakedShadowFade = UnityComputeShadowFade(fadeDist);
|
||||
|
||||
//baked occlusion if any
|
||||
half shadowMaskAttenuation = UnitySampleBakedOcclusion(lightmapUV, worldPos);
|
||||
|
||||
half realtimeShadowAttenuation = 1.0f;
|
||||
//directional realtime shadow
|
||||
#if defined (SHADOWS_SCREEN)
|
||||
#if defined(UNITY_NO_SCREENSPACE_SHADOWS)
|
||||
realtimeShadowAttenuation = unitySampleShadow(mul(unity_WorldToShadow[0], unityShadowCoord4(worldPos, 1)));
|
||||
#else
|
||||
//Only reached when LIGHTMAP_ON is NOT defined (and thus we use interpolator for screenPos rather than lightmap UVs). See HANDLE_SHADOWS_BLENDING_IN_GI below.
|
||||
realtimeShadowAttenuation = unitySampleShadow(screenPos);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_FAST_COHERENT_DYNAMIC_BRANCHING) && defined(SHADOWS_SOFT) && !defined(LIGHTMAP_SHADOW_MIXING)
|
||||
//avoid expensive shadows fetches in the distance where coherency will be good
|
||||
UNITY_BRANCH
|
||||
if (realtimeToBakedShadowFade < (1.0f - 1e-2f))
|
||||
{
|
||||
#endif
|
||||
|
||||
//spot realtime shadow
|
||||
#if (defined (SHADOWS_DEPTH) && defined (SPOT))
|
||||
unityShadowCoord4 spotShadowCoord = mul(unity_WorldToShadow[0], unityShadowCoord4(worldPos, 1));
|
||||
realtimeShadowAttenuation = UnitySampleShadowmap(spotShadowCoord);
|
||||
#endif
|
||||
|
||||
//point realtime shadow
|
||||
#if defined (SHADOWS_CUBE)
|
||||
realtimeShadowAttenuation = UnitySampleShadowmap(worldPos - _LightPositionRange.xyz);
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_FAST_COHERENT_DYNAMIC_BRANCHING) && defined(SHADOWS_SOFT) && !defined(LIGHTMAP_SHADOW_MIXING)
|
||||
}
|
||||
#endif
|
||||
|
||||
return UnityMixRealtimeAndBakedShadows(realtimeShadowAttenuation, shadowMaskAttenuation, realtimeToBakedShadowFade);
|
||||
}
|
||||
|
||||
#if defined(HANDLE_SHADOWS_BLENDING_IN_GI) // handles shadows in the depths of the GI function for performance reasons
|
||||
# define UNITY_SHADOW_COORDS(idx1) SHADOW_COORDS(idx1)
|
||||
# define UNITY_TRANSFER_SHADOW(a, coord) TRANSFER_SHADOW(a)
|
||||
# define UNITY_SHADOW_ATTENUATION(a, worldPos) SHADOW_ATTENUATION(a)
|
||||
#elif defined(SHADOWS_SCREEN) && !defined(LIGHTMAP_ON) && !defined(UNITY_NO_SCREENSPACE_SHADOWS) // no lightmap uv thus store screenPos instead
|
||||
# define UNITY_SHADOW_COORDS(idx1) SHADOW_COORDS(idx1)
|
||||
# define UNITY_TRANSFER_SHADOW(a, coord) TRANSFER_SHADOW(a)
|
||||
# define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(0, worldPos, a._ShadowCoord)
|
||||
#else
|
||||
# define UNITY_SHADOW_COORDS(idx1) unityShadowCoord2 _ShadowCoord : TEXCOORD##idx1;
|
||||
# if defined(SHADOWS_SHADOWMASK)
|
||||
# define UNITY_TRANSFER_SHADOW(a, coord) a._ShadowCoord = coord * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||
# if (defined(SHADOWS_DEPTH) || defined(SHADOWS_SCREEN) || defined(SHADOWS_CUBE) || UNITY_LIGHT_PROBE_PROXY_VOLUME)
|
||||
# define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(a._ShadowCoord, worldPos, 0)
|
||||
# else
|
||||
# define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(a._ShadowCoord, 0, 0)
|
||||
# endif
|
||||
# else
|
||||
# define UNITY_TRANSFER_SHADOW(a, coord)
|
||||
# if (defined(SHADOWS_DEPTH) || defined(SHADOWS_SCREEN) || defined(SHADOWS_CUBE))
|
||||
# define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(0, worldPos, 0)
|
||||
# else
|
||||
#if UNITY_LIGHT_PROBE_PROXY_VOLUME
|
||||
# define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(0, worldPos, 0)
|
||||
#else
|
||||
# define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(0, 0, 0)
|
||||
#endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Alloy
|
||||
// NOTE: Output shadow for forward base pass SHADOWS_SCREEN lightmaps.
|
||||
#define A_LIGHT_ATTENUATION(destName, input, worldPos) fixed destName = UNITY_SHADOW_ATTENUATION(input, worldPos); o.PositionWorld = worldPos; o.Shadow = destName;
|
||||
|
||||
#ifdef POINT
|
||||
sampler2D _LightTexture0;
|
||||
unityShadowCoord4x4 unity_WorldToLight;
|
||||
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) A_LIGHT_ATTENUATION(destName, input, worldPos)
|
||||
#endif
|
||||
|
||||
#ifdef SPOT
|
||||
sampler2D _LightTexture0;
|
||||
unityShadowCoord4x4 unity_WorldToLight;
|
||||
sampler2D _LightTextureB0;
|
||||
inline fixed UnitySpotCookie(unityShadowCoord4 LightCoord)
|
||||
{
|
||||
return tex2D(_LightTexture0, LightCoord.xy / LightCoord.w + 0.5).w;
|
||||
}
|
||||
inline fixed UnitySpotAttenuate(unityShadowCoord3 LightCoord)
|
||||
{
|
||||
return tex2D(_LightTextureB0, dot(LightCoord, LightCoord).xx).UNITY_ATTEN_CHANNEL;
|
||||
}
|
||||
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) A_LIGHT_ATTENUATION(destName, input, worldPos)
|
||||
#endif
|
||||
|
||||
#ifdef DIRECTIONAL
|
||||
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) A_LIGHT_ATTENUATION(destName, input, worldPos)
|
||||
#endif
|
||||
|
||||
#ifdef POINT_COOKIE
|
||||
samplerCUBE _LightTexture0;
|
||||
unityShadowCoord4x4 unity_WorldToLight;
|
||||
sampler2D _LightTextureB0;
|
||||
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) A_LIGHT_ATTENUATION(destName, input, worldPos)
|
||||
#endif
|
||||
|
||||
#ifdef DIRECTIONAL_COOKIE
|
||||
sampler2D _LightTexture0;
|
||||
unityShadowCoord4x4 unity_WorldToLight;
|
||||
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) A_LIGHT_ATTENUATION(destName, input, worldPos)
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------
|
||||
// Light/Shadow helpers (4.x version)
|
||||
// -----------------------------
|
||||
// This version computes light coordinates in the vertex shader and passes them to the fragment shader.
|
||||
|
||||
// ---- Spot light shadows
|
||||
#if defined (SHADOWS_DEPTH) && defined (SPOT)
|
||||
#define SHADOW_COORDS(idx1) unityShadowCoord4 _ShadowCoord : TEXCOORD##idx1;
|
||||
#define TRANSFER_SHADOW(a) a._ShadowCoord = mul (unity_WorldToShadow[0], mul(unity_ObjectToWorld,v.vertex));
|
||||
#define SHADOW_ATTENUATION(a) UnitySampleShadowmap(a._ShadowCoord)
|
||||
#endif
|
||||
|
||||
// ---- Point light shadows
|
||||
#if defined (SHADOWS_CUBE)
|
||||
#define SHADOW_COORDS(idx1) unityShadowCoord3 _ShadowCoord : TEXCOORD##idx1;
|
||||
#define TRANSFER_SHADOW(a) a._ShadowCoord = mul(unity_ObjectToWorld, v.vertex).xyz - _LightPositionRange.xyz;
|
||||
#define SHADOW_ATTENUATION(a) UnitySampleShadowmap(a._ShadowCoord)
|
||||
#endif
|
||||
|
||||
// ---- Shadows off
|
||||
#if !defined (SHADOWS_SCREEN) && !defined (SHADOWS_DEPTH) && !defined (SHADOWS_CUBE)
|
||||
#define SHADOW_COORDS(idx1)
|
||||
#define TRANSFER_SHADOW(a)
|
||||
#define SHADOW_ATTENUATION(a) 1.0
|
||||
#endif
|
||||
|
||||
#ifdef POINT
|
||||
#define LIGHTING_COORDS(idx1,idx2) unityShadowCoord3 _LightCoord : TEXCOORD##idx1; SHADOW_COORDS(idx2)
|
||||
#define TRANSFER_VERTEX_TO_FRAGMENT(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xyz; TRANSFER_SHADOW(a)
|
||||
#define LIGHT_ATTENUATION(a) (tex2D(_LightTexture0, dot(a._LightCoord,a._LightCoord).rr).UNITY_ATTEN_CHANNEL * SHADOW_ATTENUATION(a))
|
||||
#endif
|
||||
|
||||
#ifdef SPOT
|
||||
#define LIGHTING_COORDS(idx1,idx2) unityShadowCoord4 _LightCoord : TEXCOORD##idx1; SHADOW_COORDS(idx2)
|
||||
#define TRANSFER_VERTEX_TO_FRAGMENT(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)); TRANSFER_SHADOW(a)
|
||||
#define LIGHT_ATTENUATION(a) ( (a._LightCoord.z > 0) * UnitySpotCookie(a._LightCoord) * UnitySpotAttenuate(a._LightCoord.xyz) * SHADOW_ATTENUATION(a) )
|
||||
#endif
|
||||
|
||||
#ifdef DIRECTIONAL
|
||||
#define LIGHTING_COORDS(idx1,idx2) SHADOW_COORDS(idx1)
|
||||
#define TRANSFER_VERTEX_TO_FRAGMENT(a) TRANSFER_SHADOW(a)
|
||||
#define LIGHT_ATTENUATION(a) SHADOW_ATTENUATION(a)
|
||||
#endif
|
||||
|
||||
#ifdef POINT_COOKIE
|
||||
#define LIGHTING_COORDS(idx1,idx2) unityShadowCoord3 _LightCoord : TEXCOORD##idx1; SHADOW_COORDS(idx2)
|
||||
#define TRANSFER_VERTEX_TO_FRAGMENT(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xyz; TRANSFER_SHADOW(a)
|
||||
#define LIGHT_ATTENUATION(a) (tex2D(_LightTextureB0, dot(a._LightCoord,a._LightCoord).rr).UNITY_ATTEN_CHANNEL * texCUBE(_LightTexture0, a._LightCoord).w * SHADOW_ATTENUATION(a))
|
||||
#endif
|
||||
|
||||
#ifdef DIRECTIONAL_COOKIE
|
||||
#define LIGHTING_COORDS(idx1,idx2) unityShadowCoord2 _LightCoord : TEXCOORD##idx1; SHADOW_COORDS(idx2)
|
||||
#define TRANSFER_VERTEX_TO_FRAGMENT(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xy; TRANSFER_SHADOW(a)
|
||||
#define LIGHT_ATTENUATION(a) (tex2D(_LightTexture0, a._LightCoord).w * SHADOW_ATTENUATION(a))
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c3796affbfb7ee4ba5801737958249b
|
||||
timeCreated: 1433979826
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45bde337d21826b4a90e633a4d6b2346
|
||||
timeCreated: 1437435754
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,209 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
#ifndef UNITY_PBS_LIGHTING_INCLUDED
|
||||
#define UNITY_PBS_LIGHTING_INCLUDED
|
||||
|
||||
// Alloy.
|
||||
#define A_TANGENT_TO_WORLD_ON
|
||||
|
||||
#if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_FORWARDADD) || defined(UNITY_PASS_DEFERRED)
|
||||
#define A_AMBIENT_OCCLUSION_ON
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_DEFERRED) || defined(UNITY_PASS_META)
|
||||
#define A_EMISSIVE_COLOR_ON
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_FORWARDADD)
|
||||
#define A_DIRECT_LIGHTING_PASS
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_DEFERRED)
|
||||
#define A_INDIRECT_LIGHTING_PASS
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_PASS_DEFERRED)
|
||||
#define A_GBUFFER_PASS
|
||||
#endif
|
||||
|
||||
#include "Assets/Alloy/Shaders/Lighting/Standard.cginc"
|
||||
#include "Assets/Alloy/Shaders/Framework/Unity.cginc"
|
||||
|
||||
#include "UnityShaderVariables.cginc"
|
||||
#include "UnityStandardConfig.cginc"
|
||||
#include "UnityLightingCommon.cginc"
|
||||
#include "UnityGBuffer.cginc"
|
||||
#include "UnityGlobalIllumination.cginc"
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Default BRDF to use:
|
||||
#if !defined (UNITY_BRDF_PBS) // allow to explicitly override BRDF in custom shader
|
||||
// still add safe net for low shader models, otherwise we might end up with shaders failing to compile
|
||||
#if SHADER_TARGET < 30
|
||||
#define UNITY_BRDF_PBS BRDF3_Unity_PBS
|
||||
#elif defined(UNITY_PBS_USE_BRDF3)
|
||||
#define UNITY_BRDF_PBS BRDF3_Unity_PBS
|
||||
#elif defined(UNITY_PBS_USE_BRDF2)
|
||||
#define UNITY_BRDF_PBS BRDF2_Unity_PBS
|
||||
#elif defined(UNITY_PBS_USE_BRDF1)
|
||||
#define UNITY_BRDF_PBS BRDF1_Unity_PBS
|
||||
#elif defined(SHADER_TARGET_SURFACE_ANALYSIS)
|
||||
// we do preprocess pass during shader analysis and we dont actually care about brdf as we need only inputs/outputs
|
||||
#define UNITY_BRDF_PBS BRDF1_Unity_PBS
|
||||
#else
|
||||
#error something broke in auto-choosing BRDF
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// little helpers for GI calculation
|
||||
// CAUTION: This is deprecated and not use in Untiy shader code, but some asset store plugin still use it, so let here for compatibility
|
||||
|
||||
#if !defined (UNITY_BRDF_GI)
|
||||
#define UNITY_BRDF_GI BRDF_Unity_Indirect
|
||||
#endif
|
||||
|
||||
inline half3 BRDF_Unity_Indirect (half3 baseColor, half3 specColor, half oneMinusReflectivity, half smoothness, half3 normal, half3 viewDir, half occlusion, UnityGI gi)
|
||||
{
|
||||
return half3(0,0,0);
|
||||
}
|
||||
|
||||
#define UNITY_GLOSSY_ENV_FROM_SURFACE(x, s, data) \
|
||||
Unity_GlossyEnvironmentData g; \
|
||||
g.roughness /* perceptualRoughness */ = SmoothnessToPerceptualRoughness(s.Smoothness); \
|
||||
g.reflUVW = reflect(-data.worldViewDir, s.Normal); \
|
||||
|
||||
|
||||
#if defined(UNITY_PASS_DEFERRED) && UNITY_ENABLE_REFLECTION_BUFFERS
|
||||
#define UNITY_GI(x, s, data) x = UnityGlobalIllumination (data, s.Occlusion, s.Normal);
|
||||
#else
|
||||
#define UNITY_GI(x, s, data) \
|
||||
UNITY_GLOSSY_ENV_FROM_SURFACE(g, s, data); \
|
||||
x = UnityGlobalIllumination (data, s.Occlusion, s.Normal, g);
|
||||
#endif
|
||||
|
||||
// Surface shader output structure to be used with physically
|
||||
// based shading model.
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Metallic workflow
|
||||
|
||||
struct SurfaceOutputStandard
|
||||
{
|
||||
fixed3 Albedo; // base (diffuse or specular) color
|
||||
fixed3 Normal; // tangent space normal, if written
|
||||
half3 Emission;
|
||||
half Metallic; // 0=non-metal, 1=metal
|
||||
// Smoothness is the user facing name, it should be perceptual smoothness but user should not have to deal with it.
|
||||
// Everywhere in the code you meet smoothness it is perceptual smoothness
|
||||
half Smoothness; // 0=rough, 1=smooth
|
||||
half Occlusion; // occlusion (default 1)
|
||||
fixed Alpha; // alpha for transparencies
|
||||
float3 PositionWorld; // Alloy
|
||||
half Shadow; // Alloy
|
||||
};
|
||||
|
||||
ASurface aStandardSurface(
|
||||
SurfaceOutputStandard si,
|
||||
half3 viewDir)
|
||||
{
|
||||
half oneMinusReflectivity;
|
||||
ASurface s = aNewSurface();
|
||||
|
||||
s.albedo = DiffuseAndSpecularFromMetallic(si.Albedo, si.Metallic, /*out*/ s.f0, /*out*/ oneMinusReflectivity);
|
||||
|
||||
#ifndef UNITY_PASS_DEFERRED
|
||||
s.albedo = PreMultiplyAlpha(s.albedo, si.Alpha, oneMinusReflectivity, /*out*/ s.opacity);
|
||||
#endif
|
||||
|
||||
s.viewDirWorld = viewDir;
|
||||
s.positionWorld = si.PositionWorld;
|
||||
s.normalWorld = A_NW(s, normalize(si.Normal));
|
||||
s.roughness = 1.0h - si.Smoothness;
|
||||
s.ambientOcclusion = si.Occlusion;
|
||||
s.emissiveColor = si.Emission;
|
||||
aUnitySurface(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline half4 LightingStandard (SurfaceOutputStandard si, half3 viewDir, UnityGI gi)
|
||||
{
|
||||
ASurface s = aStandardSurface(si, viewDir);
|
||||
return aUnityLighting(s, gi, si.Shadow);
|
||||
}
|
||||
|
||||
inline half4 LightingStandard_Deferred (SurfaceOutputStandard si, half3 viewDir, UnityGI gi, out half4 outGBuffer0, out half4 outGBuffer1, out half4 outGBuffer2)
|
||||
{
|
||||
ASurface s = aStandardSurface(si, viewDir);
|
||||
return aUnityLightingDeferred(s, gi, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||
}
|
||||
|
||||
inline void LightingStandard_GI (
|
||||
SurfaceOutputStandard s,
|
||||
UnityGIInput data,
|
||||
inout UnityGI gi)
|
||||
{
|
||||
aUnityLightingGi(gi, data, s.Normal, s.Smoothness, lerp(unity_ColorSpaceDielectricSpec.rgb, s.Albedo, s.Metallic));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Specular workflow
|
||||
|
||||
struct SurfaceOutputStandardSpecular
|
||||
{
|
||||
fixed3 Albedo; // diffuse color
|
||||
fixed3 Specular; // specular color
|
||||
fixed3 Normal; // tangent space normal, if written
|
||||
half3 Emission;
|
||||
half Smoothness; // 0=rough, 1=smooth
|
||||
half Occlusion; // occlusion (default 1)
|
||||
fixed Alpha; // alpha for transparencies
|
||||
float3 PositionWorld; // Alloy
|
||||
half Shadow; // Alloy
|
||||
};
|
||||
|
||||
ASurface aStandardSpecularSurface(
|
||||
SurfaceOutputStandardSpecular si,
|
||||
half3 viewDir)
|
||||
{
|
||||
half oneMinusReflectivity;
|
||||
ASurface s = aNewSurface();
|
||||
|
||||
s.albedo = EnergyConservationBetweenDiffuseAndSpecular(si.Albedo, si.Specular, /*out*/ oneMinusReflectivity);
|
||||
s.f0 = si.Specular;
|
||||
|
||||
#ifndef UNITY_PASS_DEFERRED
|
||||
s.albedo = PreMultiplyAlpha(s.albedo, si.Alpha, oneMinusReflectivity, /*out*/ s.opacity);
|
||||
#endif
|
||||
|
||||
s.viewDirWorld = viewDir;
|
||||
s.positionWorld = si.PositionWorld;
|
||||
s.normalWorld = A_NW(s, normalize(si.Normal));
|
||||
s.roughness = 1.0h - si.Smoothness;
|
||||
s.ambientOcclusion = si.Occlusion;
|
||||
s.emissiveColor = si.Emission;
|
||||
aUnitySurface(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline half4 LightingStandardSpecular (SurfaceOutputStandardSpecular si, half3 viewDir, UnityGI gi)
|
||||
{
|
||||
ASurface s = aStandardSpecularSurface(si, viewDir);
|
||||
return aUnityLighting(s, gi, si.Shadow);
|
||||
}
|
||||
|
||||
inline half4 LightingStandardSpecular_Deferred (SurfaceOutputStandardSpecular si, half3 viewDir, UnityGI gi, out half4 outGBuffer0, out half4 outGBuffer1, out half4 outGBuffer2)
|
||||
{
|
||||
ASurface s = aStandardSpecularSurface(si, viewDir);
|
||||
return aUnityLightingDeferred(s, gi, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||
}
|
||||
|
||||
inline void LightingStandardSpecular_GI (
|
||||
SurfaceOutputStandardSpecular s,
|
||||
UnityGIInput data,
|
||||
inout UnityGI gi)
|
||||
{
|
||||
aUnityLightingGi(gi, data, s.Normal, s.Smoothness, s.Specular);
|
||||
}
|
||||
|
||||
#endif // UNITY_PBS_LIGHTING_INCLUDED
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b87791ddd81b476429c53e287d249e41
|
||||
timeCreated: 1434755007
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user