@@ -21,9 +21,17 @@ export interface IEditorPBRMaterialInspectorProps {
2121 material : PBRMaterial ;
2222}
2323
24- export class EditorPBRMaterialInspector extends Component < IEditorPBRMaterialInspectorProps > {
24+ export interface IEditorPBRMaterialInspectorState {
25+ subSurfaceEnabled : boolean ;
26+ }
27+
28+ export class EditorPBRMaterialInspector extends Component < IEditorPBRMaterialInspectorProps , IEditorPBRMaterialInspectorState > {
2529 public constructor ( props : IEditorPBRMaterialInspectorProps ) {
2630 super ( props ) ;
31+
32+ this . state = {
33+ subSurfaceEnabled : this . props . material . subSurface . isRefractionEnabled || this . props . material . subSurface . isTranslucencyEnabled ,
34+ } ;
2735 }
2836
2937 public render ( ) : ReactNode {
@@ -238,36 +246,96 @@ export class EditorPBRMaterialInspector extends Component<IEditorPBRMaterialInsp
238246 ) }
239247
240248 < EditorInspectorSectionField title = "Sub Surface" >
241- < EditorInspectorTextureField scene = { scene } object = { this . props . material . subSurface } property = "thicknessTexture" title = "Thickness Texture" >
242- < EditorInspectorSwitchField label = "Use Mask From Thickness Texture" object = { this . props . material . subSurface } property = "useMaskFromThicknessTexture" />
243- < EditorInspectorNumberField label = "Minimum Thickness" object = { this . props . material . subSurface } property = "minimumThickness" min = { 0 } />
244- < EditorInspectorNumberField label = "Maximum Thickness" object = { this . props . material . subSurface } property = "maximumThickness" min = { 0 } />
245- </ EditorInspectorTextureField >
249+ < EditorInspectorSwitchField object = { this . state } property = "subSurfaceEnabled" label = "Enabled" onChange = { ( v ) => this . _handleSubSurfaceEnabledChange ( v ) } />
246250
247- < EditorInspectorColorField label = { < div className = "w-14" > Tint</ div > } object = { this . props . material . subSurface } property = "tintColor" />
251+ { this . state . subSurfaceEnabled && (
252+ < >
253+ < EditorInspectorColorField label = { < div className = "w-14" > Tint</ div > } object = { this . props . material . subSurface } property = "tintColor" />
248254
249- < EditorInspectorBlockField >
250- < div className = "font-semibold text-base text-center" > Refraction</ div >
251- < EditorInspectorSwitchField label = "Enabled" object = { this . props . material . subSurface } property = "isRefractionEnabled" onChange = { ( ) => this . forceUpdate ( ) } />
255+ < EditorInspectorTextureField scene = { scene } object = { this . props . material . subSurface } property = "thicknessTexture" title = "Thickness Texture" >
256+ < EditorInspectorSwitchField
257+ label = "Use Mask From Thickness Texture"
258+ object = { this . props . material . subSurface }
259+ property = "useMaskFromThicknessTexture"
260+ />
261+ < EditorInspectorNumberField label = "Minimum Thickness" object = { this . props . material . subSurface } property = "minimumThickness" min = { 0 } />
262+ < EditorInspectorNumberField label = "Maximum Thickness" object = { this . props . material . subSurface } property = "maximumThickness" min = { 0 } />
263+ </ EditorInspectorTextureField >
252264
253- { this . props . material . subSurface . isRefractionEnabled && (
254- < >
255- < EditorInspectorNumberField label = "Intensity" object = { this . props . material . subSurface } property = "refractionIntensity" min = { 0 } />
256- < EditorInspectorNumberField label = "Index of Refraction" object = { this . props . material . subSurface } property = "indexOfRefraction" min = { 0 } />
257- </ >
258- ) }
259- </ EditorInspectorBlockField >
265+ < EditorInspectorBlockField >
266+ < div className = "font-semibold text-base text-center" > Refraction</ div >
267+ < EditorInspectorSwitchField
268+ label = "Enabled"
269+ object = { this . props . material . subSurface }
270+ property = "isRefractionEnabled"
271+ onChange = { ( ) => this . forceUpdate ( ) }
272+ />
260273
261- < EditorInspectorBlockField >
262- < div className = "font-semibold text-base text-center" > Translucency</ div >
263- < EditorInspectorSwitchField label = "Enabled" object = { this . props . material . subSurface } property = "isTranslucencyEnabled" onChange = { ( ) => this . forceUpdate ( ) } />
274+ { this . props . material . subSurface . isRefractionEnabled && (
275+ < >
276+ < EditorInspectorNumberField label = "Intensity" object = { this . props . material . subSurface } property = "refractionIntensity" min = { 0 } />
277+ < EditorInspectorNumberField label = "Index of Refraction" object = { this . props . material . subSurface } property = "indexOfRefraction" min = { 0 } />
278+ </ >
279+ ) }
280+ </ EditorInspectorBlockField >
264281
265- { this . props . material . subSurface . isTranslucencyEnabled && (
266- < >
267- < EditorInspectorNumberField label = "Intensity" object = { this . props . material . subSurface } property = "translucencyIntensity" min = { 0 } />
268- </ >
269- ) }
270- </ EditorInspectorBlockField >
282+ < EditorInspectorBlockField >
283+ < div className = "font-semibold text-base text-center" > Translucency</ div >
284+ < EditorInspectorSwitchField
285+ label = "Enabled"
286+ object = { this . props . material . subSurface }
287+ property = "isTranslucencyEnabled"
288+ onChange = { ( ) => this . forceUpdate ( ) }
289+ />
290+
291+ { this . props . material . subSurface . isTranslucencyEnabled && (
292+ < >
293+ < EditorInspectorNumberField label = "Intensity" object = { this . props . material . subSurface } property = "translucencyIntensity" min = { 0 } />
294+ </ >
295+ ) }
296+ </ EditorInspectorBlockField >
297+ </ >
298+ ) }
299+ </ EditorInspectorSectionField >
300+
301+ < EditorInspectorSectionField title = "Iridescence" >
302+ < EditorInspectorSwitchField label = "Enabled" object = { this . props . material . iridescence } property = "isEnabled" onChange = { ( ) => this . forceUpdate ( ) } />
303+
304+ { this . props . material . iridescence . isEnabled && (
305+ < >
306+ < EditorInspectorNumberField label = "Intensity" object = { this . props . material . iridescence } property = "intensity" min = { 0 } />
307+ < EditorInspectorNumberField label = "Index of Refraction" object = { this . props . material . iridescence } property = "indexOfRefraction" min = { 0 } />
308+ < EditorInspectorNumberField label = "Minimum Thickness" object = { this . props . material . iridescence } property = "minimumThickness" min = { 0 } />
309+ < EditorInspectorNumberField label = "Maximum Thickness" object = { this . props . material . iridescence } property = "maximumThickness" min = { 0 } />
310+
311+ < EditorInspectorTextureField scene = { scene } object = { this . props . material . iridescence } property = "texture" title = "Intensity Texture" />
312+ < EditorInspectorTextureField scene = { scene } object = { this . props . material . iridescence } property = "thicknessTexture" title = "Thickness Texture" />
313+ </ >
314+ ) }
315+ </ EditorInspectorSectionField >
316+
317+ < EditorInspectorSectionField title = "Sheen" >
318+ < EditorInspectorSwitchField label = "Enabled" object = { this . props . material . sheen } property = "isEnabled" onChange = { ( ) => this . forceUpdate ( ) } />
319+
320+ { this . props . material . sheen . isEnabled && (
321+ < >
322+ < EditorInspectorNumberField label = "Intensity" object = { this . props . material . sheen } property = "intensity" min = { 0 } />
323+ < EditorInspectorColorField label = { < div className = "w-14" > Color</ div > } object = { this . props . material . sheen } property = "color" />
324+
325+ < EditorInspectorTextureField scene = { scene } object = { this . props . material . sheen } property = "texture" title = "Tint Texture" >
326+ < EditorInspectorSwitchField
327+ label = "Use Roughness From Main Texture"
328+ object = { this . props . material . sheen }
329+ property = "useRoughnessFromMainTexture"
330+ onChange = { ( ) => this . forceUpdate ( ) }
331+ />
332+ </ EditorInspectorTextureField >
333+
334+ { ! this . props . material . sheen . useRoughnessFromMainTexture && (
335+ < EditorInspectorTextureField scene = { scene } object = { this . props . material . sheen } property = "textureRoughness" title = "Roughness Texture" />
336+ ) }
337+ </ >
338+ ) }
271339 </ EditorInspectorSectionField >
272340
273341 < EditorInspectorSectionField title = "Intensity Properties" >
@@ -285,6 +353,7 @@ export class EditorPBRMaterialInspector extends Component<IEditorPBRMaterialInsp
285353 < EditorInspectorSwitchField label = "Use Radiance Occlusion" object = { this . props . material } property = "useRadianceOcclusion" />
286354 < EditorInspectorSwitchField label = "Use Horizon Occlusion" object = { this . props . material } property = "useHorizonOcclusion" />
287355 < EditorInspectorSwitchField label = "Use Physical Light Falloff" object = { this . props . material } property = "usePhysicalLightFalloff" />
356+ < EditorInspectorSwitchField label = "Use Spherical Harmonics" object = { this . props . material . brdf } property = "useSphericalHarmonics" />
288357 < EditorInspectorSwitchField label = "Use Radiance Over Alpha" object = { this . props . material } property = "useRadianceOverAlpha" />
289358 < EditorInspectorSwitchField label = "Use Specular Over Alpha" object = { this . props . material } property = "useSpecularOverAlpha" />
290359 < EditorInspectorSwitchField label = "Separate Culling Pass" object = { this . props . material } property = "separateCullingPass" />
@@ -297,4 +366,15 @@ export class EditorPBRMaterialInspector extends Component<IEditorPBRMaterialInsp
297366 </ >
298367 ) ;
299368 }
369+
370+ private _handleSubSurfaceEnabledChange ( v : boolean ) : void {
371+ if ( ! v ) {
372+ this . props . material . subSurface . isRefractionEnabled = false ;
373+ this . props . material . subSurface . isTranslucencyEnabled = false ;
374+ }
375+
376+ this . setState ( {
377+ subSurfaceEnabled : v ,
378+ } ) ;
379+ }
300380}
0 commit comments