-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KHR_materials_emissive_strength support #1441
base: develop
Are you sure you want to change the base?
Changes from 5 commits
bfdf8bc
9b9e8cb
5d1c81f
f071e0b
c19ee24
0edba68
4a354fb
441bb78
f726415
b2305f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ namespace tinygltf | |
class Model; | ||
struct TextureInfo; | ||
class Value; | ||
struct Material; | ||
} | ||
|
||
class LLTextureEntry; | ||
|
@@ -100,6 +101,11 @@ class LLGLTFMaterial : public LLRefCount | |
// -Cosmic,2023-01-26 | ||
GLTF_TEXTURE_INFO_OCCLUSION = GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS, | ||
GLTF_TEXTURE_INFO_EMISSIVE, | ||
GLTF_TEXTURE_INFO_TRANSMISSION_TEXTURE, | ||
// Geenz: The GLTF spec for KHR_materials_transmission states that the red channel of the transmission texture defines the | ||
// transmission factor, but the spec does not define what the green and blue channels are for. We are using the green channel to | ||
// define the thickness of the object, as the spec defines the green channel of the volume extension as thickness in KHR_materials_volume. | ||
GLTF_TEXTURE_INFO_THICKNESS_TEXTURE = GLTF_TEXTURE_INFO_TRANSMISSION_TEXTURE, | ||
|
||
GLTF_TEXTURE_INFO_COUNT | ||
}; | ||
|
@@ -110,6 +116,10 @@ class LLGLTFMaterial : public LLRefCount | |
static const char* const GLTF_FILE_EXTENSION_TRANSFORM_ROTATION; | ||
static const LLUUID GLTF_OVERRIDE_NULL_UUID; | ||
|
||
|
||
static const char *const GLTF_FILE_EXTENSION_EMISSIVE_STRENGTH; | ||
static const char *const GLTF_FILE_EXTENSION_EMISSIVE_STRENGTH_EMISSIVE_STRENGTH; | ||
|
||
// *TODO: If/when we implement additional GLTF extensions, they may not be | ||
// compatible with our GLTF terrain implementation. We may want to disallow | ||
// materials with some features from being set on terrain, if their | ||
|
@@ -120,12 +130,6 @@ class LLGLTFMaterial : public LLRefCount | |
// heightmaps cannot currently be described as finite enclosed | ||
// volumes. | ||
// See also LLPanelRegionTerrainInfo::validateMaterials | ||
bool mDoubleSided = false; | ||
|
||
|
||
// These fields are local to viewer and are a part of local bitmap support | ||
typedef std::map<LLUUID, LLUUID> local_tex_map_t; | ||
local_tex_map_t mTrackingIdToLocalTexture; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AndrewMeadows changed the order of the fields to save some bits. That's relevant to resolving this merge conflict. You may be interested in choosing a location for mEmissiveStrength to optimize the packing (although the savings may only be relevant server-side) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - I wasn't sure what the specific ordering was supposed to be here. I'll look at the git-blame and reorder as needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I restored the packing from the previous merge - I'm generally assuming there's a very good reason for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grokking this further, it appears there's a comment/warning further down that This also would explain why the merge broke. There was a fix to GLTF hashing (and therefore render batching) in a maintenance branch. |
||
|
||
public: | ||
|
||
|
@@ -145,6 +149,7 @@ class LLGLTFMaterial : public LLRefCount | |
void setBaseColorFactor(const LLColor4& baseColor, bool for_override = false); | ||
void setAlphaCutoff(F32 cutoff, bool for_override = false); | ||
void setEmissiveColorFactor(const LLColor3& emissiveColor, bool for_override = false); | ||
void setEmissiveStrength(F32 emissiveStrength, bool for_override = false); | ||
void setMetallicFactor(F32 metallic, bool for_override = false); | ||
void setRoughnessFactor(F32 roughness, bool for_override = false); | ||
void setAlphaMode(S32 mode, bool for_override = false); | ||
|
@@ -163,6 +168,7 @@ class LLGLTFMaterial : public LLRefCount | |
static F32 getDefaultRoughnessFactor(); | ||
static LLColor4 getDefaultBaseColor(); | ||
static LLColor3 getDefaultEmissiveColor(); | ||
static F32 getDefaultEmissiveStrength(); | ||
static bool getDefaultDoubleSided(); | ||
static LLVector2 getDefaultTextureOffset(); | ||
static LLVector2 getDefaultTextureScale(); | ||
|
@@ -228,6 +234,10 @@ class LLGLTFMaterial : public LLRefCount | |
bool hasLocalTextures() { return !mTrackingIdToLocalTexture.empty(); } | ||
virtual bool replaceLocalTexture(const LLUUID& tracking_id, const LLUUID &old_id, const LLUUID& new_id); | ||
virtual void updateTextureTracking(); | ||
|
||
static void writeEmissiveStrength(tinygltf::Material &material, F32 emissive_strength); | ||
static void setEmissiveStrengthFromModel(const tinygltf::Material &model, F32 &emissiveStrength); | ||
|
||
protected: | ||
static LLVector2 vec2FromJson(const std::map<std::string, tinygltf::Value>& object, const char* key, const LLVector2& default_value); | ||
static F32 floatFromJson(const std::map<std::string, tinygltf::Value>& object, const char* key, const F32 default_value); | ||
|
@@ -269,6 +279,7 @@ class LLGLTFMaterial : public LLRefCount | |
// NOTE: these values should be in linear color space | ||
LLColor4 mBaseColor; | ||
LLColor3 mEmissiveColor; | ||
F32 mEmissiveStrength = 1.0f; | ||
|
||
F32 mMetallicFactor; | ||
F32 mRoughnessFactor; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is confusing to me that it is
double
here but handled asF32
everywhere else, but seems like that is what we do for all the other fields so ok i guessThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was a bit weirded out by that. I'm keeping with the established convention more or less.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the GLTF spec, it does seem there are cases where single precision floating point is enforced. From the section on "Accessors Bounds":
Not relevant to this PR, but might be worth keeping in mind for the future. cc: @RunitaiLinden