浏览代码
Merge pull request #941 from Unity-Technologies/LW-ScreenSpaceShadows
Merge pull request #941 from Unity-Technologies/LW-ScreenSpaceShadows
Lw screen space shadows/main
GitHub
7 年前
当前提交
ee1e6968
共有 14 个文件被更改,包括 266 次插入 和 182 次删除
-
5ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
-
2ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineResources.asset
-
1ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineResources.cs
-
122ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
-
30ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Core.hlsl
-
9ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl
-
4ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl
-
6ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassShadow.hlsl
-
151ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Shadows.hlsl
-
8ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandard.shader
-
8ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardSimpleLighting.shader
-
8ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardTerrain.shader
-
85ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader
-
9ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader.meta
|
|||
Shader "Hidden/LightweightPipeline/ScreenSpaceShadows" |
|||
{ |
|||
SubShader |
|||
{ |
|||
Tags{ "RenderPipeline" = "LightweightPipeline" } |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
//Keep compiler quiet about Shadows.hlsl. |
|||
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|||
#include "CoreRP/ShaderLibrary/EntityLighting.hlsl" |
|||
#include "CoreRP/ShaderLibrary/ImageBasedLighting.hlsl" |
|||
#include "LWRP/ShaderLibrary/Core.hlsl" |
|||
#include "LWRP/ShaderLibrary/Shadows.hlsl" |
|||
|
|||
TEXTURE2D(_CameraDepthTexture); |
|||
SAMPLER(sampler_CameraDepthTexture); |
|||
|
|||
struct VertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct Interpolators |
|||
{ |
|||
half4 pos : SV_POSITION; |
|||
half4 texcoord : TEXCOORD0; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
Interpolators Vertex(VertexInput i) |
|||
{ |
|||
Interpolators o; |
|||
UNITY_SETUP_INSTANCE_ID(i); |
|||
UNITY_TRANSFER_INSTANCE_ID(i, o); |
|||
|
|||
o.pos = TransformObjectToHClip(i.vertex.xyz); |
|||
|
|||
float4 projPos = o.pos * 0.5; |
|||
projPos.xy = projPos.xy + projPos.w; |
|||
|
|||
o.texcoord.xy = i.texcoord; |
|||
o.texcoord.zw = projPos.xy; |
|||
|
|||
return o; |
|||
} |
|||
|
|||
half Fragment(Interpolators i) : SV_Target |
|||
{ |
|||
UNITY_SETUP_INSTANCE_ID(i); |
|||
|
|||
float deviceDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy); |
|||
|
|||
#if UNITY_REVERSED_Z |
|||
deviceDepth = 1 - deviceDepth; |
|||
#endif |
|||
deviceDepth = 2 * deviceDepth - 1; //NOTE: Currently must massage depth before computing CS position. |
|||
|
|||
float3 vpos = ComputeViewSpacePosition(i.texcoord.zw, deviceDepth, unity_CameraInvProjection); |
|||
float3 wpos = mul(unity_CameraToWorld, float4(vpos, 1)).xyz; |
|||
|
|||
//Fetch shadow coordinates for cascade. |
|||
float4 coords = ComputeShadowCoord(wpos); |
|||
|
|||
return SampleShadowmap(coords); |
|||
} |
|||
|
|||
ENDHLSL |
|||
|
|||
Pass |
|||
{ |
|||
ZTest Always ZWrite Off |
|||
|
|||
HLSLPROGRAM |
|||
#pragma multi_compile _ _SHADOWS_SOFT |
|||
#pragma multi_compile _ _SHADOWS_CASCADE |
|||
|
|||
#pragma vertex Vertex |
|||
#pragma fragment Fragment |
|||
ENDHLSL |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0f854b35a0cf61a429bd5dcfea30eddd |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue