浏览代码

LayeredLit shader first version (no custom GUI, only shader code + framework)

/main
Julien Ignace 8 年前
当前提交
730f9523
共有 12 个文件被更改,包括 1525 次插入6 次删除
  1. 1
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterial.hlsl
  2. 2
      Assets/TestScenes/HDTest/EnlightenTest.unity
  3. 11
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Blue_Alpha.mat
  4. 6
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Green.mat
  5. 264
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLit.shader
  6. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLit.shader.meta
  7. 406
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitTemplate.hlsl
  8. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitTemplate.hlsl.meta
  9. 411
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitUI.cs
  10. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitUI.cs.meta
  11. 392
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Layered.mat
  12. 8
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Layered.mat.meta

1
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterial.hlsl


#define DEBUGVIEW_VARYING_VERTEXNORMALWS 3
#define DEBUGVIEW_VARYING_VERTEXTANGENTWS 4
#define DEBUGVIEW_VARYING_VERTEXBITANGENTWS 5
#define DEBUGVIEW_VARYING_VERTEXCOLOR 6
// These define are sepcific to GBuffer
#define DEBUGVIEW_GBUFFER_DEPTH 6

2
Assets/TestScenes/HDTest/EnlightenTest.unity


m_Name:
m_EditorClassIdentifier:
m_RenderLoop: {fileID: 11400000, guid: 2400b74f5ce370c4481e5dc417d03703, type: 2}
m_AssetVersion: 0
m_AssetVersion: 1
--- !u!1 &1893534339
GameObject:
m_ObjectHideFlags: 0

11
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Blue_Alpha.mat


m_Name: Blue_Alpha
m_Shader: {fileID: 4800000, guid: e7e3743f30ad81a4ba2d0528f52d026b, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF
_DOUBLESIDED_LIGHTING_MIRROR _EMISSION _NORMALMAP_TANGENT_SPACE
_EMISSION _NORMALMAP_TANGENT_SPACE
m_CustomRenderQueue: -1
stringTagMap: {}
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:

m_Floats:
- first:
name: _AlphaCutoff
second: 0.5
second: 0.187
- first:
name: _AlphaCutoffEnable
second: 0

second: 1
- first:
name: _DoubleSidedMode
second: 3
second: 1
- first:
name: _DstBlend
second: 10

6
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Green.mat


m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ColorMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}

264
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLit.shader


Shader "Unity/LayeredLit"
{
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
_BaseColor0("BaseColor0", Color) = (1,1,1,1)
_BaseColor1("BaseColor1", Color) = (1, 1, 1, 1)
_BaseColor2("BaseColor2", Color) = (1, 1, 1, 1)
_BaseColor3("BaseColor3", Color) = (1, 1, 1, 1)
_BaseColorMap0("BaseColorMap0", 2D) = "white" {}
_BaseColorMap1("BaseColorMap1", 2D) = "white" {}
_BaseColorMap2("BaseColorMap2", 2D) = "white" {}
_BaseColorMap3("BaseColorMap3", 2D) = "white" {}
_Metalic0("Metalic0", Range(0.0, 1.0)) = 0
_Metalic1("Metalic1", Range(0.0, 1.0)) = 0
_Metalic2("Metalic2", Range(0.0, 1.0)) = 0
_Metalic3("Metalic3", Range(0.0, 1.0)) = 0
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 0.5
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 0.5
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 0.5
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 0.5
_MaskMap0("MaskMap0", 2D) = "white" {}
_MaskMap1("MaskMap1", 2D) = "white" {}
_MaskMap2("MaskMap2", 2D) = "white" {}
_MaskMap3("MaskMap3", 2D) = "white" {}
_SpecularOcclusionMap0("SpecularOcclusion0", 2D) = "white" {}
_SpecularOcclusionMap1("SpecularOcclusion1", 2D) = "white" {}
_SpecularOcclusionMap2("SpecularOcclusion2", 2D) = "white" {}
_SpecularOcclusionMap3("SpecularOcclusion3", 2D) = "white" {}
_NormalMap0("NormalMap0", 2D) = "bump" {}
_NormalMap1("NormalMap1", 2D) = "bump" {}
_NormalMap2("NormalMap2", 2D) = "bump" {}
_NormalMap3("NormalMap3", 2D) = "bump" {}
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
_HeightMap0("HeightMap0", 2D) = "black" {}
_HeightMap1("HeightMap1", 2D) = "black" {}
_HeightMap2("HeightMap2", 2D) = "black" {}
_HeightMap3("HeightMap3", 2D) = "black" {}
_HeightScale0("Height Scale0", Float) = 1
_HeightScale1("Height Scale1", Float) = 1
_HeightScale2("Height Scale2", Float) = 1
_HeightScale3("Height Scale3", Float) = 1
_HeightBias0("Height Bias0", Float) = 0
_HeightBias1("Height Bias1", Float) = 0
_HeightBias2("Height Bias2", Float) = 0
_HeightBias3("Height Bias3", Float) = 0
[Enum(Parallax, 0, Displacement, 1)] _HeightMapMode("Heightmap usage", Float) = 0
_EmissiveColor0("EmissiveColor0", Color) = (0, 0, 0)
_EmissiveColor1("EmissiveColor1", Color) = (0, 0, 0)
_EmissiveColor2("EmissiveColor2", Color) = (0, 0, 0)
_EmissiveColor3("EmissiveColor3", Color) = (0, 0, 0)
_EmissiveColorMap0("EmissiveColorMap0", 2D) = "white" {}
_EmissiveColorMap1("EmissiveColorMap1", 2D) = "white" {}
_EmissiveColorMap2("EmissiveColorMap2", 2D) = "white" {}
_EmissiveColorMap3("EmissiveColorMap3", 2D) = "white" {}
_EmissiveIntensity0("EmissiveIntensity0", Float) = 0
_EmissiveIntensity1("EmissiveIntensity1", Float) = 0
_EmissiveIntensity2("EmissiveIntensity2", Float) = 0
_EmissiveIntensity3("EmissiveIntensity3", 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 "LayeredLitTemplate.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);
SurfaceData surfaceData;
BuiltinData builtinData;
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
ENCODE_INTO_GBUFFER(surfaceData, outGBuffer);
#ifdef VELOCITY_IN_GBUFFER
ENCODE_VELOCITY_INTO_GBUFFER(builtinData.velocity, outGBuffer);
#endif
ENCODE_BAKE_LIGHTING_INTO_GBUFFER(GetBakedDiffuseLigthing(surfaceData, builtinData), outGBuffer);
}
#endif
ENDHLSL
}
// ------------------------------------------------------------------
// Debug pass
Pass
{
Name "Debug"
Tags{ "LightMode" = "DebugView" }
Cull[_CullMode]
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment FragDebug
#include "Assets/ScriptableRenderLoop/ShaderLibrary/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);
float4 diffuseLighting;
float4 specularLighting;
ForwardLighting(V, positionWS, bsdfData, diffuseLighting, specularLighting);
diffuseLighting.rgb += GetBakedDiffuseLigthing(surfaceData, builtinData);
return float4(diffuseLighting.rgb + specularLighting.rgb, builtinData.opacity);
}
#endif
ENDHLSL
}
}
CustomEditor "LayeredLitGUI"
}

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLit.shader.meta


