@@ -53,7 +53,9 @@ public class MaterialConverter : IMaterialConverter
53
53
private static readonly int DiffusionProfileAsset = Shader . PropertyToID ( "_DiffusionProfileAsset" ) ;
54
54
private static readonly int DiffusionProfileHash = Shader . PropertyToID ( "_DiffusionProfileHash" ) ;
55
55
private static readonly int MaterialID = Shader . PropertyToID ( "_MaterialID" ) ;
56
- private static readonly int EmissiveColor = Shader . PropertyToID ( "_EmissiveColor" ) ;
56
+ private static readonly int EmissiveColorHDR = Shader . PropertyToID ( "_EmissiveColor" ) ;
57
+ private static readonly int EmissiveColorLDR = Shader . PropertyToID ( "_EmissionColor" ) ;
58
+ private static readonly int EmissiveIntensity = Shader . PropertyToID ( "_EmissiveIntensity" ) ;
57
59
58
60
#endregion
59
61
@@ -214,12 +216,31 @@ public void SetMaterialType(Material material, MaterialType materialType)
214
216
215
217
public void SetEmissiveColor ( MaterialPropertyBlock propBlock , Color color )
216
218
{
217
- propBlock . SetColor ( EmissiveColor , color ) ;
219
+ propBlock . SetColor ( EmissiveColorHDR , color ) ;
218
220
}
219
221
220
222
public Color ? GetEmissiveColor ( Material material )
221
223
{
222
- return material . GetColor ( EmissiveColor ) ;
224
+ return material . GetColor ( EmissiveColorHDR ) ;
225
+ }
226
+
227
+ public void SetEmissiveIntensity ( Material material , MaterialPropertyBlock propBlock , float intensity )
228
+ {
229
+ var ldr = material . GetColor ( EmissiveColorLDR ) ;
230
+ var hdr = new Color ( Mathf . GammaToLinearSpace ( ldr . r ) * intensity , Mathf . GammaToLinearSpace ( ldr . g ) * intensity , Mathf . GammaToLinearSpace ( ldr . b ) * intensity ) ;
231
+ // var hdr = ldr * intensity;
232
+ propBlock . SetColor ( EmissiveColorHDR , hdr ) ;
233
+
234
+ Debug . Log ( $ "SET intensity ({ material . name } ) = { intensity } -> { ldr } / { hdr } ") ;
235
+ }
236
+
237
+ public float GetEmissiveIntensity ( Material material )
238
+ {
239
+ var hdr = material . GetColor ( EmissiveColorHDR ) ;
240
+ var ldr = material . GetColor ( EmissiveColorLDR ) ;
241
+ var intensity = hdr . r / ldr . r ; // just look at red for now
242
+ Debug . Log ( $ "GET intensity = { intensity } ({ hdr } / { ldr } )") ;
243
+ return intensity ;
223
244
}
224
245
225
246
private static Vector4 ConvertGUIDToVector4 ( string guid )
0 commit comments