Skip to content
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

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft

Conversation

Geenz
Copy link
Contributor

@Geenz Geenz commented May 9, 2024

Also we may have had a bad merge in LLGLTFMaterial.

indra/llprimitive/llgltfmaterial.cpp Outdated Show resolved Hide resolved
@@ -79,6 +79,7 @@ class gltf_render_material
double normalScale; // scale applies only to X,Y components of normal
double occlusionScale; // strength multiplier for occlusion
LLColor4 emissiveColor; // emissive mulitiplier, assumed linear encoding (spec 2.0 is silent)
double emissiveStrength; // multiplier for emissiveColor
Copy link
Collaborator

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 as F32 everywhere else, but seems like that is what we do for all the other fields so ok i guess

Copy link
Contributor Author

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.

Copy link
Contributor

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":

For floating-point components, JSON-stored minimum and maximum values represent single precision floats and SHOULD be rounded to single precision before usage to avoid any potential boundary mismatches.

Not relevant to this PR, but might be worth keeping in mind for the future. cc: @RunitaiLinden

indra/newview/app_settings/settings.xml Show resolved Hide resolved

// 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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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 LLGLTFMaterial::getHash uses mLocalTexDataDigest to determine the hash offset of the material object. (see "IMPORTANT: do not move this member down") Any fields prior to mLocalTexDataDigest will not get included in the hash. I didn't consider this before, but this probably takes precedence over @AndrewMeadows ' size optimizations.

This also would explain why the merge broke. There was a fix to GLTF hashing (and therefore render batching) in a maintenance branch.

…ure that emission strength max to something completely insane.

Probably a good reason for the packing that was modified.
@Geenz Geenz requested a review from cosmic-linden May 9, 2024 01:14
@brad-linden
Copy link
Collaborator

note: this PR has lots of merges in it, be sure not to do 'Squash and merge' when landing it.

@Geenz Geenz marked this pull request as draft May 14, 2024 16:21

void LLGLTFMaterial::setIOR(F32 ior, bool for_override)
{
mIOR = llmax(ior, 1.f);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the spec, a value of 0 is also allowed (but not (0, 1) )

mAttenuationDistance -= FLT_EPSILON;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the volume extension spec, a value of exactly zero is not allowed, and the default is +inifinity (which, coincidentally, is not a value that can be serialized to JSON, although I don't think that matters). In addition, infinity minus a finite number will evaluate to infinity, so we need something different for overrides as well.

Base automatically changed from project/gltf_development to develop June 13, 2024 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants