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

Add specification of target glossiness to configuration #359

Merged
merged 3 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/experimentConfigReadme.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ The following configuration is universal to all target types.
* `id` a short string to refer to this target information
* `respawnCount` is an integer providing the number of respawns to occur. For non-respawning items use `0` or leave unspecified. A value of `-1` creates a target that respawns infinitely (trial ends when ammo or task time runs out).
* `visualSize` is a vector indicating the minimum ([0]) and maximum ([1]) visual size for the target (in deg)
* `colors` is an array of 2 colors (max and min health) which are interpolated between based on target damage (note this setting override the experiment or session-level [`targetHealthColors`](general_config.md#target-rendering) setting). If unspecified the experiment/session level settings are used.
* `colors` is an array of 2 colors (max and min health) which are interpolated between based on target damage (note this setting overrides the experiment or session-level [`targetHealthColors`](general_config.md#target-rendering) setting). If unspecified the experiment/session level settings are used.
* `gloss` is a `Color4` representing glossyness, the first 3 channels are RGB w/ alpha representing minimum reflection (F0). Set all channels to 0 or do not specify to disable glossy reflections (note this setting overrides the experiment or session-level [`targetGloss`](general_config.md#target-rendering) setting). If unspecified the experiment/session level settings are used.
* `destSpace` the space for which the target is rendered (useful for non-destiantion based targets, "player" or "world")
* `hitSound` is a filename for the sound to play when the target is hit but not destroyed (for no sound use an empty string).
* `hitSoundVol` provides the volume (as a float) for the hit sound to be played at (default is `1.0`).
Expand Down
2 changes: 2 additions & 0 deletions docs/general_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ These flags help control the behavior of click-to-photon monitoring in applicati
| Parameter Name |Units | Description |
|-----------------------|-----------------------|------------------------------------------------------------------------------------|
|`targetHealthColors` |[`Color3`, `Color3`] | The max/min health colors for the target as an array of [`max color`, `min color`], if you do not want the target to change color as its health drops, set these values both to the same color |
|`targetGloss` |`Color4` | The target glossy (reflection) value, first 3 channels are RGB w/ alpha representing minimum reflection (F0). Set all channels to 0 or do not specify to disable glossy reflections. This sets the glossy color for the reference target in addition to trial targets |
|`showReferenceTarget` |`bool` | Show a reference target to re-center the view between trials/sessions? |
|`referenceTargetColor` |`Color3` | The color of the "reference" targets spawned between trials |
|`referenceTargetSize` |m | The size of the "reference" targets spawned between trials |
Expand Down Expand Up @@ -524,6 +525,7 @@ These flags help control the behavior of click-to-photon monitoring in applicati
"showPreviewTargetsWithReference" : false, // Don't show the preview targets with the reference
"showReferenceTargetMissDecals" : true, // Show miss decals for reference targets
"previewTargetColor" = Color3(0.5, 0.5, 0.5), // Use gray for preview targets (if they are shown)
"targetGloss" = Color4(0.4f, 0.2f, 0.1f, 0.8f), // Use the target gloss behavior from FPSci v22.02.01 and earlier
```

### Target Health Bars
Expand Down
10 changes: 9 additions & 1 deletion source/FPSciApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,18 @@ Array<shared_ptr<UniversalMaterial>> FPSciApp::makeMaterials(shared_ptr<TargetCo
else {
color = lerpColor(experimentConfig.targetView.healthColors, complete);
}
Color4 gloss;
if (notNull(tconfig) && tconfig->hasGloss) {
gloss = tconfig->gloss;
}
else {
gloss = experimentConfig.targetView.gloss;
}

UniversalMaterial::Specification materialSpecification;
materialSpecification.setLambertian(Texture::Specification(color));
materialSpecification.setEmissive(Texture::Specification(color * 0.7f));
materialSpecification.setGlossy(Texture::Specification(Color4(0.4f, 0.2f, 0.1f, 0.8f)));
materialSpecification.setGlossy(Texture::Specification(gloss)); // Used to be Color4(0.4f, 0.2f, 0.1f, 0.8f)
targetMaterials.append(UniversalMaterial::create(materialSpecification));
}
return targetMaterials;
Expand Down
1 change: 1 addition & 0 deletions source/FpsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ void TargetViewConfig::load(FPSciAnyTableReader reader, int settingsVersion) {
if (gotColors && healthColors.length() < 1) {
throw "Specified \"healthColors\" doesn't contain at least one Color3!";
}
reader.getIfPresent("targetGloss", gloss);
reader.getIfPresent("targetHealthBarColors", healthBarColors);
reader.getIfPresent("showFloatingCombatText", showCombatText);
reader.getIfPresent("floatingCombatTextSize", combatTextSize);
Expand Down
2 changes: 2 additions & 0 deletions source/FpsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ class TargetViewConfig {
Color3(1.0, 0.0, 0.0)
};

Color4 gloss; ///< Target glossyness (alpha is F0 or minimum reflectivity, see G3D docs)

// Target health bars
bool showHealthBars = false; ///< Display a target health bar?
Point2 healthBarSize = Point2(100.0f, 10.0f); ///< Health bar size (in pixels)
Expand Down
14 changes: 10 additions & 4 deletions source/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,9 @@ shared_ptr<TargetEntity> Session::spawnDestTarget(
target->setHitSound(config->hitSound, m_app->soundTable, config->hitSoundVol);
target->setDestoyedSound(config->destroyedSound, m_app->soundTable, config->destroyedSoundVol);
target->setFrame(position);
target->setColor(color);

Color4 gloss = config->hasGloss ? config->gloss : m_app->experimentConfig.targetView.gloss;
target->setColor(color, gloss);

// Add target to array and scene
insertTarget(target);
Expand All @@ -840,7 +842,7 @@ shared_ptr<FlyingEntity> Session::spawnReferenceTarget(

// Setup additional target parameters
target->setFrame(position);
target->setColor(color);
target->setColor(color, m_app->experimentConfig.targetView.gloss);

// Add target to array and scene
insertTarget(target);
Expand Down Expand Up @@ -869,7 +871,9 @@ shared_ptr<FlyingEntity> Session::spawnFlyingTarget(
}
target->setHitSound(config->hitSound, m_app->soundTable, config->hitSoundVol);
target->setDestoyedSound(config->destroyedSound, m_app->soundTable, config->destroyedSoundVol);
target->setColor(color);

Color4 gloss = config->hasGloss ? config->gloss : m_app->experimentConfig.targetView.gloss;
target->setColor(color, gloss);

// Add the target to the scene/target array
insertTarget(target);
Expand Down Expand Up @@ -899,7 +903,9 @@ shared_ptr<JumpingEntity> Session::spawnJumpingTarget(
}
target->setHitSound(config->hitSound, m_app->soundTable, config->hitSoundVol);
target->setDestoyedSound(config->destroyedSound, m_app->soundTable, config->destroyedSoundVol);
target->setColor(color);

Color4 gloss = config->hasGloss ? config->gloss : m_app->experimentConfig.targetView.gloss;
target->setColor(color, gloss);

// Add the target to the scene/target array
insertTarget(target);
Expand Down
1 change: 1 addition & 0 deletions source/TargetEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ TargetConfig::TargetConfig(const Any& any) {
reader.getIfPresent("destroyedSound", destroyedSound);
reader.getIfPresent("destroyedSoundVol", destroyedSoundVol);
reader.getIfPresent("colors", colors);
hasGloss = reader.getIfPresent("gloss", gloss);

break;
default:
Expand Down
6 changes: 4 additions & 2 deletions source/TargetEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class TargetConfig : public ReferenceCountedObject {

// Target color based on health
Array<Color3> colors; ///< Target start/end color (based on target health)
Color4 gloss; ///< Target gloss (alpha is F0, see docs)
bool hasGloss = false; ///< Target has gloss specified

Any modelSpec = PARSE_ANY(ArticulatedModel::Specification{ ///< Basic model spec for target
filename = "model/target/target.obj";
Expand Down Expand Up @@ -170,11 +172,11 @@ class TargetEntity : public VisibleEntity {
destinationIdx = 0;
}

void setColor(const Color3& color) {
void setColor(const Color3& color, const Color4& gloss = Color4()) {
UniversalMaterial::Specification materialSpecification;
materialSpecification.setLambertian(Texture::Specification(color));
materialSpecification.setEmissive(Texture::Specification(color * 0.7f));
materialSpecification.setGlossy(Texture::Specification(Color4(0.4f, 0.2f, 0.1f, 0.8f)));
materialSpecification.setGlossy(Texture::Specification(gloss)); // Used to be Color4(0.4f, 0.2f, 0.1f, 0.8f)

const shared_ptr<ArticulatedModel::Pose>& amPose = ArticulatedModel::Pose::create();
amPose->materialTable.set("core/icosahedron_default", UniversalMaterial::create(materialSpecification));
Expand Down