@@ -128,15 +128,16 @@ public void RegisterDebug()
128128 DebugMenuManager . instance . AddDebugItem < bool > ( "Rendering" , "Display Opaque" , ( ) => renderingDebugSettings . displayOpaqueObjects , ( value ) => renderingDebugSettings . displayOpaqueObjects = ( bool ) value ) ;
129129 DebugMenuManager . instance . AddDebugItem < bool > ( "Rendering" , "Display Transparency" , ( ) => renderingDebugSettings . displayTransparentObjects , ( value ) => renderingDebugSettings . displayTransparentObjects = ( bool ) value ) ;
130130 DebugMenuManager . instance . AddDebugItem < bool > ( "Rendering" , "Enable Distortion" , ( ) => renderingDebugSettings . enableDistortion , ( value ) => renderingDebugSettings . enableDistortion = ( bool ) value ) ;
131- DebugMenuManager . instance . AddDebugItem < bool > ( "Rendering" , "Enable Subsurface Scattering" , ( ) => renderingDebugSettings . enableSSS , ( value ) => renderingDebugSettings . enableSSS = ( bool ) value ) ;
131+ DebugMenuManager . instance . AddDebugItem < bool > ( "Rendering" , "Enable Subsurface Scattering" , ( ) => renderingDebugSettings . enableSSSAndTransmission , ( value ) => renderingDebugSettings . enableSSSAndTransmission = ( bool ) value ) ;
132132 }
133133
134134 public void OnValidate ( )
135135 {
136136 lightingDebugSettings . OnValidate ( ) ;
137137 }
138138
139- void FillWithProperties ( Type type , GUIContent [ ] debugViewMaterialStrings , int [ ] debugViewMaterialValues , string strSubNameSpace , ref int index )
139+ // className include the additional "/"
140+ void FillWithProperties ( Type type , GUIContent [ ] debugViewMaterialStrings , int [ ] debugViewMaterialValues , string className , ref int index )
140141 {
141142 var attributes = type . GetCustomAttributes ( true ) ;
142143 // Get attribute to get the start number of the value for the enum
@@ -164,7 +165,7 @@ void FillWithProperties(Type type, GUIContent[] debugViewMaterialStrings, int[]
164165 }
165166 }
166167
167- fieldName = strSubNameSpace + fieldName ;
168+ fieldName = className + fieldName ;
168169
169170 debugViewMaterialStrings [ index ] = new GUIContent ( fieldName ) ;
170171 debugViewMaterialValues [ index ] = attr . paramDefinesStart + ( int ) localIndex ;
@@ -189,57 +190,94 @@ void FillWithPropertiesEnum(Type type, GUIContent[] debugViewMaterialStrings, in
189190 }
190191 }
191192
192- string GetSubNameSpaceName ( Type type )
193+ public class MaterialItem
193194 {
194- return type . Namespace . Substring ( type . Namespace . LastIndexOf ( ( "." ) ) + 1 ) + "/" ;
195- }
195+ public String className ;
196+ public Type surfaceDataType ;
197+ public Type bsdfDataType ;
198+ } ;
196199
197200 void BuildDebugRepresentation ( )
198201 {
199202 if ( ! isDebugViewMaterialInit )
200203 {
201- var varyingNames = Enum . GetNames ( typeof ( Attributes . DebugViewVarying ) ) ;
202- debugViewMaterialVaryingStrings = new GUIContent [ varyingNames . Length ] ;
203- debugViewMaterialVaryingValues = new int [ varyingNames . Length ] ;
204- var gbufferNames = Enum . GetNames ( typeof ( Attributes . DebugViewGbuffer ) ) ;
205- debugViewMaterialGBufferStrings = new GUIContent [ gbufferNames . Length + typeof ( Lit . BSDFData ) . GetFields ( ) . Length ] ;
206- debugViewMaterialGBufferValues = new int [ gbufferNames . Length + typeof ( Lit . BSDFData ) . GetFields ( ) . Length ] ;
204+ List < RenderPipelineMaterial > materialList = Utilities . GetRenderPipelineMaterialList ( ) ;
207205
208- var num = typeof ( Builtin . BuiltinData ) . GetFields ( ) . Length * 2 // BuildtinData are duplicated for each material
209- + typeof ( Lit . SurfaceData ) . GetFields ( ) . Length
210- + typeof ( Unlit . SurfaceData ) . GetFields ( ) . Length
211- + 1 ; // None
206+ // TODO: Share this code to retrieve deferred material with HDRenderPipeline
207+ // Find first material that have non 0 Gbuffer count and assign it as deferredMaterial
208+ Type bsdfDataDeferredType = null ;
209+ foreach ( RenderPipelineMaterial material in materialList )
210+ {
211+ if ( material . GetMaterialGBufferCount ( ) > 0 )
212+ {
213+ bsdfDataDeferredType = material . GetType ( ) . GetNestedType ( "BSDFData" ) ;
214+ }
215+ }
212216
213- debugViewMaterialStrings = new GUIContent [ num ] ;
214- debugViewMaterialValues = new int [ num ] ;
217+ // TODO: Handle the case of no Gbuffer material
218+ Debug . Assert ( bsdfDataDeferredType != null ) ;
215219
216- num = typeof ( Lit . BSDFData ) . GetFields ( ) . Length
217- + typeof ( Unlit . BSDFData ) . GetFields ( ) . Length
218- + 1 ; // None
220+ List < MaterialItem > materialItems = new List < MaterialItem > ( ) ;
219221
220- debugViewEngineStrings = new GUIContent [ num ] ;
221- debugViewEngineValues = new int [ num ] ;
222+ int numSurfaceDataFields = 0 ;
223+ int numBSDFDataFields = 0 ;
224+ foreach ( RenderPipelineMaterial material in materialList )
225+ {
226+ MaterialItem item = new MaterialItem ( ) ;
227+
228+ item . className = material . GetType ( ) . Name + "/" ;
229+
230+ item . surfaceDataType = material . GetType ( ) . GetNestedType ( "SurfaceData" ) ;
231+ numSurfaceDataFields += item . surfaceDataType . GetFields ( ) . Length ;
222232
233+ item . bsdfDataType = material . GetType ( ) . GetNestedType ( "BSDFData" ) ;
234+ numBSDFDataFields += item . bsdfDataType . GetFields ( ) . Length ;
223235
224- // Special case for None since it cannot be inferred from SurfaceDAta/BuiltinData
236+ materialItems . Add ( item ) ;
237+ }
238+
239+ // Material properties debug
240+ var num = typeof ( Builtin . BuiltinData ) . GetFields ( ) . Length * materialList . Count // BuildtinData are duplicated for each material
241+ + numSurfaceDataFields + 1 ; // +1 for None case
242+
243+ debugViewMaterialStrings = new GUIContent [ num ] ;
244+ debugViewMaterialValues = new int [ num ] ;
245+ // Special case for None since it cannot be inferred from SurfaceData/BuiltinData
225246 debugViewMaterialStrings [ 0 ] = new GUIContent ( "None" ) ;
226247 debugViewMaterialValues [ 0 ] = 0 ;
227248 var index = 1 ;
228249 // 0 is a reserved number and should not be used (allow to track error)
229- FillWithProperties ( typeof ( Builtin . BuiltinData ) , debugViewMaterialStrings , debugViewMaterialValues , GetSubNameSpaceName ( typeof ( Lit . SurfaceData ) ) , ref index ) ;
230- FillWithProperties ( typeof ( Lit . SurfaceData ) , debugViewMaterialStrings , debugViewMaterialValues , GetSubNameSpaceName ( typeof ( Lit . SurfaceData ) ) , ref index ) ;
231- FillWithProperties ( typeof ( Builtin . BuiltinData ) , debugViewMaterialStrings , debugViewMaterialValues , GetSubNameSpaceName ( typeof ( Unlit . SurfaceData ) ) , ref index ) ;
232- FillWithProperties ( typeof ( Unlit . SurfaceData ) , debugViewMaterialStrings , debugViewMaterialValues , GetSubNameSpaceName ( typeof ( Unlit . SurfaceData ) ) , ref index ) ;
250+ foreach ( MaterialItem item in materialItems )
251+ {
252+ // BuiltinData are duplicated for each material
253+ FillWithProperties ( typeof ( Builtin . BuiltinData ) , debugViewMaterialStrings , debugViewMaterialValues , item . className , ref index ) ;
254+ FillWithProperties ( item . surfaceDataType , debugViewMaterialStrings , debugViewMaterialValues , item . className , ref index ) ;
255+ }
233256
234- // Engine
257+ // Engine properties debug
258+ num = numBSDFDataFields + 1 ; // +1 for None case
259+ debugViewEngineStrings = new GUIContent [ num ] ;
260+ debugViewEngineValues = new int [ num ] ;
261+ // 0 is a reserved number and should not be used (allow to track error)
235262 debugViewEngineStrings [ 0 ] = new GUIContent ( "None" ) ;
236263 debugViewEngineValues [ 0 ] = 0 ;
237264 index = 1 ;
238- FillWithProperties ( typeof ( Lit . BSDFData ) , debugViewEngineStrings , debugViewEngineValues , GetSubNameSpaceName ( typeof ( Lit . BSDFData ) ) , ref index ) ;
239- FillWithProperties ( typeof ( Unlit . BSDFData ) , debugViewEngineStrings , debugViewEngineValues , GetSubNameSpaceName ( typeof ( Unlit . BSDFData ) ) , ref index ) ;
265+ foreach ( MaterialItem item in materialItems )
266+ {
267+ FillWithProperties ( item . bsdfDataType , debugViewEngineStrings , debugViewEngineValues , item . className , ref index ) ;
268+ }
240269
270+ // Attributes debug
271+ var varyingNames = Enum . GetNames ( typeof ( Attributes . DebugViewVarying ) ) ;
272+ debugViewMaterialVaryingStrings = new GUIContent [ varyingNames . Length ] ;
273+ debugViewMaterialVaryingValues = new int [ varyingNames . Length ] ;
241274 index = 0 ;
242275 FillWithPropertiesEnum ( typeof ( Attributes . DebugViewVarying ) , debugViewMaterialVaryingStrings , debugViewMaterialVaryingValues , "" , ref index ) ;
276+
277+ // Gbuffer debug
278+ var gbufferNames = Enum . GetNames ( typeof ( Attributes . DebugViewGbuffer ) ) ;
279+ debugViewMaterialGBufferStrings = new GUIContent [ gbufferNames . Length + bsdfDataDeferredType . GetFields ( ) . Length ] ;
280+ debugViewMaterialGBufferValues = new int [ gbufferNames . Length + bsdfDataDeferredType . GetFields ( ) . Length ] ;
243281 index = 0 ;
244282 FillWithPropertiesEnum ( typeof ( Attributes . DebugViewGbuffer ) , debugViewMaterialGBufferStrings , debugViewMaterialGBufferValues , "" , ref index ) ;
245283 FillWithProperties ( typeof ( Lit . BSDFData ) , debugViewMaterialGBufferStrings , debugViewMaterialGBufferValues , "" , ref index ) ;
@@ -348,7 +386,7 @@ public class RenderingDebugSettings
348386 public bool displayOpaqueObjects = true ;
349387 public bool displayTransparentObjects = true ;
350388 public bool enableDistortion = true ;
351- public bool enableSSS = true ;
389+ public bool enableSSSAndTransmission = true ;
352390 }
353391
354392 public enum ShadowMapDebugMode
0 commit comments