Converted Haze initialization values to static.

This commit is contained in:
Nissim Hadar 2017-10-30 11:51:19 -07:00
parent d6b3fa4cb1
commit 5fc68cae0d
8 changed files with 128 additions and 123 deletions

View file

@ -1,4 +1,4 @@
set(TARGET_NAME entities)
setup_hifi_library(Network Script)
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
link_hifi_libraries(shared networking octree avatars model)
link_hifi_libraries(shared networking octree avatars model gpu)

View file

@ -21,7 +21,7 @@
#include "PropertyGroup.h"
#include "EntityItemPropertiesMacros.h"
#include <model/HazeInit.h>
#include <model/Haze.h>
class EntityItemProperties;
class EncodeBitstreamParams;
@ -77,24 +77,24 @@ public:
bool& somethingChanged) override;
// Range only parameters
DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, model::initialHazeRange_m);
DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, model::initialHazeColorXcolor);
DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, model::initialHazeGlareColorXcolor);
DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, model::Haze::initialHazeRange_m);
DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, model::Haze::initialHazeColorXcolor);
DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, model::Haze::initialHazeGlareColorXcolor);
DEFINE_PROPERTY(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare, hazeEnableGlare, bool, false);
DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, model::initialGlareAngle_degs);
DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, model::Haze::initialGlareAngle_degs);
// Altitude parameters
DEFINE_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect, hazeAltitudeEffect, bool, false);
DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, model::initialHazeBaseReference_m + model::initialHazeHeight_m);
DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, model::initialHazeBaseReference_m);
DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, model::Haze::initialHazeBaseReference_m + model::Haze::initialHazeHeight_m);
DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, model::Haze::initialHazeBaseReference_m);
// Background (skybox) blend value
DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, model::initialHazeBackgroundBlend);
DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, model::Haze::initialHazeBackgroundBlend);
// hazeDirectional light attenuation
DEFINE_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, HazeAttenuateKeyLight, hazeAttenuateKeyLight, bool, false);
DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, model::initialHazeKeyLightRange_m);
DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, model::initialHazeKeyLightAltitude_m);
DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, model::Haze::initialHazeKeyLightRange_m);
DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, model::Haze::initialHazeKeyLightAltitude_m);
};
#endif // hifi_HazePropertyGroup_h

View file

@ -19,7 +19,7 @@
#include "HazePropertyGroup.h"
#include "StagePropertyGroup.h"
#include <ComponentMode.h>
#include <model/HazeInit.h>
#include <model/Haze.h>
class ZoneEntityItem : public EntityItem {
public:

View file

@ -9,12 +9,35 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <memory>
#include <gpu/Resource.h>
#include "Haze.h"
using namespace model;
const float Haze::initialHazeRange_m{ 1000.0f };
const float Haze::initialHazeHeight_m{ 200.0f };
const float Haze::initialHazeKeyLightRange_m{ 1000.0f };
const float Haze::initialHazeKeyLightAltitude_m{ 200.0f };
const float Haze::initialHazeBackgroundBlend{ 0.0f };
const glm::vec3 Haze::initialColorModulationFactor{
convertHazeRangeToHazeRangeFactor(initialHazeRange_m),
convertHazeRangeToHazeRangeFactor(initialHazeRange_m),
convertHazeRangeToHazeRangeFactor(initialHazeRange_m)
};
const glm::vec3 Haze::initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish
const xColor Haze::initialHazeColorXcolor{ 128, 154, 179 };
const float Haze::initialGlareAngle_degs{ 20.0f };
const glm::vec3 Haze::initialHazeGlareColor{ 1.0f, 0.9f, 0.7f };
const xColor Haze::initialHazeGlareColorXcolor{ 255, 229, 179 };
const float Haze::initialHazeBaseReference_m{ 0.0f };
Haze::Haze() {
Parameters parameters;
_hazeParametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Parameters), (const gpu::Byte*) &parameters));

View file

