浏览代码
Merge remote-tracking branch 'origin/master' into scriptablerenderloop-materialgraph
/scriptablerenderloop-materialgraph
Merge remote-tracking branch 'origin/master' into scriptablerenderloop-materialgraph
/scriptablerenderloop-materialgraph
Paul Demeulenaere
8 年前
当前提交
99a7625b
共有 55 个文件被更改,包括 357 次插入 和 308 次删除
-
2Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset.meta
-
2Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
-
1Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl
-
2Assets/TestScenes/HDTest/Leaf/GroundLeaf/Materials/GroundLeaf_Albedo.mat
-
7Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Blue_Alpha.mat
-
9Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/CubeTransparent.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Gray.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Green.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Ground/Ground_01_2x2.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Ground/Needle_Moss_1x1.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Ground/Sand_02_2x2_02.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Red.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Terrain.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test-alpha.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test-transparent.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test-twosidedLighting.mat
-
2Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test.mat
-
16Assets/TestScenes/HDTest/Rock/rcgRock012/Materials/rcgRock012Material.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_0.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_1.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_2.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_3.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_4.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_5.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_6.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_7.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_8.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth0_9.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smooth1_1.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_0.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_1.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_2.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_3.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_4.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_5.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_6.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_7.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_8.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric0_9.mat
-
2Assets/TestScenes/HDTest/Spheres/Mat_smoothdielectric1_0.mat
-
157Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/DefaultLit.shader
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/DefaultLit.shader.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitCommon.hlsl.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass.meta
-
32Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassDebugViewMaterial.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassDebugViewMaterial.hlsl.meta
-
26Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassForward.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassForward.hlsl.meta
-
30Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassGBuffer.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassGBuffer.hlsl.meta
-
243Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.shader
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.shader.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitTemplate.hlsl.meta
-
0/Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitCommon.hlsl
|
|||
fileFormatVersion: 2 |
|||
guid: 2400b74f5ce370c4481e5dc417d03703 |
|||
timeCreated: 1476868799 |
|||
timeCreated: 1476885643 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: |
|
|||
Shader "Unity/Lit" |
|||
{ |
|||
Properties |
|||
{ |
|||
// Following set of parameters represent the parameters node inside the MaterialGraph. |
|||
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist. |
|||
|
|||
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear |
|||
_BaseColor("BaseColor", Color) = (1,1,1,1) |
|||
_BaseColorMap("BaseColorMap", 2D) = "white" {} |
|||
|
|||
_Metalic("_Metalic", Range(0.0, 1.0)) = 0 |
|||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 |
|||
_MaskMap("MaskMap", 2D) = "white" {} |
|||
|
|||
_SpecularOcclusionMap("SpecularOcclusion", 2D) = "white" {} |
|||
|
|||
_NormalMap("NormalMap", 2D) = "bump" {} |
|||
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 |
|||
|
|||
_HeightMap("HeightMap", 2D) = "black" {} |
|||
_HeightScale("Height Scale", Float) = 1 |
|||
_HeightBias("Height Bias", Float) = 0 |
|||
[Enum(Parallax, 0, Displacement, 1)] _HeightMapMode("Heightmap usage", Float) = 0 |
|||
|
|||
_SubSurfaceRadius("SubSurfaceRadius", Range(0.0, 1.0)) = 0 |
|||
_SubSurfaceRadiusMap("SubSurfaceRadiusMap", 2D) = "white" {} |
|||
//_Thickness("Thickness", Range(0.0, 1.0)) = 0 |
|||
//_ThicknessMap("ThicknessMap", 2D) = "white" {} |
|||
//_SubSurfaceProfile("SubSurfaceProfile", Float) = 0 |
|||
|
|||
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0 |
|||
//_CoatCoverageMap("CoatCoverageMapMap", 2D) = "white" {} |
|||
|
|||
//_CoatRoughness("CoatRoughness", Range(0.0, 1.0)) = 0 |
|||
//_CoatRoughnessMap("CoatRoughnessMap", 2D) = "white" {} |
|||
|
|||
// _DistortionVectorMap("DistortionVectorMap", 2D) = "white" {} |
|||
// _DistortionBlur("DistortionBlur", Range(0.0, 1.0)) = 0 |
|||
|
|||
// Following options are for the GUI inspector and different from the input parameters above |
|||
// These option below will cause different compilation flag. |
|||
|
|||
_DiffuseLightingMap("DiffuseLightingMap", 2D) = "black" {} |
|||
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0) |
|||
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} |
|||
_EmissiveIntensity("EmissiveIntensity", Float) = 0 |
|||
|
|||
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0 |
|||
[ToggleOff] _DistortionDepthTest("Distortion Only", Float) = 0.0 |
|||
|
|||
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 |
|||
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
// Blending state |
|||
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 |
|||
[HideInInspector] _BlendMode ("__blendmode", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite ("__zw", Float) = 1.0 |
|||
[HideInInspector] _CullMode("__cullmode", Float) = 2.0 |
|||
// Material Id |
|||
[HideInInspector] _MaterialId("_MaterialId", FLoat) = 0 |
|||
|
|||
[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1 |
|||
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 |
|||
[Enum(None, 0, DoubleSided, 1, DoubleSidedLigthingFlip, 2, DoubleSidedLigthingMirror, 3)] _DoubleSidedMode("Double sided mode", Float) = 0 |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 5.0 |
|||
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev |
|||
|
|||
#pragma shader_feature _ALPHATEST_ON |
|||
#pragma shader_feature _ _DOUBLESIDED_LIGHTING_FLIP _DOUBLESIDED_LIGHTING_MIRROR |
|||
#pragma shader_feature _NORMALMAP |
|||
#pragma shader_feature _NORMALMAP_TANGENT_SPACE |
|||
#pragma shader_feature _MASKMAP |
|||
#pragma shader_feature _SPECULAROCCLUSIONMAP |
|||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature _EMISSIVE_COLOR |
|||
#pragma shader_feature _EMISSIVE_COLOR_MAP |
|||
#pragma shader_feature _HEIGHTMAP |
|||
#pragma shader_feature _HEIGHTMAP_AS_DISPLACEMENT |
|||
|
|||
#include "LitCommon.hlsl" |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" } |
|||
LOD 300 |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// Deferred pass |
|||
Pass |
|||
{ |
|||
Name "GBuffer" // Name is not used |
|||
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index |
|||
|
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertDefault |
|||
#pragma fragment Frag |
|||
|
|||
#include "../../ShaderPass/ShaderPassGBuffer.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// Debug pass |
|||
Pass |
|||
{ |
|||
Name "Debug" |
|||
Tags { "LightMode" = "DebugViewMaterial" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertDefault |
|||
#pragma fragment Frag |
|||
|
|||
#include "../../ShaderPass/ShaderPassDebugViewMaterial.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// forward pass |
|||
Pass |
|||
{ |
|||
Name "Forward" // Name is not used |
|||
Tags { "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index |
|||
|
|||
Blend [_SrcBlend] [_DstBlend] |
|||
ZWrite [_ZWrite] |
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertDefault |
|||
#pragma fragment Frag |
|||
|
|||
#include "../../ShaderPass/ShaderPassForward.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
CustomEditor "LitGUI" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ef966ed93e262964781047eaf96991db |
|||
timeCreated: 1476885564 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8378596fcd29cf2459998acc0b0b5b8a |
|||
timeCreated: 1476885564 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 86e1905991f44ab49baa68fc4d0570e4 |
|||
folderAsset: yes |
|||
timeCreated: 1476885561 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#if SHADER_STAGE_FRAGMENT |
|||
|
|||
#include "Color.hlsl" |
|||
int _DebugViewMaterial; |
|||
|
|||
float4 Frag(PackedVaryings packedInput) : SV_Target |
|||
{ |
|||
Varyings input = UnpackVaryings(packedInput); |
|||
SurfaceData surfaceData; |
|||
BuiltinData builtinData; |
|||
GetSurfaceAndBuiltinData(input, surfaceData, builtinData); |
|||
|
|||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData); |
|||
|
|||
float3 result = float3(1.0, 1.0, 0.0); |
|||
bool needLinearToSRGB = false; |
|||
|
|||
GetVaryingsDataDebug(_DebugViewMaterial, input, result, needLinearToSRGB); |
|||
GetBuiltinDataDebug(_DebugViewMaterial, builtinData, result, needLinearToSRGB); |
|||
GetSurfaceDataDebug(_DebugViewMaterial, surfaceData, result, needLinearToSRGB); |
|||
GetBSDFDataDebug(_DebugViewMaterial, bsdfData, result, needLinearToSRGB); // TODO: This required to initialize all field from BSDFData... |
|||
|
|||
// TEMP! |
|||
// For now, the final blit in the backbuffer performs an sRGB write |
|||
// So in the meantime we apply the inverse transform to linear data to compensate. |
|||
if (!needLinearToSRGB) |
|||
result = SRGBToLinear(max(0, result)); |
|||
|
|||
return float4(result, 0.0); |
|||
} |
|||
|
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: e786716259fc05e4299d8dd2350471ef |
|||
timeCreated: 1476885564 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#if SHADER_STAGE_FRAGMENT |
|||
|
|||
float4 Frag(PackedVaryings packedInput) : SV_Target |
|||
{ |
|||
Varyings input = UnpackVaryings(packedInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS); |
|||
float3 positionWS = input.positionWS; |
|||
|
|||
SurfaceData surfaceData; |
|||
BuiltinData builtinData; |
|||
GetSurfaceAndBuiltinData(input, surfaceData, builtinData); |
|||
|
|||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData); |
|||
Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw); |
|||
PreLightData preLightData = GetPreLightData(V, positionWS, coord, bsdfData); |
|||
|
|||
float4 diffuseLighting; |
|||
float4 specularLighting; |
|||
ForwardLighting(V, positionWS, preLightData, bsdfData, diffuseLighting, specularLighting); |
|||
|
|||
diffuseLighting.rgb += GetBakedDiffuseLigthing(preLightData, surfaceData, builtinData, bsdfData); |
|||
|
|||
return float4(diffuseLighting.rgb + specularLighting.rgb, builtinData.opacity); |
|||
} |
|||
|
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: fcba5d34434ca2d4ba0e3a17aa46b4b1 |
|||
timeCreated: 1476885564 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#if SHADER_STAGE_FRAGMENT |
|||
|
|||
void Frag( PackedVaryings packedInput, |
|||
OUTPUT_GBUFFER(outGBuffer) |
|||
#ifdef VELOCITY_IN_GBUFFER |
|||
, OUTPUT_GBUFFER_VELOCITY(outGBuffer) |
|||
#endif |
|||
, OUTPUT_GBUFFER_BAKE_LIGHTING(outGBuffer) |
|||
) |
|||
{ |
|||
Varyings input = UnpackVaryings(packedInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS); |
|||
float3 positionWS = input.positionWS; |
|||
|
|||
SurfaceData surfaceData; |
|||
BuiltinData builtinData; |
|||
GetSurfaceAndBuiltinData(input, surfaceData, builtinData); |
|||
|
|||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData); |
|||
Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw); |
|||
PreLightData preLightData = GetPreLightData(V, positionWS, coord, bsdfData); |
|||
|
|||
ENCODE_INTO_GBUFFER(surfaceData, outGBuffer); |
|||
#ifdef VELOCITY_IN_GBUFFER |
|||
ENCODE_VELOCITY_INTO_GBUFFER(builtinData.velocity, outGBuffer); |
|||
#endif |
|||
ENCODE_BAKE_LIGHTING_INTO_GBUFFER(GetBakedDiffuseLigthing(preLightData, surfaceData, builtinData, bsdfData), outGBuffer); |
|||
} |
|||
|
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: bfcad7b1a4353ed4c8d77619baa740ca |
|||
timeCreated: 1476885564 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Unity/Lit" |
|||
{ |
|||
Properties |
|||
{ |
|||
// Following set of parameters represent the parameters node inside the MaterialGraph. |
|||
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist. |
|||
|
|||
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear |
|||
_BaseColor("BaseColor", Color) = (1,1,1,1) |
|||
_BaseColorMap("BaseColorMap", 2D) = "white" {} |
|||
|
|||
_Metalic("_Metalic", Range(0.0, 1.0)) = 0 |
|||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 |
|||
_MaskMap("MaskMap", 2D) = "white" {} |
|||
|
|||
_SpecularOcclusionMap("SpecularOcclusion", 2D) = "white" {} |
|||
|
|||
_NormalMap("NormalMap", 2D) = "bump" {} |
|||
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 |
|||
|
|||
_HeightMap("HeightMap", 2D) = "black" {} |
|||
_HeightScale("Height Scale", Float) = 1 |
|||
_HeightBias("Height Bias", Float) = 0 |
|||
[Enum(Parallax, 0, Displacement, 1)] _HeightMapMode("Heightmap usage", Float) = 0 |
|||
|
|||
_SubSurfaceRadius("SubSurfaceRadius", Range(0.0, 1.0)) = 0 |
|||
_SubSurfaceRadiusMap("SubSurfaceRadiusMap", 2D) = "white" {} |
|||
//_Thickness("Thickness", Range(0.0, 1.0)) = 0 |
|||
//_ThicknessMap("ThicknessMap", 2D) = "white" {} |
|||
//_SubSurfaceProfile("SubSurfaceProfile", Float) = 0 |
|||
|
|||
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0 |
|||
//_CoatCoverageMap("CoatCoverageMapMap", 2D) = "white" {} |
|||
|
|||
//_CoatRoughness("CoatRoughness", Range(0.0, 1.0)) = 0 |
|||
//_CoatRoughnessMap("CoatRoughnessMap", 2D) = "white" {} |
|||
|
|||
// _DistortionVectorMap("DistortionVectorMap", 2D) = "white" {} |
|||
// _DistortionBlur("DistortionBlur", Range(0.0, 1.0)) = 0 |
|||
|
|||
// Following options are for the GUI inspector and different from the input parameters above |
|||
// These option below will cause different compilation flag. |
|||
|
|||
_DiffuseLightingMap("DiffuseLightingMap", 2D) = "black" {} |
|||
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0) |
|||
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} |
|||
_EmissiveIntensity("EmissiveIntensity", Float) = 0 |
|||
|
|||
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0 |
|||
[ToggleOff] _DistortionDepthTest("Distortion Only", Float) = 0.0 |
|||
|
|||
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 |
|||
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
// Blending state |
|||
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 |
|||
[HideInInspector] _BlendMode ("__blendmode", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite ("__zw", Float) = 1.0 |
|||
[HideInInspector] _CullMode("__cullmode", Float) = 2.0 |
|||
// Material Id |
|||
[HideInInspector] _MaterialId("_MaterialId", FLoat) = 0 |
|||
|
|||
[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1 |
|||
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 |
|||
[Enum(None, 0, DoubleSided, 1, DoubleSidedLigthingFlip, 2, DoubleSidedLigthingMirror, 3)] _DoubleSidedMode("Double sided mode", Float) = 0 |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 5.0 |
|||
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev |
|||
|
|||
#pragma shader_feature _ALPHATEST_ON |
|||
#pragma shader_feature _ _DOUBLESIDED_LIGHTING_FLIP _DOUBLESIDED_LIGHTING_MIRROR |
|||
#pragma shader_feature _NORMALMAP |
|||
#pragma shader_feature _NORMALMAP_TANGENT_SPACE |
|||
#pragma shader_feature _MASKMAP |
|||
#pragma shader_feature _SPECULAROCCLUSIONMAP |
|||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature _EMISSIVE_COLOR |
|||
#pragma shader_feature _EMISSIVE_COLOR_MAP |
|||
#pragma shader_feature _HEIGHTMAP |
|||
#pragma shader_feature _HEIGHTMAP_AS_DISPLACEMENT |
|||
|
|||
#include "LitTemplate.hlsl" |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" } |
|||
LOD 300 |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// Deferred pass |
|||
Pass |
|||
{ |
|||
Name "GBuffer" // Name is not used |
|||
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index |
|||
|
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertDefault |
|||
#pragma fragment FragDeferred |
|||
|
|||
#if SHADER_STAGE_FRAGMENT |
|||
|
|||
void FragDeferred( PackedVaryings packedInput, |
|||
OUTPUT_GBUFFER(outGBuffer) |
|||
#ifdef VELOCITY_IN_GBUFFER |
|||
, OUTPUT_GBUFFER_VELOCITY(outGBuffer) |
|||
#endif |
|||
, OUTPUT_GBUFFER_BAKE_LIGHTING(outGBuffer) |
|||
) |
|||
{ |
|||
Varyings input = UnpackVaryings(packedInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS); |
|||
float3 positionWS = input.positionWS; |
|||
|
|||
SurfaceData surfaceData; |
|||
BuiltinData builtinData; |
|||
GetSurfaceAndBuiltinData(input, surfaceData, builtinData); |
|||
|
|||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData); |
|||
Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw); |
|||
PreLightData preLightData = GetPreLightData(V, positionWS, coord, bsdfData); |
|||
|
|||
ENCODE_INTO_GBUFFER(surfaceData, outGBuffer); |
|||
#ifdef VELOCITY_IN_GBUFFER |
|||
ENCODE_VELOCITY_INTO_GBUFFER(builtinData.velocity, outGBuffer); |
|||
#endif |
|||
ENCODE_BAKE_LIGHTING_INTO_GBUFFER(GetBakedDiffuseLigthing(preLightData, surfaceData, builtinData, bsdfData), outGBuffer); |
|||
} |
|||
|
|||
#endif |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// Debug pass |
|||
Pass |
|||
{ |
|||
Name "Debug" |
|||
Tags { "LightMode" = "DebugView" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertDefault |
|||
#pragma fragment FragDebug |
|||
|
|||
#include "Color.hlsl" |
|||
|
|||
int _DebugViewMaterial; |
|||
|
|||
#if SHADER_STAGE_FRAGMENT |
|||
|
|||
float4 FragDebug( PackedVaryings packedInput ) : SV_Target |
|||
{ |
|||
Varyings input = UnpackVaryings(packedInput); |
|||
SurfaceData surfaceData; |
|||
BuiltinData builtinData; |
|||
GetSurfaceAndBuiltinData(input, surfaceData, builtinData); |
|||
|
|||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData); |
|||
|
|||
float3 result = float3(1.0, 1.0, 0.0); |
|||
bool needLinearToSRGB = false; |
|||
|
|||
GetVaryingsDataDebug(_DebugViewMaterial, input, result, needLinearToSRGB); |
|||
GetBuiltinDataDebug(_DebugViewMaterial, builtinData, result, needLinearToSRGB); |
|||
GetSurfaceDataDebug(_DebugViewMaterial, surfaceData, result, needLinearToSRGB); |
|||
GetBSDFDataDebug(_DebugViewMaterial, bsdfData, result, needLinearToSRGB); // TODO: This required to initialize all field from BSDFData... |
|||
|
|||
// TEMP! |
|||
// For now, the final blit in the backbuffer performs an sRGB write |
|||
// So in the meantime we apply the inverse transform to linear data to compensate. |
|||
if (!needLinearToSRGB) |
|||
result = SRGBToLinear(max(0, result)); |
|||
|
|||
return float4(result, 0.0); |
|||
} |
|||
|
|||
#endif |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
// ------------------------------------------------------------------ |
|||
// forward pass |
|||
Pass |
|||
{ |
|||
Name "Forward" // Name is not used |
|||
Tags { "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index |
|||
|
|||
Blend [_SrcBlend] [_DstBlend] |
|||
ZWrite [_ZWrite] |
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertDefault |
|||
#pragma fragment FragForward |
|||
|
|||
#if SHADER_STAGE_FRAGMENT |
|||
|
|||
float4 FragForward(PackedVaryings packedInput) : SV_Target |
|||
{ |
|||
Varyings input = UnpackVaryings(packedInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS); |
|||
float3 positionWS = input.positionWS; |
|||
|
|||
SurfaceData surfaceData; |
|||
BuiltinData builtinData; |
|||
GetSurfaceAndBuiltinData(input, surfaceData, builtinData); |
|||
|
|||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData); |
|||
Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw); |
|||
PreLightData preLightData = GetPreLightData(V, positionWS, coord, bsdfData); |
|||
|
|||
float4 diffuseLighting; |
|||
float4 specularLighting; |
|||
ForwardLighting(V, positionWS, preLightData, bsdfData, diffuseLighting, specularLighting); |
|||
|
|||
diffuseLighting.rgb += GetBakedDiffuseLigthing(preLightData, surfaceData, builtinData, bsdfData); |
|||
|
|||
return float4(diffuseLighting.rgb + specularLighting.rgb, builtinData.opacity); |
|||
} |
|||
|
|||
#endif |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
CustomEditor "LitGUI" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e7e3743f30ad81a4ba2d0528f52d026b |
|||
timeCreated: 1475845772 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: dda3abfe43d26f84c9255796cfad662a |
|||
timeCreated: 1475859326 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue