Paul Melamed
7 年前
当前提交
982555b5
共有 7 个文件被更改,包括 190 次插入 和 0 次删除
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
-
130ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/Decal.shader
-
8ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/DecalProperties.hlsl
-
9ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/OutputBuffers.hlsl
-
41ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/ShaderPass/ShaderPassDBuffer.hlsl
|
|||
Shader "HDRenderPipeline/Decal" |
|||
{ |
|||
Properties |
|||
{ |
|||
_BaseColorMap("BaseColorMap", 2D) = "white" {} |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go futher in dev |
|||
//#pragma enable_d3d11_debug_symbols |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Variant |
|||
//------------------------------------------------------------------------------------- |
|||
/* |
|||
#pragma shader_feature _ALPHATEST_ON |
|||
#pragma shader_feature _DEPTHOFFSET_ON |
|||
#pragma shader_feature _DOUBLESIDED_ON |
|||
#pragma shader_feature _ _VERTEX_DISPLACEMENT _PIXEL_DISPLACEMENT |
|||
#pragma shader_feature _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE |
|||
#pragma shader_feature _DISPLACEMENT_LOCK_TILING_SCALE |
|||
#pragma shader_feature _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE |
|||
#pragma shader_feature _VERTEX_WIND |
|||
#pragma shader_feature _ _REFRACTION_PLANE _REFRACTION_SPHERE |
|||
|
|||
#pragma shader_feature _ _MAPPING_PLANAR _MAPPING_TRIPLANAR |
|||
#pragma shader_feature _NORMALMAP_TANGENT_SPACE |
|||
#pragma shader_feature _ _REQUIRE_UV2 _REQUIRE_UV3 |
|||
|
|||
#pragma shader_feature _NORMALMAP |
|||
#pragma shader_feature _MASKMAP |
|||
#pragma shader_feature _BENTNORMALMAP |
|||
#pragma shader_feature _EMISSIVE_COLOR_MAP |
|||
#pragma shader_feature _ENABLESPECULAROCCLUSION |
|||
#pragma shader_feature _HEIGHTMAP |
|||
#pragma shader_feature _TANGENTMAP |
|||
#pragma shader_feature _ANISOTROPYMAP |
|||
#pragma shader_feature _DETAIL_MAP |
|||
#pragma shader_feature _SUBSURFACE_RADIUS_MAP |
|||
#pragma shader_feature _THICKNESSMAP |
|||
#pragma shader_feature _SPECULARCOLORMAP |
|||
|
|||
// Keyword for transparent |
|||
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT |
|||
#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY |
|||
#pragma shader_feature _BLENDMODE_PRESERVE_SPECULAR_LIGHTING |
|||
#pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT |
|||
|
|||
// MaterialId are used as shader feature to allow compiler to optimize properly |
|||
// Note _MATID_STANDARD is not define as there is always the default case "_". We assign default as _MATID_STANDARD, so we never test _MATID_STANDARD |
|||
#pragma shader_feature _ _MATID_SSS _MATID_ANISO _MATID_SPECULAR _MATID_CLEARCOAT |
|||
|
|||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON |
|||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED |
|||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON |
|||
// enable dithering LOD crossfade |
|||
#pragma multi_compile _ LOD_FADE_CROSSFADE |
|||
// TODO: We should have this keyword only if VelocityInGBuffer is enable, how to do that ? |
|||
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON |
|||
*/ |
|||
|
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Define |
|||
//------------------------------------------------------------------------------------- |
|||
/* |
|||
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl |
|||
// Use surface gradient normal mapping as it handle correctly triplanar normal mapping and multiple UVSet |
|||
#define SURFACE_GRADIENT |
|||
// This shader support vertex modification |
|||
#define HAVE_VERTEX_MODIFICATION |
|||
*/ |
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
|
|||
#include "../../../Core/ShaderLibrary/Common.hlsl" |
|||
|
|||
// #include "../../../Core/ShaderLibrary/Wind.hlsl" |
|||
#include "../../ShaderPass/FragInputs.hlsl" |
|||
// #include "../../ShaderPass/ShaderPass.cs.hlsl" |
|||
|
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "DecalProperties.hlsl" |
|||
|
|||
// All our shaders use same name for entry point |
|||
#pragma vertex Vert |
|||
#pragma fragment Frag |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Pass |
|||
{ |
|||
Name "DBuffer" // Name is not used |
|||
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index |
|||
|
|||
Cull [_CullMode] |
|||
|
|||
Stencil |
|||
{ |
|||
Ref [_StencilRef] |
|||
Comp Always |
|||
Pass Replace |
|||
} |
|||
|
|||
HLSLPROGRAM |
|||
#define SHADERPASS_DBUFFER |
|||
|
|||
#include "../../ShaderVariables.hlsl" |
|||
#include "OutputBuffers.hlsl" |
|||
// #include "../../Material/Material.hlsl" |
|||
// #include "ShaderPass/LitSharePass.hlsl" |
|||
// #include "LitData.hlsl" |
|||
#include "../../ShaderPass/VaryingMesh.hlsl" |
|||
#include "ShaderPass/ShaderPassDBuffer.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
// CustomEditor "Experimental.Rendering.HDPipeline.LitGUI" |
|||
} |
|
|||
#ifndef UNITY_DECALPROPERTIES_INCLUDED |
|||
#define UNITY_DECALPROPERTIES_INCLUDED |
|||
|
|||
|
|||
TEXTURE2D(_BaseColorMap); |
|||
SAMPLER2D(sampler_BaseColorMap); |
|||
|
|||
#endif |
|
|||
#ifndef UNITY_DECALOUTPUTBUFFERS_INCLUDED |
|||
#define UNITY_DECALOUTPUTBUFFERS_INCLUDED |
|||
|
|||
#define DBufferType0 uint4 |
|||
|
|||
#define OUTPUT_DBUFFER(NAME) \ |
|||
out DBufferType0 MERGE_NAME(NAME, 0) : SV_Target0 |
|||
|
|||
#endif |
|
|||
#if SHADERPASS != SHADERPASS_GBUFFER |
|||
#error SHADERPASS_is_not_correctly_define |
|||
#endif |
|||
|
|||
#include "..\..\ShaderPass\VertMesh.hlsl" |
|||
|
|||
PackedVaryingsType Vert(AttributesMesh inputMesh) |
|||
{ |
|||
VaryingsType varyingsType; |
|||
varyingsType.vmesh = VertMesh(inputMesh); |
|||
return PackVaryingsType(varyingsType); |
|||
} |
|||
|
|||
|
|||
void Frag( PackedVaryingsToPS packedInput, |
|||
OUTPUT_DBUFFER(outDBuffer) |
|||
) |
|||
{ |
|||
/* |
|||
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh); |
|||
|
|||
// input.unPositionSS is SV_Position |
|||
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw); |
|||
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS); |
|||
|
|||
SurfaceData surfaceData; |
|||
BuiltinData builtinData; |
|||
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); |
|||
|
|||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData); |
|||
|
|||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); |
|||
|
|||
float3 bakeDiffuseLighting = GetBakedDiffuseLigthing(surfaceData, builtinData, bsdfData, preLightData); |
|||
|
|||
ENCODE_INTO_GBUFFER(surfaceData, bakeDiffuseLighting, outGBuffer); |
|||
ENCODE_VELOCITY_INTO_GBUFFER(builtinData.velocity, outVelocityBuffer); |
|||
*/ |
|||
outDBuffer0.rgba = uint4(255,0,0,255); |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue