Closed abwood closed 2 years ago
This is definitely easier for loaders but I'm not sure what the processing tools like gltfpack are supposed to do with this. You can decompose the color with components >1 into color+strength but that results in a different output compared to the input. The same question would arise for applications that use fixed-point quantization for material parameters to conserve material structure size.
Also if we ever get the [rather scary] property animation extension it's going to make it impossible to animate strength individually with this approach.
Thanks for implementing this @abwood! It feels like a great shortcut to do it this way, but I also understand the concerns raised by @zeux. I think if we follow that thought, maybe it would be better to implement this like the other extensions? Ultimately, the change to existing renderers/engines to support it then would be pretty minimal.
Great points, especially when considering the notional property animation extension. I can change it back to the original implementation.
That would be great! 😃
I think this is good now. I updated cgltf_write and tested it out by loading Box.gltf, cranking up emissive_strength to 5, and then writing it file. I loaded the resulting model into Filament and confirmed the results are as expected. Also ran it through the validator built into the VSCode gltf plugin and the written model came back clean.
Behold!
KHR_materials_emissive_strength is a new extension that recently entered the "Release Candidate" status. This one is pretty simple in that the core specification limits the emissiveFactor to values in the range of [0.0 - 1.0]. This extension provides an additional multiplier to amplify emission beyond 1.0.
After discussion (below) this implementation defines a new flag,
has_emissive_strength
and anemissive_strength
struct that embodies this float property. The original approach is quoted here to preserve the history of this PR conversation, but no longer applies ...For confirmation, I locally updated Filament with these changes. Here is an altered DamagedHelmet, with the addition of the KHR_materials_emissive_strength extension that defines a strength of 5.0.
And here is the original DamagedHelmet model (i.e., emissiveFactor=[1.0, 1.0, 1.0])![image](https://user-images.githubusercontent.com/3868547/143138839-627baddc-3fce-439e-88a6-a741c796524c.png)
TODO
/CC @emackey @prideout