1 //-----------------------------------------------------------------------------
2 // structure definition
3 //-----------------------------------------------------------------------------
4 using UnityEngine.Experimental.Rendering.HDPipeline.Attributes;
6 namespace UnityEngine.Experimental.Rendering.HDPipeline
8 public class Builtin // Note: This particular class doesn't derive from RenderPipelineMaterial
10 //-----------------------------------------------------------------------------
12 // This structure include common data that should be present in all material
13 // and are independent from the BSDF parametrization.
14 // Note: These parameters can be store in GBuffer or not depends on storage available
15 //-----------------------------------------------------------------------------
16 [GenerateHLSL(PackingRules.Exact, false, false, true, 100)]
17 public struct BuiltinData
19 [MaterialSharedPropertyMapping(MaterialSharedProperty.Alpha)]
20 [SurfaceDataAttributes("Opacity")]
23 // These are lighting data.
24 // We would prefer to split lighting and material information but for performance reasons,
25 // those lighting information are fill
26 // at the same time than material information.
27 [SurfaceDataAttributes("Bake Diffuse Lighting", false, true)]
28 public Vector3 bakeDiffuseLighting; // This is the result of sampling lightmap/lightprobe/proxyvolume
29 [SurfaceDataAttributes("Back Bake Diffuse Lighting", false, true)]
30 public Vector3 backBakeDiffuseLighting; // This is the result of sampling lightmap/lightprobe/proxyvolume from the back for transmission
32 // Use for float instead of vector4 to ease the debug (no performance impact)
33 // Note: We have no way to remove these value automatically based on either SHADEROPTIONS_BAKED_SHADOW_MASK_ENABLE or s_BakedShadowMaskEnable here. Unless we make two structure... For now always keep this value
34 [SurfaceDataAttributes("Shadow Mask 0")]
35 public float shadowMask0;
36 [SurfaceDataAttributes("Shadow Mask 1")]
37 public float shadowMask1;
38 [SurfaceDataAttributes("Shadow Mask 2")]
39 public float shadowMask2;
40 [SurfaceDataAttributes("Shadow Mask 3")]
41 public float shadowMask3;
43 [SurfaceDataAttributes("Emissive Color", false, false)]
44 public Vector3 emissiveColor;
46 // These is required for motion blur and temporalAA
47 [SurfaceDataAttributes("MotionVector")]
48 public Vector2 motionVector;
51 [SurfaceDataAttributes("Distortion")]
52 public Vector2 distortion;
53 [SurfaceDataAttributes("Distortion Blur")]
54 public float distortionBlur; // Define the color buffer mipmap level to use
57 [SurfaceDataAttributes("RenderingLayers")]
58 public uint renderingLayers;
60 [SurfaceDataAttributes("Depth Offset")]
61 public float depthOffset; // define the depth in unity unit to add in Z forward direction
64 //-----------------------------------------------------------------------------
66 // This struct is use to store information for Enlighten/Progressive light mapper. both at runtime or off line.
67 //-----------------------------------------------------------------------------
68 [GenerateHLSL(PackingRules.Exact, false)]
69 public struct LightTransportData
71 [SurfaceDataAttributes("", false, true)]
72 public Vector3 diffuseColor;
73 public Vector3 emissiveColor; // HDR value
76 public static GraphicsFormat GetLightingBufferFormat()
78 return GraphicsFormat.B10G11R11_UFloatPack32;
81 public static GraphicsFormat GetShadowMaskBufferFormat()
83 return GraphicsFormat.R8G8B8A8_UNorm;
86 public static GraphicsFormat GetMotionVectorFormat()
88 return GraphicsFormat.R16G16_SFloat; // TODO: We should use 16bit normalized instead, better precision // RGInt
91 public static GraphicsFormat GetDistortionBufferFormat()
93 // TODO: // This format need to be additive blendable and include distortionBlur, blend mode different for alpha value
94 return GraphicsFormat.R16G16B16A16_SFloat;