@ -12,17 +12,68 @@
#define hifi_model_Haze_h
#include <glm/glm.hpp>
#include <gpu/Resource.h>
#include "Transform.h"
#include "NumericalConstants.h"
#include "HazeInit.h"
namespace model {
const float LOG_P_005 = logf(0.05f);
const float LOG_P_05 = logf(0.5f);
// Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05
// f = exp(-d * b)
// ln(f) = -d * b
// b = -ln(f)/d
inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) {
return glm::vec3(
-LOG_P_005 / hazeRange_m.x,
-LOG_P_005 / hazeRange_m.y,
-LOG_P_005 / hazeRange_m.z);
}
// limit range and altitude to no less than 1.0 metres
inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return -LOG_P_005 / glm::max(hazeRange_m, 1.0f); }
inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight_m) { return -LOG_P_005 / glm::max(hazeHeight_m, 1.0f); }
// Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5
// s = dot(lookAngle, sunAngle) = cos(a)
// m = pow(s, p)
// log(m) = p * log(s)
// p = log(m) / log(s)
// limit to 0.1 degrees
inline float convertGlareAngleToPower(const float hazeGlareAngle) {
const float GLARE_ANGLE_LIMIT = 0.1f;
return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle)));
}
// Haze range is defined here as the range the visibility is reduced by 95%
// Haze altitude is defined here as the altitude (above 0) that the haze is reduced by 95%
class Haze {
public:
// Initial values
static const float initialHazeRange_m;
static const float initialHazeHeight_m;
static const float initialHazeKeyLightRange_m;
static const float initialHazeKeyLightAltitude_m;
static const float initialHazeBackgroundBlend;
static const glm::vec3 initialColorModulationFactor;
static const glm::vec3 initialHazeColor;
static const xColor initialHazeColorXcolor;
static const float initialGlareAngle_degs;
static const glm::vec3 initialHazeGlareColor;
static const xColor initialHazeGlareColorXcolor;
static const float initialHazeBaseReference_m;
using UniformBufferView = gpu::BufferView;
Haze();

View file

@ -1,69 +0,0 @@
//
// MakeHaze.h
// libraries/model/src/model
//
// Created by Nissim Hadar on 10/26/2017.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_model_HazeInit_h
#define hifi_model_HazeInit_h
namespace model {
const float LOG_P_005 = logf(0.05f);
const float LOG_P_05 = logf(0.5f);
// Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05
// f = exp(-d * b)
// ln(f) = -d * b
// b = -ln(f)/d
inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) {
return glm::vec3(
-LOG_P_005 / hazeRange_m.x,
-LOG_P_005 / hazeRange_m.y,
-LOG_P_005 / hazeRange_m.z);
}
// limit range and altitude to no less than 1.0 metres
inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return -LOG_P_005 / glm::max(hazeRange_m, 1.0f); }
inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight_m) { return -LOG_P_005 / glm::max(hazeHeight_m, 1.0f); }
// Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5
// s = dot(lookAngle, sunAngle) = cos(a)
// m = pow(s, p)
// log(m) = p * log(s)
// p = log(m) / log(s)
// limit to 0.1 degrees
inline float convertGlareAngleToPower(const float hazeGlareAngle) {
const float GLARE_ANGLE_LIMIT = 0.1f;
return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle)));
}
const float initialHazeRange_m{ 1000.0f };
const float initialHazeHeight_m{ 200.0f };
const float initialHazeKeyLightRange_m{ 1000.0f };
const float initialHazeKeyLightAltitude_m{ 200.0f };
const float initialHazeBackgroundBlend{ 0.0f };
const glm::vec3 initialColorModulationFactor{
convertHazeRangeToHazeRangeFactor(initialHazeRange_m),
convertHazeRangeToHazeRangeFactor(initialHazeRange_m),
convertHazeRangeToHazeRangeFactor(initialHazeRange_m)
};
const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish
const xColor initialHazeColorXcolor{ 128, 154, 179 };
const float initialGlareAngle_degs{ 20.0f };
const glm::vec3 initialHazeGlareColor{ 1.0f, 0.9f, 0.7f };
const xColor initialHazeGlareColorXcolor{ 255, 229, 179 };
const float initialHazeBaseReference_m{ 0.0f };
}
#endif // hifi_model_HazeInit_h

View file