fileFormatVersion: 2
guid: 81d02e8644315b742b154842a3a2f98c
timeCreated: 1475846632
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

406
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitTemplate.hlsl


// GENERATED BY SHADER GRAPH
// Question for shader graph: how to handle dynamic parameter data like matData0 that can change name
// No guard header!
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "Lighting/Lighting.hlsl" // This include Material.hlsl
#include "ShaderVariables.hlsl"
#include "Debug/DebugViewMaterial.hlsl"
// This files is generated by the ShaderGraph or written by hand
// Note for ShaderGraph:
// ShaderGraph should generate the vertex shader output to add the variable that may be required
// For example if we require view vector in shader graph, the output must contain positionWS and we calcualte the view vector with it.
// Still some input are mandatory depends on the type of loop. positionWS is mandatory in this current framework. So the ShaderGraph should always generate it.
#define PROP_DECL(type, name) type name, name##0, name##1, name##2, name##3;
#define PROP_SAMPLE(name, samplerName, texcoord, swizzle)\
name##0 = tex2D(samplerName##0, texcoord).##swizzle; \
name##1 = tex2D(samplerName##1, texcoord).##swizzle; \
name##2 = tex2D(samplerName##2, texcoord).##swizzle; \
name##3 = tex2D(samplerName##3, texcoord).##swizzle;
#define PROP_MUL(name, multiplier, swizzle)\
name##0 *= multiplier##0.##swizzle; \
name##1 *= multiplier##1.##swizzle; \
name##2 *= multiplier##2.##swizzle; \
name##3 *= multiplier##3.##swizzle;
#define PROP_ASSIGN(name, input, swizzle)\
name##0 = input##0.##swizzle; \
name##1 = input##1.##swizzle; \
name##2 = input##2.##swizzle; \
name##3 = input##3.##swizzle;
#define PROP_ASSIGN_VALUE(name, input)\
name##0 = input; \
name##1 = input; \
name##2 = input; \
name##3 = input;
#define PROP_BLEND_COLOR(name, mask) name = BlendLayeredColor(name##0, name##1, name##2, name##3, mask);
#define PROP_BLEND_SCALAR(name, mask) name = BlendLayeredScalar(name##0, name##1, name##2, name##3, mask);
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
// Set of users variables
PROP_DECL(float4, _BaseColor);
PROP_DECL(sampler2D, _BaseColorMap);
PROP_DECL(float, _Metalic);
PROP_DECL(float, _Smoothness);
PROP_DECL(sampler2D, _MaskMap);
PROP_DECL(sampler2D, _SpecularOcclusionMap);
PROP_DECL(sampler2D, _NormalMap);
PROP_DECL(sampler2D, _Heightmap);
PROP_DECL(float, _HeightScale);
PROP_DECL(float, _HeightBias);
PROP_DECL(float4, _EmissiveColor);
PROP_DECL(float, _EmissiveIntensity);
float _AlphaCutoff;
//-------------------------------------------------------------------------------------
// Lighting architecture
//-------------------------------------------------------------------------------------
// TODO: Check if we will have different Varyings based on different pass, not sure about that...
// Forward
struct Attributes
{
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
float2 uv0 : TEXCOORD0;
float4 tangentOS : TANGENT;
float4 color : TANGENT;
};
struct Varyings
{
float4 positionHS;
float3 positionWS;
float2 texCoord0;
float4 tangentToWorld[3]; // [3x3:tangentToWorld | 1x3:viewDirForParallax]
float4 vertexColor;
#ifdef SHADER_STAGE_FRAGMENT
#if defined(_DOUBLESIDED_LIGHTING_FLIP) || defined(_DOUBLESIDED_LIGHTING_MIRROR)
FRONT_FACE_TYPE cullFace;
#endif
#endif
};
struct PackedVaryings
{
float4 positionHS : SV_Position;
float4 interpolators[6] : TEXCOORD0;
#ifdef SHADER_STAGE_FRAGMENT
#if defined(_DOUBLESIDED_LIGHTING_FLIP) || defined(_DOUBLESIDED_LIGHTING_MIRROR)
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMATIC;
#endif
#endif
};
// Function to pack data to use as few interpolator as possible, the ShaderGraph should generate these functions
PackedVaryings PackVaryings(Varyings input)
{
PackedVaryings output;
output.positionHS = input.positionHS;
output.interpolators[0].xyz = input.positionWS.xyz;
output.interpolators[0].w = input.texCoord0.x;
output.interpolators[1] = input.tangentToWorld[0];
output.interpolators[2] = input.tangentToWorld[1];
output.interpolators[3] = input.tangentToWorld[2];
output.interpolators[4].x = input.texCoord0.y;
output.interpolators[4].yzw = float3(0.0, 0.0, 0.0);
output.interpolators[5] = input.vertexColor;
return output;
}
Varyings UnpackVaryings(PackedVaryings input)
{
Varyings output;
output.positionHS = input.positionHS;
output.positionWS.xyz = input.interpolators[0].xyz;
output.texCoord0.x = input.interpolators[0].w;
output.texCoord0.y = input.interpolators[4].x;
output.tangentToWorld[0] = input.interpolators[1];
output.tangentToWorld[1] = input.interpolators[2];
output.tangentToWorld[2] = input.interpolators[3];
output.vertexColor = input.interpolators[5];
#ifdef SHADER_STAGE_FRAGMENT
#if defined(_DOUBLESIDED_LIGHTING_FLIP) || defined(_DOUBLESIDED_LIGHTING_MIRROR)
output.cullFace = input.cullFace;
#endif
#endif
return output;
}
// TODO: Here we will also have all the vertex deformation (GPU skinning, vertex animation, morph target...) or we will need to generate a compute shaders instead (better! but require work to deal with unpacking like fp16)
PackedVaryings VertDefault(Attributes input)
{
Varyings output;
output.positionWS = TransformObjectToWorld(input.positionOS);
// TODO deal with camera center rendering and instancing (This is the reason why we always perform tow steps transform to clip space + instancing matrix)
output.positionHS = TransformWorldToHClip(output.positionWS);
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
output.texCoord0 = input.uv0;
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w);
output.tangentToWorld[0].xyz = tangentToWorld[0];
output.tangentToWorld[1].xyz = tangentToWorld[1];
output.tangentToWorld[2].xyz = tangentToWorld[2];
output.tangentToWorld[0].w = 0;
output.tangentToWorld[1].w = 0;
output.tangentToWorld[2].w = 0;
output.vertexColor = input.color;
return PackVaryings(output);
}
//-------------------------------------------------------------------------------------
// Fill SurfaceData/Lighting data function
//-------------------------------------------------------------------------------------
float3 TransformTangentToWorld(float3 normalTS, float4 tangentToWorld[3])
{
// TODO check: do we need to normalize ?
return normalize(mul(normalTS, float3x3(tangentToWorld[0].xyz, tangentToWorld[1].xyz, tangentToWorld[2].xyz)));
}
#if SHADER_STAGE_FRAGMENT
float3 BlendLayeredColor(float3 rgb0, float3 rgb1, float3 rgb2, float3 rgb3, float weight[4])
{
return rgb0 * weight[0] + rgb1 * weight[1] + rgb2 * weight[2] + rgb3 * weight[3];
}
float3 BlendLayeredNormal(float3 normal0, float3 normal1, float3 normal2, float3 normal3, float weight[4])
{
return normal0 * weight[0] + normal1 * weight[1] + normal2 * weight[2] + normal3 * weight[3];
}
float BlendLayeredScalar(float x0, float x1, float x2, float x3, float weight[4])
{
return x0 * weight[0] + x1 * weight[1] + x2 * weight[2] + x3 * weight[3];
}
#define MAX_LAYER 4
void ComputeMaskWeights(float4 inputMasks, out float outWeights[MAX_LAYER])
{
float masks[MAX_LAYER];
masks[0] = inputMasks.r;
masks[1] = inputMasks.g;
masks[2] = inputMasks.b;
masks[3] = inputMasks.a;
// calculate weight of each layers
float left = 1.0f;
// ATTRIBUTE_UNROLL
for (int i = MAX_LAYER - 1; i > 0; --i)
{
outWeights[i] = masks[i] * left;
left -= outWeights[i];
}
outWeights[0] = left;
}
void GetSurfaceAndBuiltinData(Varyings input, out SurfaceData surfaceData, out BuiltinData builtinData)
{
float4 maskValues = input.vertexColor;
float weights[MAX_LAYER];
ComputeMaskWeights(maskValues, weights);
PROP_DECL(float3, baseColor);
PROP_SAMPLE(baseColor, _BaseColorMap, input.texCoord0, rgb);
PROP_MUL(baseColor, _BaseColor, rgb);
PROP_BLEND_COLOR(baseColor, weights);
surfaceData.baseColor = baseColor;
PROP_DECL(float, alpha);
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
PROP_ASSIGN(alpha, _BaseColor, a);
#else
PROP_SAMPLE(alpha, _BaseColorMap, input.texCoord0, a);
PROP_MUL(alpha, _BaseColor, a);
#endif
PROP_BLEND_SCALAR(alpha, weights);
#ifdef _ALPHATEST_ON
clip(alpha - _AlphaCutoff);
#endif
builtinData.opacity = alpha;
PROP_DECL(float, specularOcclusion);
#ifdef _SPECULAROCCLUSIONMAP
// TODO: Do something. For now just take alpha channel
PROP_SAMPLE(specularOcclusion, _SpecularOcclusionMap, input.texCoord0, a);
#else
// Horizon Occlusion for Normal Mapped Reflections: http://marmosetco.tumblr.com/post/81245981087
//surfaceData.specularOcclusion = saturate(1.0 + horizonFade * dot(r, input.tangentToWorld[2].xyz);
// smooth it
//surfaceData.specularOcclusion *= surfaceData.specularOcclusion;
PROP_ASSIGN_VALUE(specularOcclusion, 1.0);
#endif
PROP_BLEND_SCALAR(specularOcclusion, weights);
surfaceData.specularOcclusion = specularOcclusion;
// TODO: think about using BC5
float3 vertexNormalWS = input.tangentToWorld[2].xyz;
#ifdef _NORMALMAP
#ifdef _NORMALMAP_TANGENT_SPACE
float3 normalTS0 = UnpackNormalDXT5nm(tex2D(_NormalMap0, input.texCoord0));
float3 normalTS1 = UnpackNormalDXT5nm(tex2D(_NormalMap1, input.texCoord0));
float3 normalTS2 = UnpackNormalDXT5nm(tex2D(_NormalMap2, input.texCoord0));
float3 normalTS3 = UnpackNormalDXT5nm(tex2D(_NormalMap3, input.texCoord0));
float3 normalTS = BlendLayeredNormal(normal0, normal1, normal2, normal3, weights);
surfaceData.normalWS = TransformTangentToWorld(normalTS, input.tangentToWorld);
#else // Object space (TODO: We need to apply the world rotation here!)
surfaceData.normalWS = tex2D(_NormalMap, input.texCoord0).rgb;
#endif
#else
surfaceData.normalWS = vertexNormalWS;
#endif
#if defined(_DOUBLESIDED_LIGHTING_FLIP) || defined(_DOUBLESIDED_LIGHTING_MIRROR)
#ifdef _DOUBLESIDED_LIGHTING_FLIP
float3 oppositeNormalWS = -surfaceData.normalWS;
#else
// Mirror the normal with the plane define by vertex normal
float3 oppositeNormalWS = reflect(surfaceData.normalWS, vertexNormalWS);
#endif
// TODO : Test if GetOdddNegativeScale() is necessary here in case of normal map, as GetOdddNegativeScale is take into account in CreateTangentToWorld();
surfaceData.normalWS = IS_FRONT_VFACE(input.cullFace, GetOdddNegativeScale() >= 0.0 ? surfaceData.normalWS : oppositeNormalWS, -GetOdddNegativeScale() >= 0.0 ? surfaceData.normalWS : oppositeNormalWS);
#endif
PROP_DECL(float, perceptualSmoothness);
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
PROP_SAMPLE(perceptualSmoothness, _BaseColorMap0, input.texCoord0, a);
#elif defined(_MASKMAP)
PROP_SAMPLE(perceptualSmoothness, _MaskMap0, input.texCoord0, a);
#else
PROP_ASSIGN_VALUE(perceptualSmoothness, 1.0);
#endif
PROP_MUL(perceptualSmoothness, _Smoothness, r);
PROP_BLEND_SCALAR(perceptualSmoothness, weights);
surfaceData.perceptualSmoothness = perceptualSmoothness;
surfaceData.materialId = 0;
// MaskMap is Metalic, Ambient Occlusion, (Optional) - emissive Mask, Optional - Smoothness (in alpha)
PROP_DECL(float, metalic);
PROP_DECL(float, ambientOcclusion);
#ifdef _MASKMAP
PROP_SAMPLE(metalic, _MaskMap0, input.texCoord0, a);
PROP_SAMPLE(ambientOcclusion, _MaskMap0, input.texCoord0, g);
#else
PROP_ASSIGN_VALUE(metalic, 1.0);
PROP_ASSIGN_VALUE(ambientOcclusion, 1.0);
#endif
PROP_MUL(metalic, _Metalic, r);
PROP_BLEND_SCALAR(metalic, weights);
PROP_BLEND_SCALAR(ambientOcclusion, weights);
surfaceData.metalic = metalic;
surfaceData.ambientOcclusion = ambientOcclusion;
surfaceData.tangentWS = float3(1.0, 0.0, 0.0);
surfaceData.anisotropy = 0;
surfaceData.specular = 0.04;
surfaceData.subSurfaceRadius = 1.0;
surfaceData.thickness = 0.0;
surfaceData.subSurfaceProfile = 0;
surfaceData.coatNormalWS = float3(1.0, 0.0, 0.0);
surfaceData.coatPerceptualSmoothness = 1.0;
surfaceData.specularColor = float3(0.0, 0.0, 0.0);
// Builtin Data
// TODO: Sample lightmap/lightprobe/volume proxy
// This should also handle projective lightmap
// Note that data input above can be use to sample into lightmap (like normal)
builtinData.bakeDiffuseLighting = float3(0.0, 0.0, 0.0);// tex2D(_DiffuseLightingMap, input.texCoord0).rgb;
// If we chose an emissive color, we have a dedicated texture for it and don't use MaskMap
PROP_DECL(float3, emissiveColor);
#ifdef _EMISSIVE_COLOR
#ifdef _EMISSIVE_COLOR_MAP
PROP_SAMPLE(emissiveColor, _EmissiveColorMap, input.texCoord0, rgb);
#else
PROP_ASSIGN(emissiveColor, _EmissiveColor, rgb);
#endif
#elif defined(_MASKMAP) // If we have a MaskMap, use emissive slot as a mask on baseColor
PROP_SAMPLE(emissiveColor, _MaskMap, input.texCoord0, bbb);
PROP_MUL(emissiveColor, baseColor, rgb);
#else
PROP_ASSIGN_VALUE(emissiveColor, float3(0.0, 0.0, 0.0));
#endif
PROP_BLEND_COLOR(emissiveColor, weights);
builtinData.emissiveColor = emissiveColor;
PROP_DECL(float, emissiveIntensity);
PROP_ASSIGN(emissiveIntensity, _EmissiveIntensity, r);
PROP_BLEND_SCALAR(emissiveIntensity, weights);
builtinData.emissiveIntensity = emissiveIntensity;
builtinData.velocity = float2(0.0, 0.0);
builtinData.distortion = float2(0.0, 0.0);
builtinData.distortionBlur = 0.0;
}
void GetVaryingsDataDebug(uint paramId, Varyings input, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)
{
case DEBUGVIEW_VARYING_DEPTH:
// TODO: provide a customize parameter (like a slider)
float linearDepth = frac(LinearEyeDepth(input.positionHS.z, _ZBufferParams) * 0.1);
result = linearDepth.xxx;
break;
case DEBUGVIEW_VARYING_TEXCOORD0:
// TODO: require a remap
result = float3(input.texCoord0, 0.0);
break;
case DEBUGVIEW_VARYING_VERTEXNORMALWS:
result = input.tangentToWorld[2].xyz * 0.5 + 0.5;
break;
case DEBUGVIEW_VARYING_VERTEXTANGENTWS:
result = input.tangentToWorld[0].xyz * 0.5 + 0.5;
break;
case DEBUGVIEW_VARYING_VERTEXBITANGENTWS:
result = input.tangentToWorld[1].xyz * 0.5 + 0.5;
break;
case DEBUGVIEW_VARYING_VERTEXCOLOR:
result = input.vertexColor.xyz;
break;
}
}
#endif // #if SHADER_STAGE_FRAGMENT

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitTemplate.hlsl.meta


fileFormatVersion: 2
guid: f32b62aaa1f885a4d9aceab2b86206cb
timeCreated: 1475846632
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

411
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitUI.cs


using System;
using UnityEngine;
using UnityEngine.Rendering;
namespace UnityEditor
{
internal class LayeredLitGUI : ShaderGUI
{
// public enum SurfaceType
// {
// Opaque,
// Transparent
// }
// public enum BlendMode
// {
// Lerp,
// Add,
// SoftAdd,
// Multiply,
// Premultiply
// }
// public enum SmoothnessMapChannel
// {
// MaskAlpha,
// AlbedoAlpha,
// }
// public enum EmissiveColorMode
// {
// UseEmissiveColor,
// UseEmissiveMask,
// }
// public enum DoubleSidedMode
// {
// None,
// DoubleSided,
// DoubleSidedLightingFlip,
// DoubleSidedLightingMirror,
// }
// public enum NormalMapSpace
// {
// TangentSpace,
// ObjectSpace,
// }
// public enum HeightmapMode
// {
// Parallax,
// Displacement,
// }
// private static class Styles
// {
// public static string OptionText = "Options";
// public static string SurfaceTypeText = "Surface Type";
// public static string BlendModeText = "Blend Mode";
// public static GUIContent alphaCutoffEnableText = new GUIContent("Alpha Cutoff Enable", "Threshold for alpha cutoff");
// public static GUIContent alphaCutoffText = new GUIContent("Alpha Cutoff", "Threshold for alpha cutoff");
// public static GUIContent doubleSidedModeText = new GUIContent("Double Sided", "This will render the two face of the objects (disable backface culling)");
// public static readonly string[] surfaceTypeNames = Enum.GetNames(typeof(SurfaceType));
// public static readonly string[] blendModeNames = Enum.GetNames(typeof(BlendMode));
// public static string InputsOptionsText = "Inputs options";
// public static GUIContent smoothnessMapChannelText = new GUIContent("Smoothness Source", "Smoothness texture and channel");
// public static GUIContent emissiveColorModeText = new GUIContent("Emissive Color Usage", "Use emissive color or emissive mask");
// public static string InputsText = "Inputs";
// public static string InputsMapText = "";
// public static GUIContent baseColorText = new GUIContent("Base Color", "Albedo (RGB) and Smoothness (A)");
// public static GUIContent baseColorSmoothnessText = new GUIContent("Base Color + Smoothness", "Albedo (RGB) and Smoothness (A)");
// public static GUIContent mettalicText = new GUIContent("Mettalic", "Mettalic scale factor");
// public static GUIContent smoothnessText = new GUIContent("Smoothness", "Smoothness scale factor");
// public static GUIContent maskMapESText = new GUIContent("Mask Map - M(R), AO(G), E(B), S(A)", "Mask map");
// public static GUIContent maskMapEText = new GUIContent("Mask Map - M(R), AO(G), E(B)", "Mask map");
// public static GUIContent maskMapText = new GUIContent("Mask Map - M(R), AO(G)", "Mask map");
// public static GUIContent maskMapSText = new GUIContent("Mask Map - M(R), AO(G), S(A)", "Mask map");
// public static GUIContent specularOcclusionMapText = new GUIContent("Specular Occlusion Map (RGBA)", "Specular Occlusion Map");
// public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map (BC5) - DXT5 for test");
// public static GUIContent normalMapSpaceText = new GUIContent("Normal Map space", "");
// public static GUIContent heightMapText = new GUIContent("Height Map", "Height Map");
// public static GUIContent heightMapModeText = new GUIContent("Height Map Mode", "");
// // public static GUIContent diffuseLightingMapText = new GUIContent("DiffuseLightingMap", "Lightmap/Lightprobe data (fill by system is not done");
// public static GUIContent emissiveText = new GUIContent("Emissive Color", "Emissive");
// public static GUIContent emissiveIntensityText = new GUIContent("Emissive Intensity", "Emissive");
// }
// MaterialProperty surfaceType = null;
// MaterialProperty blendMode = null;
// MaterialProperty alphaCutoff = null;
// MaterialProperty alphaCutoffEnable = null;
// MaterialProperty doubleSidedMode = null;
// MaterialProperty smoothnessMapChannel = null;
// MaterialProperty emissiveColorMode = null;
// MaterialProperty baseColor = null;
// MaterialProperty baseColorMap = null;
// MaterialProperty mettalic = null;
// MaterialProperty smoothness = null;
// MaterialProperty maskMap = null;
// MaterialProperty specularOcclusionMap = null;
// MaterialProperty normalMap = null;
// MaterialProperty normalMapSpace = null;
// MaterialProperty heightMap = null;
// MaterialProperty heightScale = null;
// MaterialProperty heightBias = null;
// MaterialProperty heightMapMode = null;
//// MaterialProperty diffuseLightingMap = null;
// MaterialProperty emissiveColor = null;
// MaterialProperty emissiveColorMap = null;
// MaterialProperty emissiveIntensity = null;
//// MaterialProperty subSurfaceRadius = null;
//// MaterialProperty subSurfaceRadiusMap = null;
// MaterialEditor m_MaterialEditor;
// public void FindProperties (MaterialProperty[] props)
// {
// surfaceType = FindProperty("_SurfaceType", props);
// blendMode = FindProperty("_BlendMode", props);
// alphaCutoff = FindProperty("_AlphaCutoff", props);
// alphaCutoffEnable = FindProperty("_AlphaCutoffEnable", props);
// doubleSidedMode = FindProperty("_DoubleSidedMode", props);
// smoothnessMapChannel = FindProperty("_SmoothnessTextureChannel", props);
// emissiveColorMode = FindProperty("_EmissiveColorMode", props);
// baseColor = FindProperty("_BaseColor", props);
// baseColorMap = FindProperty("_BaseColorMap", props);
// mettalic = FindProperty("_Mettalic", props);
// smoothness = FindProperty("_Smoothness", props);
// maskMap = FindProperty("_MaskMap", props);
// specularOcclusionMap = FindProperty("_SpecularOcclusionMap", props);
// normalMap = FindProperty("_NormalMap", props);
// normalMapSpace = FindProperty("_NormalMapSpace", props);
// heightMap = FindProperty("_HeightMap", props);
// heightScale = FindProperty("_HeightScale", props);
// heightBias = FindProperty("_HeightBias", props);
// heightMapMode = FindProperty("_HeightMapMode", props);
// // diffuseLightingMap = FindProperty("_DiffuseLightingMap", props);
// emissiveColor = FindProperty("_EmissiveColor", props);
// emissiveColorMap = FindProperty("_EmissiveColorMap", props);
// emissiveIntensity = FindProperty("_EmissiveIntensity", props);
// }
// public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] props)
// {
// FindProperties (props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
// m_MaterialEditor = materialEditor;
// Material material = materialEditor.target as Material;
// ShaderPropertiesGUI (material);
// }
// public void ShaderPropertiesGUI (Material material)
// {
// // Use default labelWidth
// EditorGUIUtility.labelWidth = 0f;
// // Detect any changes to the material
// EditorGUI.BeginChangeCheck();
// {
// GUILayout.Label(Styles.OptionText, EditorStyles.boldLabel);
// SurfaceTypePopup();
// if ((SurfaceType)surfaceType.floatValue == SurfaceType.Transparent)
// {
// BlendModePopup();
// }
// m_MaterialEditor.ShaderProperty(alphaCutoffEnable, Styles.alphaCutoffEnableText.text);
// if (alphaCutoffEnable.floatValue == 1.0)
// {
// m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText.text);
// }
// m_MaterialEditor.ShaderProperty(doubleSidedMode, Styles.doubleSidedModeText.text);
// GUILayout.Label(Styles.InputsOptionsText, EditorStyles.boldLabel);
// m_MaterialEditor.ShaderProperty(smoothnessMapChannel, Styles.smoothnessMapChannelText.text);
// m_MaterialEditor.ShaderProperty(emissiveColorMode, Styles.emissiveColorModeText.text);
// bool isAlbedoAlpha = (SmoothnessMapChannel)smoothnessMapChannel.floatValue == SmoothnessMapChannel.AlbedoAlpha;
// bool useEmissiveMask = (EmissiveColorMode)emissiveColorMode.floatValue == EmissiveColorMode.UseEmissiveMask;
// GUILayout.Label(Styles.InputsText, EditorStyles.boldLabel);
// m_MaterialEditor.TexturePropertySingleLine(isAlbedoAlpha ? Styles.baseColorSmoothnessText : Styles.baseColorText, baseColorMap, baseColor);
// m_MaterialEditor.ShaderProperty(mettalic, Styles.mettalicText);
// m_MaterialEditor.ShaderProperty(smoothness, Styles.smoothnessText);
// if (isAlbedoAlpha && useEmissiveMask)
// m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapESText, maskMap);
// else if (useEmissiveMask)
// m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapEText, maskMap);
// else if (isAlbedoAlpha)
// m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapSText, maskMap);
// else
// m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapText, maskMap);
// m_MaterialEditor.TexturePropertySingleLine(Styles.specularOcclusionMapText, specularOcclusionMap);
// m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap);
// m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText.text);
// m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightScale, heightBias);
// m_MaterialEditor.ShaderProperty(heightMapMode, Styles.heightMapModeText.text);
// if (!useEmissiveMask)
// {
// m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
// }
// m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
// }
// if (EditorGUI.EndChangeCheck())
// {
// foreach (var obj in blendMode.targets)
// MaterialChanged((Material)obj);
// }
// }
// // TODO: try to setup minimun value to fall back to standard shaders and reverse
// public override void AssignNewShaderToMaterial (Material material, Shader oldShader, Shader newShader)
// {
// base.AssignNewShaderToMaterial(material, oldShader, newShader);
// }
// void SurfaceTypePopup()
// {
// EditorGUI.showMixedValue = surfaceType.hasMixedValue;
// var mode = (SurfaceType)surfaceType.floatValue;
// EditorGUI.BeginChangeCheck();
// mode = (SurfaceType)EditorGUILayout.Popup(Styles.SurfaceTypeText, (int)mode, Styles.surfaceTypeNames);
// if (EditorGUI.EndChangeCheck())
// {
// m_MaterialEditor.RegisterPropertyChangeUndo("Surface Type");
// surfaceType.floatValue = (float)mode;
// }
// EditorGUI.showMixedValue = false;
// }
// void BlendModePopup()
// {
// EditorGUI.showMixedValue = blendMode.hasMixedValue;
// var mode = (BlendMode)blendMode.floatValue;
// EditorGUI.BeginChangeCheck();
// mode = (BlendMode)EditorGUILayout.Popup(Styles.BlendModeText, (int)mode, Styles.blendModeNames);
// if (EditorGUI.EndChangeCheck())
// {
// m_MaterialEditor.RegisterPropertyChangeUndo("Blend Mode");
// blendMode.floatValue = (float)mode;
// }
// EditorGUI.showMixedValue = false;
// }
// static public void SetupMaterial(Material material)
// {
// // Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
// // (MaterialProperty value might come from renderer material property block)
// bool alphaTestEnable = material.GetFloat("_AlphaCutoffEnable") == 1.0;
// SurfaceType surfaceType = (SurfaceType)material.GetFloat("_SurfaceType");
// BlendMode blendMode = (BlendMode)material.GetFloat("_BlendMode");
// DoubleSidedMode doubleSidedMode = (DoubleSidedMode)material.GetFloat("_DoubleSidedMode");
// if (surfaceType == SurfaceType.Opaque)
// {
// material.SetOverrideTag("RenderType", alphaTestEnable ? "TransparentCutout" : "");
// material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
// material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
// material.SetInt("_ZWrite", 1);
// material.renderQueue = alphaTestEnable ? (int)UnityEngine.Rendering.RenderQueue.AlphaTest : -1;
// }
// else
// {
// material.SetOverrideTag("RenderType", "Transparent");
// material.SetInt("_ZWrite", 0);
// material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
// switch (blendMode)
// {
// case BlendMode.Lerp:
// material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
// material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
// break;
// case BlendMode.Add:
// material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
// material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
// break;
// case BlendMode.SoftAdd:
// material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusDstColor);
// material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
// break;
// case BlendMode.Multiply:
// material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
// material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
// break;
// case BlendMode.Premultiply:
// material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
// material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
// break;
// }
// }
// if (doubleSidedMode == DoubleSidedMode.None)
// {
// material.SetInt("_CullMode", (int)UnityEngine.Rendering.CullMode.Back);
// }
// else
// {
// material.SetInt("_CullMode", (int)UnityEngine.Rendering.CullMode.Off);
// }
// if (doubleSidedMode == DoubleSidedMode.DoubleSidedLightingFlip)
// {
// material.EnableKeyword("_DOUBLESIDED_LIGHTING_FLIP");
// material.DisableKeyword("_DOUBLESIDED_LIGHTING_MIRROR");
// }
// else if (doubleSidedMode == DoubleSidedMode.DoubleSidedLightingMirror)
// {
// material.DisableKeyword("_DOUBLESIDED_LIGHTING_FLIP");
// material.EnableKeyword("_DOUBLESIDED_LIGHTING_MIRROR");
// }
// else
// {
// material.DisableKeyword("_DOUBLESIDED_LIGHTING_FLIP");
// material.DisableKeyword("_DOUBLESIDED_LIGHTING_MIRROR");
// }
// SetKeyword(material, "_ALPHATEST_ON", alphaTestEnable);
// SetKeyword(material, "_NORMALMAP", material.GetTexture("_NormalMap"));
// SetKeyword(material, "_NORMALMAP_TANGENT_SPACE", (NormalMapSpace)material.GetFloat("_NormalMapSpace") == NormalMapSpace.TangentSpace);
// SetKeyword(material, "_MASKMAP", material.GetTexture("_MaskMap"));
// SetKeyword(material, "_SPECULAROCCLUSIONMAP", material.GetTexture("_SpecularOcclusionMap"));
// SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", ((SmoothnessMapChannel)material.GetFloat("_SmoothnessTextureChannel")) == SmoothnessMapChannel.AlbedoAlpha);
// SetKeyword(material, "_EMISSIVE_COLOR", ((EmissiveColorMode)material.GetFloat("_EmissiveColorMode")) == EmissiveColorMode.UseEmissiveColor);
// SetKeyword(material, "_EMISSIVE_COLOR_MAP", material.GetTexture("_EmissiveColorMap"));
// SetKeyword(material, "_HEIGHTMAP", material.GetTexture("_HeightMap"));
// SetKeyword(material, "_HEIGHTMAP_AS_DISPLACEMENT", (HeightmapMode)material.GetFloat("_HeightMapMode") == HeightmapMode.Displacement);
// /*
// // Setup lightmap emissive flags
// MaterialGlobalIlluminationFlags flags = material.globalIlluminationFlags;
// if ((flags & (MaterialGlobalIlluminationFlags.BakedEmissive | MaterialGlobalIlluminationFlags.RealtimeEmissive)) != 0)
// {
// flags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
// if (!shouldEmissionBeEnabled)
// flags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
// material.globalIlluminationFlags = flags;
// }
// */
//}
//static bool ShouldEmissionBeEnabled(Material mat, Color color)
//{
// //var realtimeEmission = (mat.globalIlluminationFlags & MaterialGlobalIlluminationFlags.RealtimeEmissive) > 0;
// //return color.maxColorComponent > 0.1f / 255.0f || realtimeEmission;
// return false;
//}
//bool HasValidEmissiveKeyword (Material material)
//{
// /*
// // Material animation might be out of sync with the material keyword.
// // So if the emission support is disabled on the material, but the property blocks have a value that requires it, then we need to show a warning.
// // (note: (Renderer MaterialPropertyBlock applies its values to emissionColorForRendering))
// bool hasEmissionKeyword = material.IsKeywordEnabled ("_EMISSION");
// if (!hasEmissionKeyword && ShouldEmissionBeEnabled (material, emissionColorForRendering.colorValue))
// return false;
// else
// return true;
// */
// return true;
//}
//static void MaterialChanged(Material material)
//{
// SetupMaterial(material);
//}
//static void SetKeyword(Material m, string keyword, bool state)
//{
// if (state)
// m.EnableKeyword (keyword);
// else
// m.DisableKeyword (keyword);
//}
}
} // namespace UnityEditor

12
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LayeredLitUI.cs.meta


fileFormatVersion: 2
guid: 25870545853609a4abdc1898940f4406
timeCreated: 1475845767
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

392
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Layered.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Layered
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DISTORTIONDEPTHTEST_OFF _DISTORTIONONLY_OFF
_EMISSION
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _BaseColorMap0
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _BaseColorMap1
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _BaseColorMap2
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _BaseColorMap3
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissiveColorMap0
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissiveColorMap1
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissiveColorMap2
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissiveColorMap3
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _HeightMap0
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _HeightMap1
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _HeightMap2
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _HeightMap3
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap0
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap1
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap2
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap3
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NormalMap0
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NormalMap1
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NormalMap2
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NormalMap3
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _OcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SpecularOcclusionMap0
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SpecularOcclusionMap1
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SpecularOcclusionMap2
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SpecularOcclusionMap3
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:
name: _BumpScale
second: 1
- first:
name: _CullMode
second: 2
- first:
name: _Cutoff
second: 0.5
- first:
name: _DetailNormalMapScale
second: 1
- first:
name: _DistortionDepthTest
second: 0
- first:
name: _DistortionOnly
second: 0
- first:
name: _DoubleSidedMode
second: 0
- first:
name: _DstBlend
second: 0
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity0
second: 0
- first:
name: _EmissiveIntensity1
second: 0
- first:
name: _EmissiveIntensity2
second: 0
- first:
name: _EmissiveIntensity3
second: 0
- first:
name: _GlossMapScale
second: 1
- first:
name: _Glossiness
second: 0.5
- first:
name: _GlossyReflections
second: 1
- first:
name: _HeightBias0
second: 0
- first:
name: _HeightBias1
second: 0
- first:
name: _HeightBias2
second: 0
- first:
name: _HeightBias3
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale0
second: 1
- first:
name: _HeightScale1
second: 1
- first:
name: _HeightScale2
second: 1
- first:
name: _HeightScale3
second: 1
- first:
name: _MaterialId
second: 0
- first:
name: _Metalic0
second: 0
- first:
name: _Metalic1
second: 0
- first:
name: _Metalic2
second: 0
- first:
name: _Metalic3
second: 0
- first:
name: _Metallic
second: 0
- first:
name: _Mode
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength
second: 1
- first:
name: _Parallax
second: 0.02
- first:
name: _Smoothness0
second: 0.5
- first:
name: _Smoothness1
second: 0.5
- first:
name: _Smoothness2
second: 0.5
- first:
name: _Smoothness3
second: 0.5
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SrcBlend
second: 1
- first:
name: _SurfaceType
second: 0
- first:
name: _UVSec
second: 0
- first:
name: _ZWrite
second: 1
m_Colors:
- first:
name: _BaseColor0
second: {r: 1, g: 0, b: 0, a: 1}
- first:
name: _BaseColor1
second: {r: 0, g: 1, b: 0, a: 1}
- first:
name: _BaseColor2
second: {r: 0, g: 0, b: 1, a: 1}
- first:
name: _BaseColor3
second: {r: 1, g: 1, b: 0, a: 1}
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor0
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor1
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor2
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor3
second: {r: 0, g: 0, b: 0, a: 1}

8
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Layered.mat.meta


fileFormatVersion: 2
guid: 6e7fa39a7d1b15c4184c9f51d86eba22
timeCreated: 1475855280
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存