@@ -10,20 +10,14 @@ namespace UnityEditor.VFX.HDRP
1010 [ VFXInfo ( experimental = true ) ]
1111 class VFXDecalHDRPOutput : VFXAbstractParticleHDRPOutput
1212 {
13- public override string name
14- {
15- get { return "Output Particle HDRP Lit Decal" ; }
16- }
13+ public override string name { get { return "Output Particle HDRP Lit Decal" ; } }
1714
18- public override string codeGeneratorTemplate
19- {
20- get { return RenderPipeTemplate ( "VFXParticleHDRPDecal" ) ; }
21- }
15+ public override string codeGeneratorTemplate { get { return RenderPipeTemplate ( "VFXParticleHDRPDecal" ) ; } }
2216
23- public override VFXTaskType taskType
24- {
25- get { return VFXTaskType . ParticleHexahedronOutput ; }
26- }
17+ public override VFXTaskType taskType { get { return VFXTaskType . ParticleHexahedronOutput ; } }
18+
19+ public override bool isLitDecalShader { get => true ; }
20+ protected override RPInfo currentRP { get => hdrpLitDecalInfo ; }
2721
2822 public override void OnEnable ( )
2923 {
@@ -59,7 +53,6 @@ public override IEnumerable<VFXAttributeInfo> attributes
5953 }
6054 }
6155
62-
6356 public enum BlendSource
6457 {
6558 BaseColorMapAlpha ,
@@ -93,12 +86,9 @@ public enum BlendSource
9386 "When enabled, modifies the smoothness of the surface it projects onto using the (A) channel of the Mask Map if one is provided." ) ]
9487 private bool affectSmoothness = true ;
9588
96-
9789 private bool supportDecals => HDRenderPipeline . currentAsset . currentPlatformRenderPipelineSettings . supportDecals &&
9890 HDRenderPipeline . defaultAsset . GetDefaultFrameSettings ( FrameSettingsRenderType . Camera ) . IsEnabled ( FrameSettingsField . Decals ) ;
99-
10091 private bool enableDecalLayers =>
101-
10292 supportDecals
10393 && HDRenderPipeline . currentAsset . currentPlatformRenderPipelineSettings . supportDecalLayers
10494 && HDRenderPipeline . defaultAsset . GetDefaultFrameSettings ( FrameSettingsRenderType . Camera ) . IsEnabled ( FrameSettingsField . DecalLayers ) ;
@@ -112,7 +102,7 @@ public enum BlendSource
112102 Tooltip ( "Specifies the layer mask of the decal." ) ]
113103 private DecalLayerEnum decalLayer = DecalLayerEnum . DecalLayerDefault ;
114104
115- public override bool supportsUV { get { return GetOrRefreshShaderGraphObject ( ) == null ; } }
105+ public override bool supportsUV => true ;
116106
117107
118108 public class FadeFactorProperty
@@ -132,29 +122,32 @@ protected IEnumerable<VFXPropertyWithValue> materialProperties
132122 {
133123 get
134124 {
135- if ( affectMetal )
136- yield return new VFXPropertyWithValue ( new VFXProperty ( typeof ( float ) ,
137- "metallic" ,
138- new TooltipAttribute ( useMaskMap
139- ? "Controls the scale factor for the particle’s metallic."
140- : "Controls the metallic of the decal." ) ,
141- new RangeAttribute ( 0 , 1 ) ) , 0.0f ) ;
125+ if ( GetOrRefreshShaderGraphObject ( ) == null )
126+ {
127+ if ( affectMetal )
128+ yield return new VFXPropertyWithValue ( new VFXProperty ( typeof ( float ) ,
129+ "metallic" ,
130+ new TooltipAttribute ( useMaskMap
131+ ? "Controls the scale factor for the particle’s metallic."
132+ : "Controls the metallic of the decal." ) ,
133+ new RangeAttribute ( 0 , 1 ) ) , 0.0f ) ;
142134
143- if ( affectAmbientOcclusion )
144- yield return new VFXPropertyWithValue ( new VFXProperty ( typeof ( float ) ,
145- "ambientOcclusion" ,
146- new TooltipAttribute ( useMaskMap
147- ? "Controls the scale factor for the particle’s ambient occlusion."
148- : "Controls the ambient occlusion of the decal." ) ,
149- new RangeAttribute ( 0 , 1 ) ) , 1.0f ) ;
135+ if ( affectAmbientOcclusion )
136+ yield return new VFXPropertyWithValue ( new VFXProperty ( typeof ( float ) ,
137+ "ambientOcclusion" ,
138+ new TooltipAttribute ( useMaskMap
139+ ? "Controls the scale factor for the particle’s ambient occlusion."
140+ : "Controls the ambient occlusion of the decal." ) ,
141+ new RangeAttribute ( 0 , 1 ) ) , 1.0f ) ;
150142
151- if ( affectSmoothness )
152- yield return new VFXPropertyWithValue ( new VFXProperty ( typeof ( float ) ,
153- "smoothness" ,
154- new TooltipAttribute ( useMaskMap
155- ? "Controls the scale factor for the particle’s smoothness."
156- : "Controls the smoothness of the decal." ) ,
157- new RangeAttribute ( 0 , 1 ) ) , 0.5f ) ;
143+ if ( affectSmoothness )
144+ yield return new VFXPropertyWithValue ( new VFXProperty ( typeof ( float ) ,
145+ "smoothness" ,
146+ new TooltipAttribute ( useMaskMap
147+ ? "Controls the scale factor for the particle’s smoothness."
148+ : "Controls the smoothness of the decal." ) ,
149+ new RangeAttribute ( 0 , 1 ) ) , 0.5f ) ;
150+ }
158151 }
159152 }
160153
@@ -179,21 +172,19 @@ protected override IEnumerable<VFXNamedExpression> CollectGPUExpressions(
179172 {
180173 foreach ( var exp in base . CollectGPUExpressions ( slotExpressions ) )
181174 yield return exp ;
175+ yield return slotExpressions . First ( o => o . name == "fadeFactor" ) ;
176+ var angleFadeExp = slotExpressions . First ( o => o . name == "angleFade" ) ;
177+ yield return new VFXNamedExpression ( AngleFadeSimplification ( angleFadeExp . exp ) , "angleFade" ) ;
178+ yield return new VFXNamedExpression ( VFXValue . Constant ( ( uint ) decalLayer ) , "decalLayerMask" ) ;
182179
183180 if ( GetOrRefreshShaderGraphObject ( ) == null )
184181 {
185- yield return slotExpressions . First ( o => o . name == "fadeFactor" ) ;
186182 if ( affectMetal )
187183 yield return slotExpressions . First ( o => o . name == "metallic" ) ;
188184 if ( affectAmbientOcclusion )
189185 yield return slotExpressions . First ( o => o . name == "ambientOcclusion" ) ;
190186 if ( affectSmoothness )
191187 yield return slotExpressions . First ( o => o . name == "smoothness" ) ;
192-
193-
194- var angleFadeExp = slotExpressions . First ( o => o . name == "angleFade" ) ;
195- yield return new VFXNamedExpression ( AngleFadeSimplification ( angleFadeExp . exp ) , "angleFade" ) ;
196- yield return new VFXNamedExpression ( VFXValue . Constant ( ( uint ) decalLayer ) , "decalLayerMask" ) ;
197188 }
198189 }
199190
@@ -234,9 +225,9 @@ protected override IEnumerable<string> filteredOutSettings
234225 yield return "cullMode" ;
235226 yield return "blendMode" ;
236227 yield return "doubleSided" ;
237- yield return "shaderGraph" ;
238228 yield return "zTestMode" ;
239229 yield return "zWriteMode" ;
230+ yield return "zWriteMode" ;
240231 yield return "castShadows" ;
241232 yield return "materialType" ;
242233 yield return "sort" ;
@@ -254,6 +245,25 @@ public override IEnumerable<string> additionalDefines
254245 {
255246 foreach ( var def in base . additionalDefines )
256247 yield return def ;
248+
249+ // if (GetOrRefreshShaderGraphObject() != null)
250+ // {
251+ // if (maskOpacityChannel == BlendSource.BaseColorMapAlpha)
252+ // yield return "VFX_MASK_BLEND_BASE_COLOR_ALPHA";
253+ // else
254+ // yield return "VFX_MASK_BLEND_MASK_BLUE";
255+ //
256+ // if (normalOpacityChannel == BlendSource.BaseColorMapAlpha)
257+ // yield return "VFX_NORMAL_BLEND_BASE_COLOR_ALPHA";
258+ // else
259+ // yield return "VFX_NORMAL_BLEND_MASK_BLUE";
260+ //
261+ // // yield return "AFFECT_METALLIC";
262+ // // yield return "AFFECT_AMBIENT_OCCLUSION";
263+ // // yield return "AFFECT_SMOOTHNESS";
264+ // // yield return "NEEDS_FORWARD_EMISSIVE_PASS";
265+ // }
266+
257267 if ( maskOpacityChannel == BlendSource . BaseColorMapAlpha )
258268 yield return "VFX_MASK_BLEND_BASE_COLOR_ALPHA" ;
259269 else
@@ -264,14 +274,23 @@ public override IEnumerable<string> additionalDefines
264274 else
265275 yield return "VFX_NORMAL_BLEND_MASK_BLUE" ;
266276
267- if ( affectMetal )
268- yield return "AFFECT_METALLIC" ;
269- if ( affectAmbientOcclusion )
270- yield return "AFFECT_AMBIENT_OCCLUSION" ;
271- if ( affectSmoothness )
272- yield return "AFFECT_SMOOTHNESS" ;
273- if ( useEmissive || useEmissiveMap )
277+ if ( GetOrRefreshShaderGraphObject ( ) == null )
278+ {
279+ if ( affectMetal )
280+ yield return "AFFECT_METALLIC" ;
281+ if ( affectAmbientOcclusion )
282+ yield return "AFFECT_AMBIENT_OCCLUSION" ;
283+ if ( affectSmoothness )
284+ yield return "AFFECT_SMOOTHNESS" ;
285+ if ( useEmissive || useEmissiveMap )
286+ yield return "NEEDS_FORWARD_EMISSIVE_PASS" ;
287+ }
288+ else
289+ {
290+ //HACK KARL: ADD EMISIVE CALLS BACK
291+ //TODO
274292 yield return "NEEDS_FORWARD_EMISSIVE_PASS" ;
293+ }
275294 }
276295 }
277296
0 commit comments