@ -56,15 +56,15 @@ class MakeHazeConfig : public render::Job::Config {
public:
MakeHazeConfig() : render::Job::Config() {}
float hazeColorR{ model::initialHazeColor.r };
float hazeColorG{ model::initialHazeColor.g };
float hazeColorB{ model::initialHazeColor.b };
float hazeGlareAngle_degs{ model::initialGlareAngle_degs };
float hazeColorR{ model::Haze::initialHazeColor.r };
float hazeColorG{ model::Haze::initialHazeColor.g };
float hazeColorB{ model::Haze::initialHazeColor.b };
float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs };
float hazeGlareColorR{ model::initialHazeGlareColor.r };
float hazeGlareColorG{ model::initialHazeGlareColor.g };
float hazeGlareColorB{ model::initialHazeGlareColor.b };
float hazeBaseReference_m{ model::initialHazeBaseReference_m };
float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r };
float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g };
float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b };
float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m };
bool isHazeActive{ false };
bool isAltitudeBased{ false };
@ -72,13 +72,13 @@ public:
bool isModulateColorActive{ false };
bool isHazeEnableGlare{ false };
float hazeRange_m{ model::initialHazeRange_m };
float hazeHeight_m{ model::initialHazeHeight_m };
float hazeRange_m{ model::Haze::initialHazeRange_m };
float hazeHeight_m{ model::Haze::initialHazeHeight_m };
float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m };
float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m };
float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m };
float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m };
float hazeBackgroundBlend{ model::initialHazeBackgroundBlend };
float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend };
public slots:
void setHazeColorR(const float value) { hazeColorR = value; emit dirty(); }
@ -128,15 +128,15 @@ public:
HazeConfig() : render::Job::Config(true) {}
// attributes
float hazeColorR{ model::initialHazeColor.r };
float hazeColorG{ model::initialHazeColor.g };
float hazeColorB{ model::initialHazeColor.b };
float hazeGlareAngle_degs{ model::initialGlareAngle_degs };
float hazeColorR{ model::Haze::initialHazeColor.r };
float hazeColorG{ model::Haze::initialHazeColor.g };
float hazeColorB{ model::Haze::initialHazeColor.b };
float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs };
float hazeGlareColorR{ model::initialHazeGlareColor.r };
float hazeGlareColorG{ model::initialHazeGlareColor.g };
float hazeGlareColorB{ model::initialHazeGlareColor.b };
float hazeBaseReference_m{ model::initialHazeBaseReference_m };
float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r };
float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g };
float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b };
float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m };
bool isHazeActive{ false }; // Setting this to true will set haze to on
bool isAltitudeBased{ false };
@ -144,13 +144,13 @@ public:
bool isModulateColorActive{ false };
bool isHazeEnableGlare{ false };
float hazeRange_m{ model::initialHazeRange_m };
float hazeHeight_m{ model::initialHazeHeight_m };
float hazeRange_m{ model::Haze::initialHazeRange_m };
float hazeHeight_m{ model::Haze::initialHazeHeight_m };
float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m };
float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m };
float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m };
float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m };
float hazeBackgroundBlend{ model::initialHazeBackgroundBlend };
float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend };
// methods
void setHazeColorR(const float value);

View file

@ -110,15 +110,15 @@ class FetchHazeConfig : public render::Job::Config {
public:
FetchHazeConfig() : render::Job::Config() {}
float hazeColorR{ model::initialHazeColor.r };
float hazeColorG{ model::initialHazeColor.g };
float hazeColorB{ model::initialHazeColor.b };
float hazeGlareAngle_degs{ model::initialGlareAngle_degs };
float hazeColorR{ model::Haze::initialHazeColor.r };
float hazeColorG{ model::Haze::initialHazeColor.g };
float hazeColorB{ model::Haze::initialHazeColor.b };
float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs };
float hazeGlareColorR{ model::initialHazeGlareColor.r };
float hazeGlareColorG{ model::initialHazeGlareColor.g };
float hazeGlareColorB{ model::initialHazeGlareColor.b };
float hazeBaseReference_m{ model::initialHazeBaseReference_m };
float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r };
float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g };
float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b };
float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m };
bool isHazeActive{ false };
bool isAltitudeBased{ false };
@ -126,13 +126,13 @@ public:
bool isModulateColorActive{ false };
bool isHazeEnableGlare{ false };
float hazeRange_m{ model::initialHazeRange_m };
float hazeHeight_m{ model::initialHazeHeight_m };
float hazeRange_m{ model::Haze::initialHazeRange_m };
float hazeHeight_m{ model::Haze::initialHazeHeight_m };
float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m };
float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m };
float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m };
float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m };
float hazeBackgroundBlend{ model::initialHazeBackgroundBlend };
float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend };
public slots:
void setHazeColorR(const float value) { hazeColorR = value; emit dirty(); }