浏览代码
Merge pull request #1857 from Unity-Technologies/HDRP/decals/v2_1/normal_buffer
Merge pull request #1857 from Unity-Technologies/HDRP/decals/v2_1/normal_buffer
Hdrp/decals/v2 1/normal buffer/hdrp-staging
GitHub
6 年前
当前提交
92fa3473
共有 17 个文件被更改,包括 335 次插入 和 19 次删除
-
1com.unity.render-pipelines.high-definition/CHANGELOG.md
-
7com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Decal/DecalUI.cs
-
6com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitUI.cs
-
150com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader
-
3com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalProjectorComponent.cs
-
6com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalUtilities.hlsl
-
7com.unity.render-pipelines.high-definition/HDRP/Material/GBufferManager.cs
-
9com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.cs
-
5com.unity.render-pipelines.high-definition/HDRP/Material/RenderPipelineMaterial.cs
-
10com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader
-
5com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitData.hlsl
-
1com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDCustomSamplerId.cs
-
40com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
-
2com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs
-
6com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/RenderPipelineResources.cs
-
87com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalNormalBuffer.shader
-
9com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalNormalBuffer.shader.meta
|
|||
Shader "Hidden/HDRenderPipeline/Material/Decal/DecalNormalBuffer" |
|||
{ |
|||
|
|||
Properties |
|||
{ |
|||
// Stencil state |
|||
[HideInInspector] _DecalNormalBufferStencilRef("_DecalNormalBufferStencilRef", Int) = 0 // set at runtime |
|||
[HideInInspector] _DecalNormalBufferStencilReadMask("_DecalNormalBufferStencilReadMask", Int) = 0 // set at runtime |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch |
|||
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|||
#include "../../ShaderVariables.hlsl" |
|||
#include "Decal.hlsl" |
|||
#include "../NormalBuffer.hlsl" |
|||
|
|||
RW_TEXTURE2D(float4, _NormalBuffer); |
|||
|
|||
struct Attributes |
|||
{ |
|||
uint vertexID : SV_VertexID; |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 positionCS : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
DECLARE_DBUFFER_TEXTURE(_DBufferTexture); |
|||
|
|||
Varyings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); |
|||
output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID); |
|||
return output; |
|||
} |
|||
|
|||
float4 FragNearest(Varyings input) : SV_Target |
|||
{ |
|||
FETCH_DBUFFER(DBuffer, _DBufferTexture, input.texcoord * _ScreenSize.xy); |
|||
DecalSurfaceData decalSurfaceData; |
|||
DECODE_FROM_DBUFFER(DBuffer, decalSurfaceData); |
|||
|
|||
float4 GBufferNormal = _NormalBuffer[input.texcoord * _ScreenSize.xy]; |
|||
NormalData normalData; |
|||
DecodeFromNormalBuffer(GBufferNormal, uint2(0, 0), normalData); |
|||
normalData.normalWS.xyz = normalize(normalData.normalWS.xyz * decalSurfaceData.normalWS.w + decalSurfaceData.normalWS.xyz); |
|||
EncodeIntoNormalBuffer(normalData, uint2(0, 0), GBufferNormal); |
|||
_NormalBuffer[input.texcoord * _ScreenSize.xy] = GBufferNormal; |
|||
return float4(0, 0, 0, 0); // normal buffer is written into as a RWTexture |
|||
} |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Tags{ "RenderPipeline" = "HDRenderPipeline" } |
|||
|
|||
Pass |
|||
{ |
|||
ZWrite Off |
|||
ZTest Always |
|||
Blend Off |
|||
Cull Off |
|||
|
|||
Stencil |
|||
{ |
|||
ReadMask[_DecalNormalBufferStencilReadMask] |
|||
Ref[_DecalNormalBufferStencilRef] |
|||
Comp Equal |
|||
Pass Zero // doesn't really matter, but clear to 0 for debugging |
|||
} |
|||
|
|||
HLSLPROGRAM |
|||
#pragma vertex Vert |
|||
#pragma fragment FragNearest |
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
Fallback Off |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fd532bf1795188c4daaa66ea798b8b0a |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue