浏览代码

HDRenderLoop: Rename metalic to mettalic

/main
Sebastien Lagarde 8 年前
当前提交
79cd240f
共有 13 个文件被更改,包括 68 次插入68 次删除
  1. 20
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl
  2. 8
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs.hlsl
  3. 8
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/LayeredLit/LayeredLit.shader
  4. 16
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/LayeredLit/LayeredLitCommon.hlsl
  5. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs
  6. 16
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs.hlsl
  7. 30
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl
  8. 8
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitData.hlsl
  9. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader
  10. 8
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitUI.cs
  11. 8
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/Unlit.cs.hlsl
  12. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs
  13. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs.hlsl

20
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl


//
//
// UnityEngine.ScriptableRenderLoop.AreaShapeType: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.AreaShapeType: static fields
//
#define AREASHAPETYPE_RECTANGLE (0)
#define AREASHAPETYPE_LINE (1)

#define AREASHAPETYPE_CYLINDER (5)
//
// UnityEngine.ScriptableRenderLoop.EnvShapeType: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.EnvShapeType: static fields
// Generated from UnityEngine.ScriptableRenderLoop.PunctualLightData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.PunctualLightData
// PackingRules = Exact
struct PunctualLightData
{

float2 unused2;
};
// Generated from UnityEngine.ScriptableRenderLoop.AreaLightData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.AreaLightData
// PackingRules = Exact
struct AreaLightData
{

float unused;
};
// Generated from UnityEngine.ScriptableRenderLoop.EnvLightData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.EnvLightData
// PackingRules = Exact
struct EnvLightData
{

float unused1;
};
// Generated from UnityEngine.ScriptableRenderLoop.PlanarLightData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.PlanarLightData
// PackingRules = Exact
struct PlanarLightData
{

//
// Accessors for UnityEngine.ScriptableRenderLoop.PunctualLightData
// Accessors for UnityEngine.Experimental.ScriptableRenderLoop.PunctualLightData
//
float3 GetPositionWS(PunctualLightData value)
{

}
//
// Accessors for UnityEngine.ScriptableRenderLoop.AreaLightData
// Accessors for UnityEngine.Experimental.ScriptableRenderLoop.AreaLightData
//
float3 GetPositionWS(AreaLightData value)
{

}
//
// Accessors for UnityEngine.ScriptableRenderLoop.EnvLightData
// Accessors for UnityEngine.Experimental.ScriptableRenderLoop.EnvLightData
//
float3 GetPositionWS(EnvLightData value)
{

}
//
// Accessors for UnityEngine.ScriptableRenderLoop.PlanarLightData
// Accessors for UnityEngine.Experimental.ScriptableRenderLoop.PlanarLightData
//
float3 GetPositionWS(PlanarLightData value)
{

8
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs.hlsl


//
//
// UnityEngine.ScriptableRenderLoop.Builtin.BuiltinData: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.Builtin.BuiltinData: static fields
//
#define DEBUGVIEW_BUILTIN_BUILTINDATA_OPACITY (100)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_BAKE_DIFFUSE_LIGHTING (101)

#define DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION_BLUR (106)
//
// UnityEngine.ScriptableRenderLoop.Builtin.LighTransportData: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.Builtin.LighTransportData: static fields
// Generated from UnityEngine.ScriptableRenderLoop.Builtin.BuiltinData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.Builtin.BuiltinData
// PackingRules = Exact
struct BuiltinData
{

float distortionBlur;
};
// Generated from UnityEngine.ScriptableRenderLoop.Builtin.LighTransportData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.Builtin.LighTransportData
// PackingRules = Exact
struct LighTransportData
{

8
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/LayeredLit/LayeredLit.shader


_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
_Metallic0("Metallic0", Range(0.0, 1.0)) = 0
_Metallic1("Metallic1", Range(0.0, 1.0)) = 0
_Metallic2("Metallic2", Range(0.0, 1.0)) = 0
_Metallic3("Metallic3", Range(0.0, 1.0)) = 0
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 0.5
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 0.5

16
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/LayeredLit/LayeredLitCommon.hlsl


// Set of users variables
PROP_DECL(float4, _BaseColor);
PROP_DECL_TEX2D(_BaseColorMap);
PROP_DECL(float, _Metalic);
PROP_DECL(float, _Metallic);
PROP_DECL(float, _Smoothness);
PROP_DECL_TEX2D(_MaskMap);
PROP_DECL_TEX2D(_SpecularOcclusionMap);

surfaceData.materialId = 0;
// MaskMap is Metalic, Ambient Occlusion, (Optional) - emissive Mask, Optional - Smoothness (in alpha)
PROP_DECL(float, metalic);
// MaskMap is Metallic, Ambient Occlusion, (Optional) - emissive Mask, Optional - Smoothness (in alpha)
PROP_DECL(float, metallic);
PROP_SAMPLE(metalic, _MaskMap, input.texCoord0, a);
PROP_SAMPLE(metallic, _MaskMap, input.texCoord0, a);
PROP_ASSIGN_VALUE(metalic, 1.0);
PROP_ASSIGN_VALUE(metallic, 1.0);
PROP_MUL(metalic, _Metalic, r);
PROP_MUL(metallic, _Metallic, r);
PROP_BLEND_SCALAR(metalic, weights);
PROP_BLEND_SCALAR(metallic, weights);
surfaceData.metalic = metalic;
surfaceData.metallic = metallic;
surfaceData.ambientOcclusion = ambientOcclusion;
surfaceData.tangentWS = float3(1.0, 0.0, 0.0);

4
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs


public Vector3 tangentWS;
[SurfaceDataAttributes("Anisotropy")]
public float anisotropy; // anisotropic ratio(0->no isotropic; 1->full anisotropy in tangent direction)
[SurfaceDataAttributes("Metalic")]
public float metalic;
[SurfaceDataAttributes("Metallic")]
public float metallic;
[SurfaceDataAttributes("Specular")]
public float specular; // 0.02, 0.04, 0.16, 0.2

16
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs.hlsl


//
//
// UnityEngine.ScriptableRenderLoop.Lit.MaterialId: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.Lit.MaterialId: static fields
//
#define MATERIALID_LIT_STANDARD (0)
#define MATERIALID_LIT_SSS (1)

//
// UnityEngine.ScriptableRenderLoop.Lit.SurfaceData: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.Lit.SurfaceData: static fields
//
#define DEBUGVIEW_LIT_SURFACEDATA_BASE_COLOR (1000)
#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_OCCLUSION (1001)

#define DEBUGVIEW_LIT_SURFACEDATA_AMBIENT_OCCLUSION (1005)
#define DEBUGVIEW_LIT_SURFACEDATA_TANGENT_WS (1006)
#define DEBUGVIEW_LIT_SURFACEDATA_ANISOTROPY (1007)
#define DEBUGVIEW_LIT_SURFACEDATA_METALIC (1008)
#define DEBUGVIEW_LIT_SURFACEDATA_METALLIC (1008)
#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR (1009)
#define DEBUGVIEW_LIT_SURFACEDATA_SUB_SURFACE_RADIUS (1010)
#define DEBUGVIEW_LIT_SURFACEDATA_THICKNESS (1011)

#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_COLOR (1015)
//
// UnityEngine.ScriptableRenderLoop.Lit.BSDFData: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.Lit.BSDFData: static fields
//
#define DEBUGVIEW_LIT_BSDFDATA_DIFFUSE_COLOR (1030)
#define DEBUGVIEW_LIT_BSDFDATA_FRESNEL0 (1031)

#define DEBUGVIEW_LIT_BSDFDATA_COAT_ROUGHNESS (1046)
//
// UnityEngine.ScriptableRenderLoop.Lit.GBufferMaterial: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.Lit.GBufferMaterial: static fields
// Generated from UnityEngine.ScriptableRenderLoop.Lit.SurfaceData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.Lit.SurfaceData
// PackingRules = Exact
struct SurfaceData
{

float ambientOcclusion;
float3 tangentWS;
float anisotropy;
float metalic;
float metallic;
float specular;
float subSurfaceRadius;
float thickness;

float3 specularColor;
};
// Generated from UnityEngine.ScriptableRenderLoop.Lit.BSDFData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.Lit.BSDFData
// PackingRules = Exact
struct BSDFData
{

30
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl


if (bsdfData.materialId == MATERIALID_LIT_STANDARD)
{
bsdfData.diffuseColor = surfaceData.baseColor * (1.0 - surfaceData.metalic);
bsdfData.fresnel0 = lerp(float3(surfaceData.specular, surfaceData.specular, surfaceData.specular), surfaceData.baseColor, surfaceData.metalic);
bsdfData.diffuseColor = surfaceData.baseColor * (1.0 - surfaceData.metallic);
bsdfData.fresnel0 = lerp(float3(surfaceData.specular, surfaceData.specular, surfaceData.specular), surfaceData.baseColor, surfaceData.metallic);
bsdfData.tangentWS = surfaceData.tangentWS;
bsdfData.bitangentWS = cross(surfaceData.normalWS, surfaceData.tangentWS);

}
else if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
bsdfData.diffuseColor = surfaceData.baseColor * (1.0 - surfaceData.metalic);
bsdfData.fresnel0 = lerp(float3(surfaceData.specular, surfaceData.specular, surfaceData.specular), surfaceData.baseColor, surfaceData.metalic);
bsdfData.diffuseColor = surfaceData.baseColor * (1.0 - surfaceData.metallic);
bsdfData.fresnel0 = lerp(float3(surfaceData.specular, surfaceData.specular, surfaceData.specular), surfaceData.baseColor, surfaceData.metallic);
bsdfData.coatNormalWS = surfaceData.coatNormalWS;
bsdfData.coatRoughness = PerceptualSmoothnessToRoughness(surfaceData.coatPerceptualSmoothness);
}

// Encode tangent on 16bit with oct compression
float2 octTangentWS = PackNormalOctEncode(surfaceData.tangentWS);
// TODO: store metal and specular together, specular should be an enum (fixed value)
outGBuffer2 = float4(octTangentWS * 0.5 + 0.5, surfaceData.anisotropy, surfaceData.metalic);
outGBuffer2 = float4(octTangentWS * 0.5 + 0.5, surfaceData.anisotropy, surfaceData.metallic);
}
else if (surfaceData.materialId == MATERIALID_LIT_SSS)
{

// Encode coat normal on 16bit with oct compression
float2 octCoatNormalWS = PackNormalOctEncode(surfaceData.coatNormalWS);
// TODO: store metal and specular together, specular should be an enum (fixed value)
outGBuffer2 = float4(octCoatNormalWS * 0.5 + 0.5, PerceptualSmoothnessToRoughness(surfaceData.coatPerceptualSmoothness), surfaceData.metalic);
outGBuffer2 = float4(octCoatNormalWS * 0.5 + 0.5, PerceptualSmoothnessToRoughness(surfaceData.coatPerceptualSmoothness), surfaceData.metallic);
}
else if (surfaceData.materialId == MATERIALID_LIT_SPECULAR)
{

if (bsdfData.materialId == MATERIALID_LIT_STANDARD)
{
float metalic = inGBuffer2.a;
float metallic = inGBuffer2.a;
bsdfData.diffuseColor = baseColor * (1.0 - metalic);
bsdfData.fresnel0 = lerp(float3(specular, specular, specular), baseColor, metalic);
bsdfData.diffuseColor = baseColor * (1.0 - metallic);
bsdfData.fresnel0 = lerp(float3(specular, specular, specular), baseColor, metallic);
bsdfData.tangentWS = UnpackNormalOctEncode(float2(inGBuffer2.rg * 2.0 - 1.0));
bsdfData.bitangentWS = cross(bsdfData.normalWS, bsdfData.tangentWS);

}
else if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
float metalic = inGBuffer2.a;
float metallic = inGBuffer2.a;
bsdfData.diffuseColor = baseColor * (1.0 - metalic);
bsdfData.fresnel0 = lerp(float3(specular, specular, specular), baseColor, metalic);
bsdfData.diffuseColor = baseColor * (1.0 - metallic);
bsdfData.fresnel0 = lerp(float3(specular, specular, specular), baseColor, metallic);
bsdfData.coatNormalWS = UnpackNormalOctEncode(float2(inGBuffer2.rg * 2.0 - 1.0));
bsdfData.coatRoughness = inGBuffer2.b;
}

case DEBUGVIEW_LIT_SURFACEDATA_ANISOTROPY:
result = surfaceData.anisotropy.xxx;
break;
case DEBUGVIEW_LIT_SURFACEDATA_METALIC:
result = surfaceData.metalic.xxx;
case DEBUGVIEW_LIT_SURFACEDATA_METALLIC:
result = surfaceData.metallic.xxx;
break;
// TODO: Remap here!
case DEBUGVIEW_LIT_SURFACEDATA_SPECULAR:

// But rough metals (black diffuse) still scatter quite a lot of light around, so
// we want to take some of that into account too.
lightTransportData.diffuseColor = bsdfData.diffuseColor + bsdfData.fresnel0 * bsdfData.roughness * 0.5 * surfaceData.metalic;
lightTransportData.diffuseColor = bsdfData.diffuseColor + bsdfData.fresnel0 * bsdfData.roughness * 0.5 * surfaceData.metallic;
lightTransportData.emissiveColor = builtinData.emissiveColor * builtinData.emissiveIntensity;
return lightTransportData;

8
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitData.hlsl


surfaceData.materialId = 0;
// MaskMap is Metalic, Ambient Occlusion, (Optional) - emissive Mask, Optional - Smoothness (in alpha)
// MaskMap is Metallic, Ambient Occlusion, (Optional) - emissive Mask, Optional - Smoothness (in alpha)
surfaceData.metalic = UNITY_SAMPLE_TEX2D(_MaskMap, input.texCoord0).r;
surfaceData.metallic = UNITY_SAMPLE_TEX2D(_MaskMap, input.texCoord0).r;
surfaceData.metalic = 1.0;
surfaceData.metallic = 1.0;
surfaceData.metalic *= _Metalic;
surfaceData.metallic *= _Metallic;
surfaceData.tangentWS = input.tangentToWorld[0].xyz; // TODO: do with tangent same as with normal, sample into texture etc...

4
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader


_BaseColor("BaseColor", Color) = (1,1,1,1)
_BaseColorMap("BaseColorMap", 2D) = "white" {}
_Metalic("_Metalic", Range(0.0, 1.0)) = 0
_Metallic("_Metallic", Range(0.0, 1.0)) = 0
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
_MaskMap("MaskMap", 2D) = "white" {}

float4 _BaseColor;
UNITY_DECLARE_TEX2D(_BaseColorMap);
float _Metalic;
float _Metallic;
float _Smoothness;
UNITY_DECLARE_TEX2D(_MaskMap);
UNITY_DECLARE_TEX2D(_SpecularOcclusionMap);

8
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitUI.cs


public static GUIContent baseColorText = new GUIContent("Base Color + Opacity", "Albedo (RGB) and Opacity (A)");
public static GUIContent baseColorSmoothnessText = new GUIContent("Base Color + Smoothness", "Albedo (RGB) and Smoothness (A)");
public static GUIContent metalicText = new GUIContent("Metalic", "Metalic scale factor");
public static GUIContent metallicText = new GUIContent("Metallic", "Metallic 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");

MaterialProperty baseColor = null;
MaterialProperty baseColorMap = null;
MaterialProperty metalic = null;
MaterialProperty metallic = null;
MaterialProperty smoothness = null;
MaterialProperty maskMap = null;
MaterialProperty specularOcclusionMap = null;

{
baseColor = FindProperty("_BaseColor", props);
baseColorMap = FindProperty("_BaseColorMap", props);
metalic = FindProperty("_Metalic", props);
metallic = FindProperty("_Metallic", props);
smoothness = FindProperty("_Smoothness", props);
maskMap = FindProperty(kMaskMap, props);
specularOcclusionMap = FindProperty(kspecularOcclusionMap, props);

GUILayout.Label(Styles.InputsText, EditorStyles.boldLabel);
m_MaterialEditor.TexturePropertySingleLine(smoothnessInAlbedoAlpha ? Styles.baseColorSmoothnessText : Styles.baseColorText, baseColorMap, baseColor);
m_MaterialEditor.ShaderProperty(metalic, Styles.metalicText);
m_MaterialEditor.ShaderProperty(metallic, Styles.metallicText);
m_MaterialEditor.ShaderProperty(smoothness, Styles.smoothnessText);
if (smoothnessInAlbedoAlpha && useEmissiveMask)

8
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/Unlit.cs.hlsl


//
//
// UnityEngine.ScriptableRenderLoop.Unlit.SurfaceData: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.Unlit.SurfaceData: static fields
// UnityEngine.ScriptableRenderLoop.Unlit.BSDFData: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.Unlit.BSDFData: static fields
// Generated from UnityEngine.ScriptableRenderLoop.Unlit.SurfaceData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.Unlit.SurfaceData
// PackingRules = Exact
struct SurfaceData
{

// Generated from UnityEngine.ScriptableRenderLoop.Unlit.BSDFData
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.Unlit.BSDFData
// PackingRules = Exact
struct BSDFData
{

4
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs


using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[GenerateHLSL(PackingRules.Exact)]
public enum ShaderPass

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs.hlsl


//
//
// UnityEngine.ScriptableRenderLoop.ShaderPass: static fields
// UnityEngine.Experimental.ScriptableRenderLoop.ShaderPass: static fields
//
#define SHADERPASS_GBUFFER (0)
#define SHADERPASS_FORWARD (1)

正在加载...
取消
保存