mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-08-08 06:06:49 +02:00
Merge remote-tracking branch 'upstream/master' into android
This commit is contained in:
commit
6a06bf405a
188 changed files with 1194 additions and 777 deletions
|
@ -11,7 +11,7 @@ setup_memory_debugger()
|
||||||
|
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(
|
link_hifi_libraries(
|
||||||
audio avatars octree gpu model fbx entities
|
audio avatars octree gpu graphics fbx entities
|
||||||
networking animation recording shared script-engine embedded-webserver
|
networking animation recording shared script-engine embedded-webserver
|
||||||
controllers physics plugins midi image
|
controllers physics plugins midi image
|
||||||
)
|
)
|
||||||
|
|
|
@ -116,8 +116,9 @@ public:
|
||||||
void setLastOtherAvatarEncodeTime(const QUuid& otherAvatar, const uint64_t& time);
|
void setLastOtherAvatarEncodeTime(const QUuid& otherAvatar, const uint64_t& time);
|
||||||
|
|
||||||
QVector<JointData>& getLastOtherAvatarSentJoints(QUuid otherAvatar) {
|
QVector<JointData>& getLastOtherAvatarSentJoints(QUuid otherAvatar) {
|
||||||
_lastOtherAvatarSentJoints[otherAvatar].resize(_avatar->getJointCount());
|
auto& lastOtherAvatarSentJoints = _lastOtherAvatarSentJoints[otherAvatar];
|
||||||
return _lastOtherAvatarSentJoints[otherAvatar];
|
lastOtherAvatarSentJoints.resize(_avatar->getJointCount());
|
||||||
|
return lastOtherAvatarSentJoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
void queuePacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer node);
|
void queuePacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer node);
|
||||||
|
|
|
@ -191,7 +191,7 @@ endif()
|
||||||
|
|
||||||
# link required hifi libraries
|
# link required hifi libraries
|
||||||
link_hifi_libraries(
|
link_hifi_libraries(
|
||||||
shared octree ktx gpu gl procedural model render
|
shared octree ktx gpu gl procedural graphics render
|
||||||
pointers
|
pointers
|
||||||
recording fbx networking model-networking entities avatars trackers
|
recording fbx networking model-networking entities avatars trackers
|
||||||
audio audio-client animation script-engine physics
|
audio audio-client animation script-engine physics
|
||||||
|
|
Binary file not shown.
|
@ -50,7 +50,7 @@ Item {
|
||||||
id: avatarImage
|
id: avatarImage
|
||||||
visible: profileUrl !== "" && userName !== "";
|
visible: profileUrl !== "" && userName !== "";
|
||||||
// Size
|
// Size
|
||||||
height: isMyCard ? 70 : 42;
|
height: isMyCard ? 84 : 42;
|
||||||
width: visible ? height : 0;
|
width: visible ? height : 0;
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top;
|
||||||
anchors.topMargin: isMyCard ? 0 : 8;
|
anchors.topMargin: isMyCard ? 0 : 8;
|
||||||
|
@ -520,7 +520,7 @@ Item {
|
||||||
Slider {
|
Slider {
|
||||||
id: gainSlider
|
id: gainSlider
|
||||||
// Size
|
// Size
|
||||||
width: thisNameCard.width;
|
width: isMyCard ? thisNameCard.width - 20 : thisNameCard.width;
|
||||||
height: 14
|
height: 14
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.verticalCenter: nameCardVUMeter.verticalCenter;
|
anchors.verticalCenter: nameCardVUMeter.verticalCenter;
|
||||||
|
|
|
@ -28,7 +28,7 @@ Rectangle {
|
||||||
// Properties
|
// Properties
|
||||||
property bool debug: false;
|
property bool debug: false;
|
||||||
property int myCardWidth: width - upperRightInfoContainer.width;
|
property int myCardWidth: width - upperRightInfoContainer.width;
|
||||||
property int myCardHeight: 80;
|
property int myCardHeight: 100;
|
||||||
property int rowHeight: 60;
|
property int rowHeight: 60;
|
||||||
property int actionButtonWidth: 55;
|
property int actionButtonWidth: 55;
|
||||||
property int locationColumnWidth: 170;
|
property int locationColumnWidth: 170;
|
||||||
|
|
|
@ -22,7 +22,6 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
id: d
|
id: d
|
||||||
objectName: "stack"
|
objectName: "stack"
|
||||||
initialItem: topMenu
|
|
||||||
|
|
||||||
property var menuStack: []
|
property var menuStack: []
|
||||||
property var topMenu: null;
|
property var topMenu: null;
|
||||||
|
|
|
@ -5534,7 +5534,7 @@ void Application::clearDomainOctreeDetails() {
|
||||||
|
|
||||||
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
||||||
|
|
||||||
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT);
|
skyStage->setBackgroundMode(graphics::SunSkyStage::SKY_DEFAULT);
|
||||||
|
|
||||||
DependencyManager::get<AnimationCache>()->clearUnusedResources();
|
DependencyManager::get<AnimationCache>()->clearUnusedResources();
|
||||||
DependencyManager::get<ModelCache>()->clearUnusedResources();
|
DependencyManager::get<ModelCache>()->clearUnusedResources();
|
||||||
|
@ -6249,7 +6249,7 @@ void Application::showAssetServerWidget(QString filePath) {
|
||||||
if (!hmd->getShouldShowTablet() && !isHMDMode()) {
|
if (!hmd->getShouldShowTablet() && !isHMDMode()) {
|
||||||
DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
|
DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
|
||||||
} else {
|
} else {
|
||||||
static const QUrl url("hifi/dialogs/TabletAssetServer.qml");
|
static const QUrl url("../dialogs/TabletAssetServer.qml");
|
||||||
tablet->pushOntoStack(url);
|
tablet->pushOntoStack(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7469,11 +7469,13 @@ void Application::updateThreadPoolCount() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateSystemTabletMode() {
|
void Application::updateSystemTabletMode() {
|
||||||
qApp->setProperty(hifi::properties::HMD, isHMDMode());
|
if (_settingsLoaded) {
|
||||||
if (isHMDMode()) {
|
qApp->setProperty(hifi::properties::HMD, isHMDMode());
|
||||||
DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getHmdTabletBecomesToolbarSetting());
|
if (isHMDMode()) {
|
||||||
} else {
|
DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getHmdTabletBecomesToolbarSetting());
|
||||||
DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getDesktopTabletBecomesToolbarSetting());
|
} else {
|
||||||
|
DependencyManager::get<TabletScriptingInterface>()->setToolbarMode(getDesktopTabletBecomesToolbarSetting());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
#include "UndoStackScriptingInterface.h"
|
#include "UndoStackScriptingInterface.h"
|
||||||
|
|
||||||
#include <procedural/ProceduralSkybox.h>
|
#include <procedural/ProceduralSkybox.h>
|
||||||
#include <model/Skybox.h>
|
#include <graphics/Skybox.h>
|
||||||
#include <ModelScriptingInterface.h>
|
#include <ModelScriptingInterface.h>
|
||||||
#include "FrameTimingsScriptingInterface.h"
|
#include "FrameTimingsScriptingInterface.h"
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ public:
|
||||||
void takeSecondaryCameraSnapshot();
|
void takeSecondaryCameraSnapshot();
|
||||||
void shareSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
void shareSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
||||||
|
|
||||||
model::SkyboxPointer getDefaultSkybox() const { return _defaultSkybox; }
|
graphics::SkyboxPointer getDefaultSkybox() const { return _defaultSkybox; }
|
||||||
gpu::TexturePointer getDefaultSkyboxTexture() const { return _defaultSkyboxTexture; }
|
gpu::TexturePointer getDefaultSkyboxTexture() const { return _defaultSkyboxTexture; }
|
||||||
gpu::TexturePointer getDefaultSkyboxAmbientTexture() const { return _defaultSkyboxAmbientTexture; }
|
gpu::TexturePointer getDefaultSkyboxAmbientTexture() const { return _defaultSkyboxAmbientTexture; }
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ private:
|
||||||
|
|
||||||
ConnectionMonitor _connectionMonitor;
|
ConnectionMonitor _connectionMonitor;
|
||||||
|
|
||||||
model::SkyboxPointer _defaultSkybox { new ProceduralSkybox() } ;
|
graphics::SkyboxPointer _defaultSkybox { new ProceduralSkybox() } ;
|
||||||
gpu::TexturePointer _defaultSkyboxTexture;
|
gpu::TexturePointer _defaultSkyboxTexture;
|
||||||
gpu::TexturePointer _defaultSkyboxAmbientTexture;
|
gpu::TexturePointer _defaultSkyboxAmbientTexture;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptR
|
||||||
* @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other
|
* @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other
|
||||||
* chrome), in pixels. <em>Read-only.</em>
|
* chrome), in pixels. <em>Read-only.</em>
|
||||||
* @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other
|
* @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other
|
||||||
* chrome) plus the height of the menu bar, in pixels. <em>Read-only.</em>
|
* chrome), in pixels. <em>Read-only.</em>
|
||||||
* @property {object} location - Provides facilities for working with your current metaverse location. See {@link location}.
|
* @property {object} location - Provides facilities for working with your current metaverse location. See {@link location}.
|
||||||
* @property {number} x - The x coordinate of the top left corner of the Interface window on the display. <em>Read-only.</em>
|
* @property {number} x - The x coordinate of the top left corner of the Interface window on the display. <em>Read-only.</em>
|
||||||
* @property {number} y - The y coordinate of the top left corner of the Interface window on the display. <em>Read-only.</em>
|
* @property {number} y - The y coordinate of the top left corner of the Interface window on the display. <em>Read-only.</em>
|
||||||
|
@ -301,7 +301,7 @@ public slots:
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Get Interface's build number.
|
* Get Interface's build number.
|
||||||
* @function Window.checkVersion
|
* @function Window.checkVersion
|
||||||
* @returns {string} - Interface's build number.
|
* @returns {string} Interface's build number.
|
||||||
*/
|
*/
|
||||||
QString checkVersion();
|
QString checkVersion();
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ public slots:
|
||||||
* full resolution is used (window dimensions in desktop mode; HMD display dimensions in HMD mode), otherwise one of the
|
* full resolution is used (window dimensions in desktop mode; HMD display dimensions in HMD mode), otherwise one of the
|
||||||
* dimensions is adjusted in order to match the aspect ratio.
|
* dimensions is adjusted in order to match the aspect ratio.
|
||||||
* @example <caption>Using the snapshot function and signals.</caption>
|
* @example <caption>Using the snapshot function and signals.</caption>
|
||||||
* function onStillSnapshottaken(path, notify) {
|
* function onStillSnapshotTaken(path, notify) {
|
||||||
* print("Still snapshot taken: " + path);
|
* print("Still snapshot taken: " + path);
|
||||||
* print("Notify: " + notify);
|
* print("Notify: " + notify);
|
||||||
* }
|
* }
|
||||||
|
@ -340,7 +340,7 @@ public slots:
|
||||||
* print("Animated snapshot taken: " + animatedPath);
|
* print("Animated snapshot taken: " + animatedPath);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Window.stillSnapshotTaken.connect(onStillSnapshottaken);
|
* Window.stillSnapshotTaken.connect(onStillSnapshotTaken);
|
||||||
* Window.processingGifStarted.connect(onProcessingGifStarted);
|
* Window.processingGifStarted.connect(onProcessingGifStarted);
|
||||||
* Window.processingGifCompleted.connect(onProcessingGifCompleted);
|
* Window.processingGifCompleted.connect(onProcessingGifCompleted);
|
||||||
*
|
*
|
||||||
|
@ -555,7 +555,7 @@ signals:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when a still snapshot has been taken by calling {@link Window.takeSnapshot|takeSnapshot} with
|
* Triggered when a still snapshot has been taken by calling {@link Window.takeSnapshot|takeSnapshot} with
|
||||||
* <code>includeAnimated = false</code>.
|
* <code>includeAnimated = false</code> or {@link Window.takeSecondaryCameraSnapshot|takeSecondaryCameraSnapshot}.
|
||||||
* @function Window.stillSnapshotTaken
|
* @function Window.stillSnapshotTaken
|
||||||
* @param {string} pathStillSnapshot - The path and name of the snapshot image file.
|
* @param {string} pathStillSnapshot - The path and name of the snapshot image file.
|
||||||
* @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSnapshot|takeSnapshot}
|
* @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSnapshot|takeSnapshot}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
set(TARGET_NAME animation)
|
set(TARGET_NAME animation)
|
||||||
setup_hifi_library(Network Script)
|
setup_hifi_library(Network Script)
|
||||||
link_hifi_libraries(shared model fbx)
|
link_hifi_libraries(shared graphics fbx)
|
||||||
include_hifi_library_headers(networking)
|
include_hifi_library_headers(networking)
|
||||||
include_hifi_library_headers(gpu)
|
include_hifi_library_headers(gpu)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
set(TARGET_NAME avatars-renderer)
|
set(TARGET_NAME avatars-renderer)
|
||||||
AUTOSCRIBE_SHADER_LIB(gpu model render render-utils)
|
AUTOSCRIBE_SHADER_LIB(gpu graphics render render-utils)
|
||||||
setup_hifi_library(Widgets Network Script)
|
setup_hifi_library(Widgets Network Script)
|
||||||
link_hifi_libraries(shared gpu model animation model-networking script-engine render render-utils image trackers entities-renderer)
|
link_hifi_libraries(shared gpu graphics animation model-networking script-engine render render-utils image trackers entities-renderer)
|
||||||
include_hifi_library_headers(avatars)
|
include_hifi_library_headers(avatars)
|
||||||
include_hifi_library_headers(networking)
|
include_hifi_library_headers(networking)
|
||||||
include_hifi_library_headers(fbx)
|
include_hifi_library_headers(fbx)
|
||||||
|
|
|
@ -530,9 +530,13 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
|
|
||||||
destinationBuffer += numValidityBytes; // Move pointer past the validity bytes
|
destinationBuffer += numValidityBytes; // Move pointer past the validity bytes
|
||||||
|
|
||||||
|
// sentJointDataOut and lastSentJointData might be the same vector
|
||||||
|
// build sentJointDataOut locally and then swap it at the end.
|
||||||
|
QVector<JointData> localSentJointDataOut;
|
||||||
if (sentJointDataOut) {
|
if (sentJointDataOut) {
|
||||||
sentJointDataOut->resize(_jointData.size()); // Make sure the destination is resized before using it
|
localSentJointDataOut.resize(numJoints); // Make sure the destination is resized before using it
|
||||||
}
|
}
|
||||||
|
|
||||||
float minRotationDOT = !distanceAdjust ? AVATAR_MIN_ROTATION_DOT : getDistanceBasedMinRotationDOT(viewerPosition);
|
float minRotationDOT = !distanceAdjust ? AVATAR_MIN_ROTATION_DOT : getDistanceBasedMinRotationDOT(viewerPosition);
|
||||||
|
|
||||||
for (int i = 0; i < _jointData.size(); i++) {
|
for (int i = 0; i < _jointData.size(); i++) {
|
||||||
|
@ -552,8 +556,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
destinationBuffer += packOrientationQuatToSixBytes(destinationBuffer, data.rotation);
|
destinationBuffer += packOrientationQuatToSixBytes(destinationBuffer, data.rotation);
|
||||||
|
|
||||||
if (sentJointDataOut) {
|
if (sentJointDataOut) {
|
||||||
auto jointDataOut = *sentJointDataOut;
|
localSentJointDataOut[i].rotation = data.rotation;
|
||||||
jointDataOut[i].rotation = data.rotation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -602,8 +605,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
packFloatVec3ToSignedTwoByteFixed(destinationBuffer, data.translation, TRANSLATION_COMPRESSION_RADIX);
|
packFloatVec3ToSignedTwoByteFixed(destinationBuffer, data.translation, TRANSLATION_COMPRESSION_RADIX);
|
||||||
|
|
||||||
if (sentJointDataOut) {
|
if (sentJointDataOut) {
|
||||||
auto jointDataOut = *sentJointDataOut;
|
localSentJointDataOut[i].translation = data.translation;
|
||||||
jointDataOut[i].translation = data.translation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -646,6 +648,11 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
if (outboundDataRateOut) {
|
if (outboundDataRateOut) {
|
||||||
outboundDataRateOut->jointDataRate.increment(numBytes);
|
outboundDataRateOut->jointDataRate.increment(numBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sentJointDataOut) {
|
||||||
|
// Push new sent joint data to sentJointDataOut
|
||||||
|
sentJointDataOut->swap(localSentJointDataOut);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int avatarDataSize = destinationBuffer - startPosition;
|
int avatarDataSize = destinationBuffer - startPosition;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
set(TARGET_NAME baking)
|
set(TARGET_NAME baking)
|
||||||
setup_hifi_library(Concurrent)
|
setup_hifi_library(Concurrent)
|
||||||
|
|
||||||
link_hifi_libraries(shared model networking ktx image fbx)
|
link_hifi_libraries(shared graphics networking ktx image fbx)
|
||||||
include_hifi_library_headers(gpu)
|
include_hifi_library_headers(gpu)
|
||||||
|
|
||||||
add_dependency_external_projects(draco)
|
add_dependency_external_projects(draco)
|
||||||
|
|
|
@ -5,7 +5,7 @@ link_hifi_libraries(shared plugins ui-plugins gl ui render-utils ${PLATFORM_GL_B
|
||||||
include_hifi_library_headers(gpu)
|
include_hifi_library_headers(gpu)
|
||||||
include_hifi_library_headers(model-networking)
|
include_hifi_library_headers(model-networking)
|
||||||
include_hifi_library_headers(networking)
|
include_hifi_library_headers(networking)
|
||||||
include_hifi_library_headers(model)
|
include_hifi_library_headers(graphics)
|
||||||
include_hifi_library_headers(fbx)
|
include_hifi_library_headers(fbx)
|
||||||
include_hifi_library_headers(image)
|
include_hifi_library_headers(image)
|
||||||
include_hifi_library_headers(ktx)
|
include_hifi_library_headers(ktx)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
set(TARGET_NAME entities-renderer)
|
set(TARGET_NAME entities-renderer)
|
||||||
AUTOSCRIBE_SHADER_LIB(gpu model procedural render render-utils)
|
AUTOSCRIBE_SHADER_LIB(gpu graphics procedural render render-utils)
|
||||||
setup_hifi_library(Widgets Network Script)
|
setup_hifi_library(Widgets Network Script)
|
||||||
link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils image ui pointers)
|
link_hifi_libraries(shared gpu procedural graphics model-networking script-engine render render-utils image ui pointers)
|
||||||
include_hifi_library_headers(networking)
|
include_hifi_library_headers(networking)
|
||||||
include_hifi_library_headers(gl)
|
include_hifi_library_headers(gl)
|
||||||
include_hifi_library_headers(ktx)
|
include_hifi_library_headers(ktx)
|
||||||
|
|
|
@ -52,9 +52,9 @@ void LightEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
|
||||||
float exponent = entity->getExponent();
|
float exponent = entity->getExponent();
|
||||||
float cutoff = glm::radians(entity->getCutoff());
|
float cutoff = glm::radians(entity->getCutoff());
|
||||||
if (!entity->getIsSpotlight()) {
|
if (!entity->getIsSpotlight()) {
|
||||||
light->setType(model::Light::POINT);
|
light->setType(graphics::Light::POINT);
|
||||||
} else {
|
} else {
|
||||||
light->setType(model::Light::SPOT);
|
light->setType(graphics::Light::SPOT);
|
||||||
|
|
||||||
light->setSpotAngle(cutoff);
|
light->setSpotAngle(cutoff);
|
||||||
light->setSpotExponent(exponent);
|
light->setSpotExponent(exponent);
|
||||||
|
|
|
@ -558,10 +558,10 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
if (type == SHAPE_TYPE_STATIC_MESH) {
|
if (type == SHAPE_TYPE_STATIC_MESH) {
|
||||||
// copy into triangleIndices
|
// copy into triangleIndices
|
||||||
triangleIndices.reserve((int32_t)((gpu::Size)(triangleIndices.size()) + indices.getNumElements()));
|
triangleIndices.reserve((int32_t)((gpu::Size)(triangleIndices.size()) + indices.getNumElements()));
|
||||||
gpu::BufferView::Iterator<const model::Mesh::Part> partItr = parts.cbegin<const model::Mesh::Part>();
|
gpu::BufferView::Iterator<const graphics::Mesh::Part> partItr = parts.cbegin<const graphics::Mesh::Part>();
|
||||||
while (partItr != parts.cend<const model::Mesh::Part>()) {
|
while (partItr != parts.cend<const graphics::Mesh::Part>()) {
|
||||||
auto numIndices = partItr->_numIndices;
|
auto numIndices = partItr->_numIndices;
|
||||||
if (partItr->_topology == model::Mesh::TRIANGLES) {
|
if (partItr->_topology == graphics::Mesh::TRIANGLES) {
|
||||||
// TODO: assert rather than workaround after we start sanitizing FBXMesh higher up
|
// TODO: assert rather than workaround after we start sanitizing FBXMesh higher up
|
||||||
//assert(numIndices % TRIANGLE_STRIDE == 0);
|
//assert(numIndices % TRIANGLE_STRIDE == 0);
|
||||||
numIndices -= numIndices % TRIANGLE_STRIDE; // WORKAROUND lack of sanity checking in FBXReader
|
numIndices -= numIndices % TRIANGLE_STRIDE; // WORKAROUND lack of sanity checking in FBXReader
|
||||||
|
@ -572,7 +572,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
triangleIndices.push_back(*indexItr + meshIndexOffset);
|
triangleIndices.push_back(*indexItr + meshIndexOffset);
|
||||||
++indexItr;
|
++indexItr;
|
||||||
}
|
}
|
||||||
} else if (partItr->_topology == model::Mesh::TRIANGLE_STRIP) {
|
} else if (partItr->_topology == graphics::Mesh::TRIANGLE_STRIP) {
|
||||||
// TODO: resurrect assert after we start sanitizing FBXMesh higher up
|
// TODO: resurrect assert after we start sanitizing FBXMesh higher up
|
||||||
//assert(numIndices > 2);
|
//assert(numIndices > 2);
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
// the rest use previous and next index
|
// the rest use previous and next index
|
||||||
uint32_t triangleCount = 1;
|
uint32_t triangleCount = 1;
|
||||||
while (indexItr != indexEnd) {
|
while (indexItr != indexEnd) {
|
||||||
if ((*indexItr) != model::Mesh::PRIMITIVE_RESTART_INDEX) {
|
if ((*indexItr) != graphics::Mesh::PRIMITIVE_RESTART_INDEX) {
|
||||||
if (triangleCount % 2 == 0) {
|
if (triangleCount % 2 == 0) {
|
||||||
// even triangles use first two indices in order
|
// even triangles use first two indices in order
|
||||||
triangleIndices.push_back(*(indexItr - 2) + meshIndexOffset);
|
triangleIndices.push_back(*(indexItr - 2) + meshIndexOffset);
|
||||||
|
@ -613,12 +613,12 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
}
|
}
|
||||||
} else if (type == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
} else if (type == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
// for each mesh copy unique part indices, separated by special bogus (flag) index values
|
// for each mesh copy unique part indices, separated by special bogus (flag) index values
|
||||||
gpu::BufferView::Iterator<const model::Mesh::Part> partItr = parts.cbegin<const model::Mesh::Part>();
|
gpu::BufferView::Iterator<const graphics::Mesh::Part> partItr = parts.cbegin<const graphics::Mesh::Part>();
|
||||||
while (partItr != parts.cend<const model::Mesh::Part>()) {
|
while (partItr != parts.cend<const graphics::Mesh::Part>()) {
|
||||||
// collect unique list of indices for this part
|
// collect unique list of indices for this part
|
||||||
std::set<int32_t> uniqueIndices;
|
std::set<int32_t> uniqueIndices;
|
||||||
auto numIndices = partItr->_numIndices;
|
auto numIndices = partItr->_numIndices;
|
||||||
if (partItr->_topology == model::Mesh::TRIANGLES) {
|
if (partItr->_topology == graphics::Mesh::TRIANGLES) {
|
||||||
// TODO: assert rather than workaround after we start sanitizing FBXMesh higher up
|
// TODO: assert rather than workaround after we start sanitizing FBXMesh higher up
|
||||||
//assert(numIndices% TRIANGLE_STRIDE == 0);
|
//assert(numIndices% TRIANGLE_STRIDE == 0);
|
||||||
numIndices -= numIndices % TRIANGLE_STRIDE; // WORKAROUND lack of sanity checking in FBXReader
|
numIndices -= numIndices % TRIANGLE_STRIDE; // WORKAROUND lack of sanity checking in FBXReader
|
||||||
|
@ -629,7 +629,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
uniqueIndices.insert(*indexItr);
|
uniqueIndices.insert(*indexItr);
|
||||||
++indexItr;
|
++indexItr;
|
||||||
}
|
}
|
||||||
} else if (partItr->_topology == model::Mesh::TRIANGLE_STRIP) {
|
} else if (partItr->_topology == graphics::Mesh::TRIANGLE_STRIP) {
|
||||||
// TODO: resurrect assert after we start sanitizing FBXMesh higher up
|
// TODO: resurrect assert after we start sanitizing FBXMesh higher up
|
||||||
//assert(numIndices > TRIANGLE_STRIDE - 1);
|
//assert(numIndices > TRIANGLE_STRIDE - 1);
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
// the rest use previous and next index
|
// the rest use previous and next index
|
||||||
uint32_t triangleCount = 1;
|
uint32_t triangleCount = 1;
|
||||||
while (indexItr != indexEnd) {
|
while (indexItr != indexEnd) {
|
||||||
if ((*indexItr) != model::Mesh::PRIMITIVE_RESTART_INDEX) {
|
if ((*indexItr) != graphics::Mesh::PRIMITIVE_RESTART_INDEX) {
|
||||||
if (triangleCount % 2 == 0) {
|
if (triangleCount % 2 == 0) {
|
||||||
// EVEN triangles use first two indices in order
|
// EVEN triangles use first two indices in order
|
||||||
uniqueIndices.insert(*(indexItr - 2));
|
uniqueIndices.insert(*(indexItr - 2));
|
||||||
|
@ -1295,7 +1295,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
ShapeType type = entity->getShapeType();
|
ShapeType type = entity->getShapeType();
|
||||||
if (DependencyManager::get<EntityTreeRenderer>()->shouldRenderDebugHulls() && type != SHAPE_TYPE_STATIC_MESH && type != SHAPE_TYPE_NONE) {
|
if (DependencyManager::get<EntityTreeRenderer>()->shouldRenderDebugHulls() && type != SHAPE_TYPE_STATIC_MESH && type != SHAPE_TYPE_NONE) {
|
||||||
// NOTE: it is OK if _collisionMeshKey is nullptr
|
// NOTE: it is OK if _collisionMeshKey is nullptr
|
||||||
model::MeshPointer mesh = collisionMeshCache.getMesh(_collisionMeshKey);
|
graphics::MeshPointer mesh = collisionMeshCache.getMesh(_collisionMeshKey);
|
||||||
// NOTE: the model will render the collisionGeometry if it has one
|
// NOTE: the model will render the collisionGeometry if it has one
|
||||||
_model->setCollisionMesh(mesh);
|
_model->setCollisionMesh(mesh);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1304,7 +1304,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
collisionMeshCache.releaseMesh(_collisionMeshKey);
|
collisionMeshCache.releaseMesh(_collisionMeshKey);
|
||||||
}
|
}
|
||||||
// clear model's collision geometry
|
// clear model's collision geometry
|
||||||
model::MeshPointer mesh = nullptr;
|
graphics::MeshPointer mesh = nullptr;
|
||||||
_model->setCollisionMesh(mesh);
|
_model->setCollisionMesh(mesh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "model/Geometry.h"
|
#include "graphics/Geometry.h"
|
||||||
|
|
||||||
#include "StencilMaskPass.h"
|
#include "StencilMaskPass.h"
|
||||||
|
|
||||||
|
@ -1060,7 +1060,7 @@ void RenderablePolyVoxEntityItem::recomputeMesh() {
|
||||||
auto entity = std::static_pointer_cast<RenderablePolyVoxEntityItem>(getThisPointer());
|
auto entity = std::static_pointer_cast<RenderablePolyVoxEntityItem>(getThisPointer());
|
||||||
|
|
||||||
QtConcurrent::run([entity, voxelSurfaceStyle] {
|
QtConcurrent::run([entity, voxelSurfaceStyle] {
|
||||||
model::MeshPointer mesh(new model::Mesh());
|
graphics::MeshPointer mesh(new graphics::Mesh());
|
||||||
|
|
||||||
// A mesh object to hold the result of surface extraction
|
// A mesh object to hold the result of surface extraction
|
||||||
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> polyVoxMesh;
|
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> polyVoxMesh;
|
||||||
|
@ -1122,18 +1122,18 @@ void RenderablePolyVoxEntityItem::recomputeMesh() {
|
||||||
sizeof(PolyVox::PositionMaterialNormal),
|
sizeof(PolyVox::PositionMaterialNormal),
|
||||||
gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)));
|
gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)));
|
||||||
|
|
||||||
std::vector<model::Mesh::Part> parts;
|
std::vector<graphics::Mesh::Part> parts;
|
||||||
parts.emplace_back(model::Mesh::Part((model::Index)0, // startIndex
|
parts.emplace_back(graphics::Mesh::Part((graphics::Index)0, // startIndex
|
||||||
(model::Index)vecIndices.size(), // numIndices
|
(graphics::Index)vecIndices.size(), // numIndices
|
||||||
(model::Index)0, // baseVertex
|
(graphics::Index)0, // baseVertex
|
||||||
model::Mesh::TRIANGLES)); // topology
|
graphics::Mesh::TRIANGLES)); // topology
|
||||||
mesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part),
|
mesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part),
|
||||||
(gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
(gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
||||||
entity->setMesh(mesh);
|
entity->setMesh(mesh);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderablePolyVoxEntityItem::setMesh(model::MeshPointer mesh) {
|
void RenderablePolyVoxEntityItem::setMesh(graphics::MeshPointer mesh) {
|
||||||
// this catches the payload from recomputeMesh
|
// this catches the payload from recomputeMesh
|
||||||
bool neighborsNeedUpdate;
|
bool neighborsNeedUpdate;
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
|
@ -1164,7 +1164,7 @@ void RenderablePolyVoxEntityItem::computeShapeInfoWorker() {
|
||||||
|
|
||||||
PolyVoxSurfaceStyle voxelSurfaceStyle;
|
PolyVoxSurfaceStyle voxelSurfaceStyle;
|
||||||
glm::vec3 voxelVolumeSize;
|
glm::vec3 voxelVolumeSize;
|
||||||
model::MeshPointer mesh;
|
graphics::MeshPointer mesh;
|
||||||
|
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
voxelSurfaceStyle = _voxelSurfaceStyle;
|
voxelSurfaceStyle = _voxelSurfaceStyle;
|
||||||
|
@ -1585,7 +1585,7 @@ void PolyVoxEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& s
|
||||||
|
|
||||||
void PolyVoxEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
void PolyVoxEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||||
_lastVoxelToWorldMatrix = entity->voxelToWorldMatrix();
|
_lastVoxelToWorldMatrix = entity->voxelToWorldMatrix();
|
||||||
model::MeshPointer newMesh;
|
graphics::MeshPointer newMesh;
|
||||||
entity->withReadLock([&] {
|
entity->withReadLock([&] {
|
||||||
newMesh = entity->_mesh;
|
newMesh = entity->_mesh;
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
#include <gpu/Forward.h>
|
#include <gpu/Forward.h>
|
||||||
#include <gpu/Context.h>
|
#include <gpu/Context.h>
|
||||||
#include <model/Forward.h>
|
#include <graphics/Forward.h>
|
||||||
#include <model/Geometry.h>
|
#include <graphics/Geometry.h>
|
||||||
#include <TextureCache.h>
|
#include <TextureCache.h>
|
||||||
#include <PolyVoxEntityItem.h>
|
#include <PolyVoxEntityItem.h>
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public:
|
||||||
void forEachVoxelValue(const ivec3& voxelSize, std::function<void(const ivec3&, uint8_t)> thunk);
|
void forEachVoxelValue(const ivec3& voxelSize, std::function<void(const ivec3&, uint8_t)> thunk);
|
||||||
QByteArray volDataToArray(quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize) const;
|
QByteArray volDataToArray(quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize) const;
|
||||||
|
|
||||||
void setMesh(model::MeshPointer mesh);
|
void setMesh(graphics::MeshPointer mesh);
|
||||||
void setCollisionPoints(ShapeInfo::PointCollection points, AABox box);
|
void setCollisionPoints(ShapeInfo::PointCollection points, AABox box);
|
||||||
PolyVox::SimpleVolume<uint8_t>* getVolData() { return _volData.get(); }
|
PolyVox::SimpleVolume<uint8_t>* getVolData() { return _volData.get(); }
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ private:
|
||||||
// may not match _voxelVolumeSize.
|
// may not match _voxelVolumeSize.
|
||||||
bool _meshDirty { true }; // does collision-shape need to be recomputed?
|
bool _meshDirty { true }; // does collision-shape need to be recomputed?
|
||||||
bool _meshReady{ false };
|
bool _meshReady{ false };
|
||||||
model::MeshPointer _mesh;
|
graphics::MeshPointer _mesh;
|
||||||
|
|
||||||
ShapeInfo _shapeInfo;
|
ShapeInfo _shapeInfo;
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ private:
|
||||||
bool _hasTransitioned{ false };
|
bool _hasTransitioned{ false };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
model::MeshPointer _mesh;
|
graphics::MeshPointer _mesh;
|
||||||
std::array<NetworkTexturePointer, 3> _xyzTextures;
|
std::array<NetworkTexturePointer, 3> _xyzTextures;
|
||||||
glm::vec3 _lastVoxelVolumeSize;
|
glm::vec3 _lastVoxelVolumeSize;
|
||||||
glm::mat4 _lastVoxelToWorldMatrix;
|
glm::mat4 _lastVoxelToWorldMatrix;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
|
|
||||||
#include <model/Stage.h>
|
#include <graphics/Stage.h>
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
|
@ -162,28 +162,31 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_visible) {
|
if (_visible) {
|
||||||
// Finally, push the light visible in the frame
|
// Finally, push the lights visible in the frame
|
||||||
|
//
|
||||||
|
// If component is disabled then push component off state
|
||||||
|
// else if component is enabled then push current state
|
||||||
|
// (else mode is inherit, the value from the parent zone will be used
|
||||||
|
//
|
||||||
if (_keyLightMode == COMPONENT_MODE_DISABLED) {
|
if (_keyLightMode == COMPONENT_MODE_DISABLED) {
|
||||||
_stage->_currentFrame.pushSunLight(_stage->getSunOffLight());
|
_stage->_currentFrame.pushSunLight(_stage->getSunOffLight());
|
||||||
} else if (_keyLightMode == COMPONENT_MODE_ENABLED) {
|
} else if (_keyLightMode == COMPONENT_MODE_ENABLED) {
|
||||||
_stage->_currentFrame.pushSunLight(_sunIndex);
|
_stage->_currentFrame.pushSunLight(_sunIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The background only if the mode is not inherit
|
|
||||||
if (_skyboxMode == COMPONENT_MODE_DISABLED) {
|
if (_skyboxMode == COMPONENT_MODE_DISABLED) {
|
||||||
_backgroundStage->_currentFrame.pushBackground(INVALID_INDEX);
|
_backgroundStage->_currentFrame.pushBackground(INVALID_INDEX);
|
||||||
} else if (_skyboxMode == COMPONENT_MODE_ENABLED) {
|
} else if (_skyboxMode == COMPONENT_MODE_ENABLED) {
|
||||||
_backgroundStage->_currentFrame.pushBackground(_backgroundIndex);
|
_backgroundStage->_currentFrame.pushBackground(_backgroundIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The ambient light only if it has a valid texture to render with
|
|
||||||
if (_ambientLightMode == COMPONENT_MODE_DISABLED) {
|
if (_ambientLightMode == COMPONENT_MODE_DISABLED) {
|
||||||
_stage->_currentFrame.pushAmbientLight(_stage->getAmbientOffLight());
|
_stage->_currentFrame.pushAmbientLight(_stage->getAmbientOffLight());
|
||||||
} else if (_ambientLightMode == COMPONENT_MODE_ENABLED) {
|
} else if (_ambientLightMode == COMPONENT_MODE_ENABLED) {
|
||||||
_stage->_currentFrame.pushAmbientLight(_ambientIndex);
|
_stage->_currentFrame.pushAmbientLight(_ambientIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Haze only if the mode is not inherit
|
// Haze only if the mode is not inherit, as the model deals with on/off
|
||||||
if (_hazeMode != COMPONENT_MODE_INHERIT) {
|
if (_hazeMode != COMPONENT_MODE_INHERIT) {
|
||||||
_hazeStage->_currentFrame.pushHaze(_hazeIndex);
|
_hazeStage->_currentFrame.pushHaze(_hazeIndex);
|
||||||
}
|
}
|
||||||
|
@ -319,7 +322,7 @@ void ZoneEntityRenderer::updateKeySunFromEntity(const TypedEntityPointer& entity
|
||||||
setKeyLightMode((ComponentMode)entity->getKeyLightMode());
|
setKeyLightMode((ComponentMode)entity->getKeyLightMode());
|
||||||
|
|
||||||
const auto& sunLight = editSunLight();
|
const auto& sunLight = editSunLight();
|
||||||
sunLight->setType(model::Light::SUN);
|
sunLight->setType(graphics::Light::SUN);
|
||||||
sunLight->setPosition(_lastPosition);
|
sunLight->setPosition(_lastPosition);
|
||||||
sunLight->setOrientation(_lastRotation);
|
sunLight->setOrientation(_lastRotation);
|
||||||
|
|
||||||
|
@ -333,7 +336,7 @@ void ZoneEntityRenderer::updateAmbientLightFromEntity(const TypedEntityPointer&
|
||||||
setAmbientLightMode((ComponentMode)entity->getAmbientLightMode());
|
setAmbientLightMode((ComponentMode)entity->getAmbientLightMode());
|
||||||
|
|
||||||
const auto& ambientLight = editAmbientLight();
|
const auto& ambientLight = editAmbientLight();
|
||||||
ambientLight->setType(model::Light::AMBIENT);
|
ambientLight->setType(graphics::Light::AMBIENT);
|
||||||
ambientLight->setPosition(_lastPosition);
|
ambientLight->setPosition(_lastPosition);
|
||||||
ambientLight->setOrientation(_lastRotation);
|
ambientLight->setOrientation(_lastRotation);
|
||||||
|
|
||||||
|
@ -357,23 +360,23 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity)
|
||||||
haze->setHazeActive(hazeMode == COMPONENT_MODE_ENABLED);
|
haze->setHazeActive(hazeMode == COMPONENT_MODE_ENABLED);
|
||||||
haze->setAltitudeBased(_hazeProperties.getHazeAltitudeEffect());
|
haze->setAltitudeBased(_hazeProperties.getHazeAltitudeEffect());
|
||||||
|
|
||||||
haze->setHazeRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange()));
|
haze->setHazeRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange()));
|
||||||
xColor hazeColor = _hazeProperties.getHazeColor();
|
xColor hazeColor = _hazeProperties.getHazeColor();
|
||||||
haze->setHazeColor(glm::vec3(hazeColor.red / 255.0, hazeColor.green / 255.0, hazeColor.blue / 255.0));
|
haze->setHazeColor(glm::vec3(hazeColor.red / 255.0, hazeColor.green / 255.0, hazeColor.blue / 255.0));
|
||||||
xColor hazeGlareColor = _hazeProperties.getHazeGlareColor();
|
xColor hazeGlareColor = _hazeProperties.getHazeGlareColor();
|
||||||
haze->setHazeGlareColor(glm::vec3(hazeGlareColor.red / 255.0, hazeGlareColor.green / 255.0, hazeGlareColor.blue / 255.0));
|
haze->setHazeGlareColor(glm::vec3(hazeGlareColor.red / 255.0, hazeGlareColor.green / 255.0, hazeGlareColor.blue / 255.0));
|
||||||
haze->setHazeEnableGlare(_hazeProperties.getHazeEnableGlare());
|
haze->setHazeEnableGlare(_hazeProperties.getHazeEnableGlare());
|
||||||
haze->setHazeGlareBlend(model::Haze::convertGlareAngleToPower(_hazeProperties.getHazeGlareAngle()));
|
haze->setHazeGlareBlend(graphics::Haze::convertGlareAngleToPower(_hazeProperties.getHazeGlareAngle()));
|
||||||
|
|
||||||
float hazeAltitude = _hazeProperties.getHazeCeiling() - _hazeProperties.getHazeBaseRef();
|
float hazeAltitude = _hazeProperties.getHazeCeiling() - _hazeProperties.getHazeBaseRef();
|
||||||
haze->setHazeAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(hazeAltitude));
|
haze->setHazeAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(hazeAltitude));
|
||||||
haze->setHazeBaseReference(_hazeProperties.getHazeBaseRef());
|
haze->setHazeBaseReference(_hazeProperties.getHazeBaseRef());
|
||||||
|
|
||||||
haze->setHazeBackgroundBlend(_hazeProperties.getHazeBackgroundBlend());
|
haze->setHazeBackgroundBlend(_hazeProperties.getHazeBackgroundBlend());
|
||||||
|
|
||||||
haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight());
|
haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight());
|
||||||
haze->setHazeKeyLightRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange()));
|
haze->setHazeKeyLightRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange()));
|
||||||
haze->setHazeKeyLightAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude()));
|
haze->setHazeKeyLightAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude()));
|
||||||
|
|
||||||
haze->setZoneTransform(entity->getTransform().getMatrix());
|
haze->setZoneTransform(entity->getTransform().getMatrix());
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
#define hifi_RenderableZoneEntityItem_h
|
#define hifi_RenderableZoneEntityItem_h
|
||||||
|
|
||||||
#include <ZoneEntityItem.h>
|
#include <ZoneEntityItem.h>
|
||||||
#include <model/Skybox.h>
|
#include <graphics/Skybox.h>
|
||||||
#include <model/Haze.h>
|
#include <graphics/Haze.h>
|
||||||
#include <model/Stage.h>
|
#include <graphics/Stage.h>
|
||||||
#include <LightStage.h>
|
#include <LightStage.h>
|
||||||
#include <BackgroundStage.h>
|
#include <BackgroundStage.h>
|
||||||
#include <HazeStage.h>
|
#include <HazeStage.h>
|
||||||
|
@ -63,11 +63,11 @@ private:
|
||||||
void setSkyboxColor(const glm::vec3& color);
|
void setSkyboxColor(const glm::vec3& color);
|
||||||
void setProceduralUserData(const QString& userData);
|
void setProceduralUserData(const QString& userData);
|
||||||
|
|
||||||
model::LightPointer editSunLight() { _needSunUpdate = true; return _sunLight; }
|
graphics::LightPointer editSunLight() { _needSunUpdate = true; return _sunLight; }
|
||||||
model::LightPointer editAmbientLight() { _needAmbientUpdate = true; return _ambientLight; }
|
graphics::LightPointer editAmbientLight() { _needAmbientUpdate = true; return _ambientLight; }
|
||||||
model::SunSkyStagePointer editBackground() { _needBackgroundUpdate = true; return _background; }
|
graphics::SunSkyStagePointer editBackground() { _needBackgroundUpdate = true; return _background; }
|
||||||
model::SkyboxPointer editSkybox() { return editBackground()->getSkybox(); }
|
graphics::SkyboxPointer editSkybox() { return editBackground()->getSkybox(); }
|
||||||
model::HazePointer editHaze() { _needHazeUpdate = true; return _haze; }
|
graphics::HazePointer editHaze() { _needHazeUpdate = true; return _haze; }
|
||||||
|
|
||||||
bool _needsInitialSimulation{ true };
|
bool _needsInitialSimulation{ true };
|
||||||
glm::vec3 _lastPosition;
|
glm::vec3 _lastPosition;
|
||||||
|
@ -83,10 +83,10 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LightStagePointer _stage;
|
LightStagePointer _stage;
|
||||||
const model::LightPointer _sunLight{ std::make_shared<model::Light>() };
|
const graphics::LightPointer _sunLight{ std::make_shared<graphics::Light>() };
|
||||||
const model::LightPointer _ambientLight{ std::make_shared<model::Light>() };
|
const graphics::LightPointer _ambientLight{ std::make_shared<graphics::Light>() };
|
||||||
const model::SunSkyStagePointer _background{ std::make_shared<model::SunSkyStage>() };
|
const graphics::SunSkyStagePointer _background{ std::make_shared<graphics::SunSkyStage>() };
|
||||||
const model::HazePointer _haze{ std::make_shared<model::Haze>() };
|
const graphics::HazePointer _haze{ std::make_shared<graphics::Haze>() };
|
||||||
|
|
||||||
ComponentMode _keyLightMode { COMPONENT_MODE_INHERIT };
|
ComponentMode _keyLightMode { COMPONENT_MODE_INHERIT };
|
||||||
ComponentMode _ambientLightMode { COMPONENT_MODE_INHERIT };
|
ComponentMode _ambientLightMode { COMPONENT_MODE_INHERIT };
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
<@include model/Material.slh@>
|
<@include graphics/Material.slh@>
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
<@include model/Material.slh@>
|
<@include graphics/Material.slh@>
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
<@include Fade.slh@>
|
<@include Fade.slh@>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
set(TARGET_NAME entities)
|
set(TARGET_NAME entities)
|
||||||
setup_hifi_library(Network Script)
|
setup_hifi_library(Network Script)
|
||||||
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
||||||
link_hifi_libraries(shared networking octree avatars model)
|
link_hifi_libraries(shared networking octree avatars graphics)
|
||||||
|
|
|
@ -2283,30 +2283,35 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
||||||
properties.setOwningAvatarID(myNodeID);
|
properties.setOwningAvatarID(myNodeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for older content not containing these fields in the zones
|
// Fix for older content not containing mode fields in the zones
|
||||||
if (needsConversion && (properties.getType() == EntityTypes::EntityType::Zone)) {
|
if (needsConversion && (properties.getType() == EntityTypes::EntityType::Zone)) {
|
||||||
|
// The legacy version had no keylight mode - this is set to on
|
||||||
|
properties.setKeyLightMode(COMPONENT_MODE_ENABLED);
|
||||||
|
|
||||||
// The ambient URL has been moved from "keyLight" to "ambientLight"
|
// The ambient URL has been moved from "keyLight" to "ambientLight"
|
||||||
if (entityMap.contains("keyLight")) {
|
if (entityMap.contains("keyLight")) {
|
||||||
QVariantMap keyLightObject = entityMap["keyLight"].toMap();
|
QVariantMap keyLightObject = entityMap["keyLight"].toMap();
|
||||||
properties.getAmbientLight().setAmbientURL(keyLightObject["ambientURL"].toString());
|
properties.getAmbientLight().setAmbientURL(keyLightObject["ambientURL"].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy the skybox URL if the ambient URL is empty, as this is the legacy behaviour
|
||||||
|
// Use skybox value only if it is not empty, else set ambientMode to inherit (to use default URL)
|
||||||
|
properties.setAmbientLightMode(COMPONENT_MODE_ENABLED);
|
||||||
|
if (properties.getAmbientLight().getAmbientURL() == "") {
|
||||||
|
if (properties.getSkybox().getURL() != "") {
|
||||||
|
properties.getAmbientLight().setAmbientURL(properties.getSkybox().getURL());
|
||||||
|
} else {
|
||||||
|
properties.setAmbientLightMode(COMPONENT_MODE_INHERIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The background should be enabled if the mode is skybox
|
// The background should be enabled if the mode is skybox
|
||||||
// Note that if the values are default then they are not stored in the JSON file
|
// Note that if the values are default then they are not stored in the JSON file
|
||||||
if (entityMap.contains("backgroundMode") && (entityMap["backgroundMode"].toString() == "skybox")) {
|
if (entityMap.contains("backgroundMode") && (entityMap["backgroundMode"].toString() == "skybox")) {
|
||||||
properties.setSkyboxMode(COMPONENT_MODE_ENABLED);
|
properties.setSkyboxMode(COMPONENT_MODE_ENABLED);
|
||||||
|
} else {
|
||||||
// Copy the skybox URL if the ambient URL is empty, as this is the legacy behaviour
|
|
||||||
if (properties.getAmbientLight().getAmbientURL() == "") {
|
|
||||||
properties.getAmbientLight().setAmbientURL(properties.getSkybox().getURL());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
properties.setSkyboxMode(COMPONENT_MODE_INHERIT);
|
properties.setSkyboxMode(COMPONENT_MODE_INHERIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The legacy version had no keylight/ambient modes - these are always on
|
|
||||||
properties.setKeyLightMode(COMPONENT_MODE_ENABLED);
|
|
||||||
properties.setAmbientLightMode(COMPONENT_MODE_ENABLED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItemPointer entity = addEntity(entityItemID, properties);
|
EntityItemPointer entity = addEntity(entityItemID, properties);
|
||||||
|
|
|
@ -267,9 +267,9 @@ void ModelEntityItem::updateFrameCount() {
|
||||||
if (!getAnimationHold() && getAnimationIsPlaying()) {
|
if (!getAnimationHold() && getAnimationIsPlaying()) {
|
||||||
float deltaTime = (float)interval / (float)USECS_PER_SECOND;
|
float deltaTime = (float)interval / (float)USECS_PER_SECOND;
|
||||||
_currentFrame += (deltaTime * getAnimationFPS());
|
_currentFrame += (deltaTime * getAnimationFPS());
|
||||||
if (_currentFrame > getAnimationLastFrame()) {
|
if (_currentFrame > getAnimationLastFrame() + 1) {
|
||||||
if (getAnimationLoop()) {
|
if (getAnimationLoop() && getAnimationFirstFrame() != getAnimationLastFrame()) {
|
||||||
_currentFrame = getAnimationFirstFrame() + (int)(glm::floor(_currentFrame - getAnimationFirstFrame())) % (updatedFrameCount - 1);
|
_currentFrame = getAnimationFirstFrame() + (int)(_currentFrame - getAnimationFirstFrame()) % updatedFrameCount;
|
||||||
} else {
|
} else {
|
||||||
_currentFrame = getAnimationLastFrame();
|
_currentFrame = getAnimationLastFrame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
set(TARGET_NAME fbx)
|
set(TARGET_NAME fbx)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
|
|
||||||
link_hifi_libraries(shared model networking image)
|
link_hifi_libraries(shared graphics networking image)
|
||||||
include_hifi_library_headers(gpu image)
|
include_hifi_library_headers(gpu image)
|
||||||
|
|
||||||
target_draco()
|
target_draco()
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
#include <Extents.h>
|
#include <Extents.h>
|
||||||
#include <Transform.h>
|
#include <Transform.h>
|
||||||
|
|
||||||
#include <model/Geometry.h>
|
#include <graphics/Geometry.h>
|
||||||
#include <model/Material.h>
|
#include <graphics/Material.h>
|
||||||
|
|
||||||
static const QByteArray FBX_BINARY_PROLOG = "Kaydara FBX Binary ";
|
static const QByteArray FBX_BINARY_PROLOG = "Kaydara FBX Binary ";
|
||||||
static const int FBX_HEADER_BYTES_BEFORE_VERSION = 23;
|
static const int FBX_HEADER_BYTES_BEFORE_VERSION = 23;
|
||||||
|
@ -183,7 +183,7 @@ public:
|
||||||
QString materialID;
|
QString materialID;
|
||||||
QString name;
|
QString name;
|
||||||
QString shadingModel;
|
QString shadingModel;
|
||||||
model::MaterialPointer _material;
|
graphics::MaterialPointer _material;
|
||||||
|
|
||||||
FBXTexture normalTexture;
|
FBXTexture normalTexture;
|
||||||
FBXTexture albedoTexture;
|
FBXTexture albedoTexture;
|
||||||
|
@ -238,7 +238,7 @@ public:
|
||||||
|
|
||||||
unsigned int meshIndex; // the order the meshes appeared in the object file
|
unsigned int meshIndex; // the order the meshes appeared in the object file
|
||||||
|
|
||||||
model::MeshPointer _mesh;
|
graphics::MeshPointer _mesh;
|
||||||
bool wasCompressed { false };
|
bool wasCompressed { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ Extents FBXGeometry::getUnscaledMeshExtents() const {
|
||||||
return scaledExtents;
|
return scaledExtents;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move to model::Mesh when Sam's ready
|
// TODO: Move to graphics::Mesh when Sam's ready
|
||||||
bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
|
bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
|
||||||
if (!getUnscaledMeshExtents().containsPoint(point)) {
|
if (!getUnscaledMeshExtents().containsPoint(point)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -148,6 +148,59 @@ glm::vec3 parseVec3(const QString& string) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum RotationOrder {
|
||||||
|
OrderXYZ = 0,
|
||||||
|
OrderXZY,
|
||||||
|
OrderYZX,
|
||||||
|
OrderYXZ,
|
||||||
|
OrderZXY,
|
||||||
|
OrderZYX,
|
||||||
|
OrderSphericXYZ
|
||||||
|
};
|
||||||
|
|
||||||
|
bool haveReportedUnhandledRotationOrder = false; // Report error only once per FBX file.
|
||||||
|
|
||||||
|
glm::vec3 convertRotationToXYZ(int rotationOrder, const glm::vec3& rotation) {
|
||||||
|
// Convert rotation with given rotation order to have order XYZ.
|
||||||
|
if (rotationOrder == OrderXYZ) {
|
||||||
|
return rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::quat xyzRotation;
|
||||||
|
|
||||||
|
switch (rotationOrder) {
|
||||||
|
case OrderXZY:
|
||||||
|
xyzRotation = glm::quat(glm::radians(glm::vec3(0, rotation.y, 0)))
|
||||||
|
* (glm::quat(glm::radians(glm::vec3(0, 0, rotation.z))) * glm::quat(glm::radians(glm::vec3(rotation.x, 0, 0))));
|
||||||
|
break;
|
||||||
|
case OrderYZX:
|
||||||
|
xyzRotation = glm::quat(glm::radians(glm::vec3(rotation.x, 0, 0)))
|
||||||
|
* (glm::quat(glm::radians(glm::vec3(0, 0, rotation.z))) * glm::quat(glm::radians(glm::vec3(0, rotation.y, 0))));
|
||||||
|
break;
|
||||||
|
case OrderYXZ:
|
||||||
|
xyzRotation = glm::quat(glm::radians(glm::vec3(0, 0, rotation.z)))
|
||||||
|
* (glm::quat(glm::radians(glm::vec3(rotation.x, 0, 0))) * glm::quat(glm::radians(glm::vec3(0, rotation.y, 0))));
|
||||||
|
break;
|
||||||
|
case OrderZXY:
|
||||||
|
xyzRotation = glm::quat(glm::radians(glm::vec3(0, rotation.y, 0)))
|
||||||
|
* (glm::quat(glm::radians(glm::vec3(rotation.x, 0, 0))) * glm::quat(glm::radians(glm::vec3(0, 0, rotation.z))));
|
||||||
|
break;
|
||||||
|
case OrderZYX:
|
||||||
|
xyzRotation = glm::quat(glm::radians(glm::vec3(rotation.x, 0, 0)))
|
||||||
|
* (glm::quat(glm::radians(glm::vec3(0, rotation.y, 0))) * glm::quat(glm::radians(glm::vec3(0, 0, rotation.z))));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// FIXME: Handle OrderSphericXYZ.
|
||||||
|
if (!haveReportedUnhandledRotationOrder) {
|
||||||
|
qCDebug(modelformat) << "ERROR: Unhandled rotation order in FBX file:" << rotationOrder;
|
||||||
|
haveReportedUnhandledRotationOrder = true;
|
||||||
|
}
|
||||||
|
return rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
return glm::degrees(safeEulerAngles(xyzRotation));
|
||||||
|
}
|
||||||
|
|
||||||
QString processID(const QString& id) {
|
QString processID(const QString& id) {
|
||||||
// Blender (at least) prepends a type to the ID, so strip it out
|
// Blender (at least) prepends a type to the ID, so strip it out
|
||||||
return id.mid(id.lastIndexOf(':') + 1);
|
return id.mid(id.lastIndexOf(':') + 1);
|
||||||
|
@ -630,6 +683,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
glm::vec3 ambientColor;
|
glm::vec3 ambientColor;
|
||||||
QString hifiGlobalNodeID;
|
QString hifiGlobalNodeID;
|
||||||
unsigned int meshIndex = 0;
|
unsigned int meshIndex = 0;
|
||||||
|
haveReportedUnhandledRotationOrder = false;
|
||||||
foreach (const FBXNode& child, node.children) {
|
foreach (const FBXNode& child, node.children) {
|
||||||
|
|
||||||
if (child.name == "FBXHeaderExtension") {
|
if (child.name == "FBXHeaderExtension") {
|
||||||
|
@ -731,6 +785,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
glm::vec3 translation;
|
glm::vec3 translation;
|
||||||
// NOTE: the euler angles as supplied by the FBX file are in degrees
|
// NOTE: the euler angles as supplied by the FBX file are in degrees
|
||||||
glm::vec3 rotationOffset;
|
glm::vec3 rotationOffset;
|
||||||
|
int rotationOrder = OrderXYZ; // Default rotation order set in "Definitions" node is assumed to be XYZ.
|
||||||
glm::vec3 preRotation, rotation, postRotation;
|
glm::vec3 preRotation, rotation, postRotation;
|
||||||
glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f);
|
glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||||
glm::vec3 scalePivot, rotationPivot, scaleOffset;
|
glm::vec3 scalePivot, rotationPivot, scaleOffset;
|
||||||
|
@ -764,6 +819,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
index = 4;
|
index = 4;
|
||||||
}
|
}
|
||||||
if (properties) {
|
if (properties) {
|
||||||
|
static const QVariant ROTATION_ORDER = QByteArray("RotationOrder");
|
||||||
static const QVariant GEOMETRIC_TRANSLATION = QByteArray("GeometricTranslation");
|
static const QVariant GEOMETRIC_TRANSLATION = QByteArray("GeometricTranslation");
|
||||||
static const QVariant GEOMETRIC_ROTATION = QByteArray("GeometricRotation");
|
static const QVariant GEOMETRIC_ROTATION = QByteArray("GeometricRotation");
|
||||||
static const QVariant GEOMETRIC_SCALING = QByteArray("GeometricScaling");
|
static const QVariant GEOMETRIC_SCALING = QByteArray("GeometricScaling");
|
||||||
|
@ -790,6 +846,9 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
if (childProperty == LCL_TRANSLATION) {
|
if (childProperty == LCL_TRANSLATION) {
|
||||||
translation = getVec3(property.properties, index);
|
translation = getVec3(property.properties, index);
|
||||||
|
|
||||||
|
} else if (childProperty == ROTATION_ORDER) {
|
||||||
|
rotationOrder = property.properties.at(index).toInt();
|
||||||
|
|
||||||
} else if (childProperty == ROTATION_OFFSET) {
|
} else if (childProperty == ROTATION_OFFSET) {
|
||||||
rotationOffset = getVec3(property.properties, index);
|
rotationOffset = getVec3(property.properties, index);
|
||||||
|
|
||||||
|
@ -797,13 +856,13 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
rotationPivot = getVec3(property.properties, index);
|
rotationPivot = getVec3(property.properties, index);
|
||||||
|
|
||||||
} else if (childProperty == PRE_ROTATION) {
|
} else if (childProperty == PRE_ROTATION) {
|
||||||
preRotation = getVec3(property.properties, index);
|
preRotation = convertRotationToXYZ(rotationOrder, getVec3(property.properties, index));
|
||||||
|
|
||||||
} else if (childProperty == LCL_ROTATION) {
|
} else if (childProperty == LCL_ROTATION) {
|
||||||
rotation = getVec3(property.properties, index);
|
rotation = convertRotationToXYZ(rotationOrder, getVec3(property.properties, index));
|
||||||
|
|
||||||
} else if (childProperty == POST_ROTATION) {
|
} else if (childProperty == POST_ROTATION) {
|
||||||
postRotation = getVec3(property.properties, index);
|
postRotation = convertRotationToXYZ(rotationOrder, getVec3(property.properties, index));
|
||||||
|
|
||||||
} else if (childProperty == SCALING_PIVOT) {
|
} else if (childProperty == SCALING_PIVOT) {
|
||||||
scalePivot = getVec3(property.properties, index);
|
scalePivot = getVec3(property.properties, index);
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
#include <Extents.h>
|
#include <Extents.h>
|
||||||
#include <Transform.h>
|
#include <Transform.h>
|
||||||
|
|
||||||
#include <model/Geometry.h>
|
#include <graphics/Geometry.h>
|
||||||
#include <model/Material.h>
|
#include <graphics/Material.h>
|
||||||
|
|
||||||
class QIODevice;
|
class QIODevice;
|
||||||
class FBXNode;
|
class FBXNode;
|
||||||
|
|
|
@ -279,7 +279,7 @@ void FBXReader::consolidateFBXMaterials(const QVariantHash& mapping) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally create the true material representation
|
// Finally create the true material representation
|
||||||
material._material = std::make_shared<model::Material>();
|
material._material = std::make_shared<graphics::Material>();
|
||||||
|
|
||||||
// Emissive color is the mix of emissiveColor with emissiveFactor
|
// Emissive color is the mix of emissiveColor with emissiveFactor
|
||||||
auto emissive = material.emissiveColor * (isMaterialLambert ? 1.0f : material.emissiveFactor); // In lambert there is not emissiveFactor
|
auto emissive = material.emissiveColor * (isMaterialLambert ? 1.0f : material.emissiveFactor); // In lambert there is not emissiveFactor
|
||||||
|
@ -293,7 +293,7 @@ void FBXReader::consolidateFBXMaterials(const QVariantHash& mapping) {
|
||||||
material._material->setRoughness(material.roughness);
|
material._material->setRoughness(material.roughness);
|
||||||
material._material->setMetallic(material.metallic);
|
material._material->setMetallic(material.metallic);
|
||||||
} else {
|
} else {
|
||||||
material._material->setRoughness(model::Material::shininessToRoughness(material.shininess));
|
material._material->setRoughness(graphics::Material::shininessToRoughness(material.shininess));
|
||||||
float metallic = std::max(material.specularColor.x, std::max(material.specularColor.y, material.specularColor.z));
|
float metallic = std::max(material.specularColor.x, std::max(material.specularColor.y, material.specularColor.z));
|
||||||
material._material->setMetallic(metallic);
|
material._material->setMetallic(metallic);
|
||||||
|
|
||||||
|
|
|
@ -584,7 +584,7 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FBXMesh& fbxMesh = extractedMesh;
|
FBXMesh& fbxMesh = extractedMesh;
|
||||||
model::MeshPointer mesh(new model::Mesh());
|
graphics::MeshPointer mesh(new graphics::Mesh());
|
||||||
|
|
||||||
// Grab the vertices in a buffer
|
// Grab the vertices in a buffer
|
||||||
auto vb = std::make_shared<gpu::Buffer>();
|
auto vb = std::make_shared<gpu::Buffer>();
|
||||||
|
@ -721,45 +721,45 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) {
|
||||||
|
|
||||||
if (normalsSize) {
|
if (normalsSize) {
|
||||||
mesh->addAttribute(gpu::Stream::NORMAL,
|
mesh->addAttribute(gpu::Stream::NORMAL,
|
||||||
model::BufferView(attribBuffer, normalsOffset, normalsAndTangentsSize,
|
graphics::BufferView(attribBuffer, normalsOffset, normalsAndTangentsSize,
|
||||||
normalsAndTangentsStride, FBX_NORMAL_ELEMENT));
|
normalsAndTangentsStride, FBX_NORMAL_ELEMENT));
|
||||||
mesh->addAttribute(gpu::Stream::TANGENT,
|
mesh->addAttribute(gpu::Stream::TANGENT,
|
||||||
model::BufferView(attribBuffer, tangentsOffset, normalsAndTangentsSize,
|
graphics::BufferView(attribBuffer, tangentsOffset, normalsAndTangentsSize,
|
||||||
normalsAndTangentsStride, FBX_NORMAL_ELEMENT));
|
normalsAndTangentsStride, FBX_NORMAL_ELEMENT));
|
||||||
}
|
}
|
||||||
if (colorsSize) {
|
if (colorsSize) {
|
||||||
mesh->addAttribute(gpu::Stream::COLOR,
|
mesh->addAttribute(gpu::Stream::COLOR,
|
||||||
model::BufferView(attribBuffer, colorsOffset, colorsSize, FBX_COLOR_ELEMENT));
|
graphics::BufferView(attribBuffer, colorsOffset, colorsSize, FBX_COLOR_ELEMENT));
|
||||||
}
|
}
|
||||||
if (texCoordsSize) {
|
if (texCoordsSize) {
|
||||||
mesh->addAttribute(gpu::Stream::TEXCOORD,
|
mesh->addAttribute(gpu::Stream::TEXCOORD,
|
||||||
model::BufferView( attribBuffer, texCoordsOffset, texCoordsSize,
|
graphics::BufferView( attribBuffer, texCoordsOffset, texCoordsSize,
|
||||||
gpu::Element(gpu::VEC2, gpu::HALF, gpu::UV)));
|
gpu::Element(gpu::VEC2, gpu::HALF, gpu::UV)));
|
||||||
}
|
}
|
||||||
if (texCoords1Size) {
|
if (texCoords1Size) {
|
||||||
mesh->addAttribute( gpu::Stream::TEXCOORD1,
|
mesh->addAttribute( gpu::Stream::TEXCOORD1,
|
||||||
model::BufferView(attribBuffer, texCoords1Offset, texCoords1Size,
|
graphics::BufferView(attribBuffer, texCoords1Offset, texCoords1Size,
|
||||||
gpu::Element(gpu::VEC2, gpu::HALF, gpu::UV)));
|
gpu::Element(gpu::VEC2, gpu::HALF, gpu::UV)));
|
||||||
} else if (texCoordsSize) {
|
} else if (texCoordsSize) {
|
||||||
mesh->addAttribute(gpu::Stream::TEXCOORD1,
|
mesh->addAttribute(gpu::Stream::TEXCOORD1,
|
||||||
model::BufferView(attribBuffer, texCoordsOffset, texCoordsSize,
|
graphics::BufferView(attribBuffer, texCoordsOffset, texCoordsSize,
|
||||||
gpu::Element(gpu::VEC2, gpu::HALF, gpu::UV)));
|
gpu::Element(gpu::VEC2, gpu::HALF, gpu::UV)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clusterIndicesSize) {
|
if (clusterIndicesSize) {
|
||||||
if (fbxMesh.clusters.size() < UINT8_MAX) {
|
if (fbxMesh.clusters.size() < UINT8_MAX) {
|
||||||
mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_INDEX,
|
mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_INDEX,
|
||||||
model::BufferView(attribBuffer, clusterIndicesOffset, clusterIndicesSize,
|
graphics::BufferView(attribBuffer, clusterIndicesOffset, clusterIndicesSize,
|
||||||
gpu::Element(gpu::VEC4, gpu::UINT8, gpu::XYZW)));
|
gpu::Element(gpu::VEC4, gpu::UINT8, gpu::XYZW)));
|
||||||
} else {
|
} else {
|
||||||
mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_INDEX,
|
mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_INDEX,
|
||||||
model::BufferView(attribBuffer, clusterIndicesOffset, clusterIndicesSize,
|
graphics::BufferView(attribBuffer, clusterIndicesOffset, clusterIndicesSize,
|
||||||
gpu::Element(gpu::VEC4, gpu::UINT16, gpu::XYZW)));
|
gpu::Element(gpu::VEC4, gpu::UINT16, gpu::XYZW)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (clusterWeightsSize) {
|
if (clusterWeightsSize) {
|
||||||
mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_WEIGHT,
|
mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_WEIGHT,
|
||||||
model::BufferView(attribBuffer, clusterWeightsOffset, clusterWeightsSize,
|
graphics::BufferView(attribBuffer, clusterWeightsOffset, clusterWeightsSize,
|
||||||
gpu::Element(gpu::VEC4, gpu::NUINT16, gpu::XYZW)));
|
gpu::Element(gpu::VEC4, gpu::NUINT16, gpu::XYZW)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,12 +780,12 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) {
|
||||||
int indexNum = 0;
|
int indexNum = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
std::vector< model::Mesh::Part > parts;
|
std::vector< graphics::Mesh::Part > parts;
|
||||||
if (extractedMesh.parts.size() > 1) {
|
if (extractedMesh.parts.size() > 1) {
|
||||||
indexNum = 0;
|
indexNum = 0;
|
||||||
}
|
}
|
||||||
foreach(const FBXMeshPart& part, extractedMesh.parts) {
|
foreach(const FBXMeshPart& part, extractedMesh.parts) {
|
||||||
model::Mesh::Part modelPart(indexNum, 0, 0, model::Mesh::TRIANGLES);
|
graphics::Mesh::Part modelPart(indexNum, 0, 0, graphics::Mesh::TRIANGLES);
|
||||||
|
|
||||||
if (part.quadTrianglesIndices.size()) {
|
if (part.quadTrianglesIndices.size()) {
|
||||||
indexBuffer->setSubData(offset,
|
indexBuffer->setSubData(offset,
|
||||||
|
@ -813,7 +813,7 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) {
|
||||||
|
|
||||||
if (parts.size()) {
|
if (parts.size()) {
|
||||||
auto pb = std::make_shared<gpu::Buffer>();
|
auto pb = std::make_shared<gpu::Buffer>();
|
||||||
pb->setData(parts.size() * sizeof(model::Mesh::Part), (const gpu::Byte*) parts.data());
|
pb->setData(parts.size() * sizeof(graphics::Mesh::Part), (const gpu::Byte*) parts.data());
|
||||||
gpu::BufferView pbv(pb, gpu::Element(gpu::VEC4, gpu::UINT32, gpu::XYZW));
|
gpu::BufferView pbv(pb, gpu::Element(gpu::VEC4, gpu::UINT32, gpu::XYZW));
|
||||||
mesh->setPartBuffer(pbv);
|
mesh->setPartBuffer(pbv);
|
||||||
} else {
|
} else {
|
||||||
|
@ -821,7 +821,7 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// model::Box box =
|
// graphics::Box box =
|
||||||
mesh->evalPartBound(0);
|
mesh->evalPartBound(0);
|
||||||
|
|
||||||
extractedMesh._mesh = mesh;
|
extractedMesh._mesh = mesh;
|
||||||
|
|
|
@ -748,7 +748,7 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
|
||||||
QString& matid = materialIDs[i];
|
QString& matid = materialIDs[i];
|
||||||
geometry.materials[matid] = FBXMaterial();
|
geometry.materials[matid] = FBXMaterial();
|
||||||
FBXMaterial& fbxMaterial = geometry.materials[matid];
|
FBXMaterial& fbxMaterial = geometry.materials[matid];
|
||||||
fbxMaterial._material = std::make_shared<model::Material>();
|
fbxMaterial._material = std::make_shared<graphics::Material>();
|
||||||
setFBXMaterial(fbxMaterial, _file.materials[i]);
|
setFBXMaterial(fbxMaterial, _file.materials[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -750,8 +750,8 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping,
|
||||||
objMaterial.opacity);
|
objMaterial.opacity);
|
||||||
FBXMaterial& fbxMaterial = geometry.materials[materialID];
|
FBXMaterial& fbxMaterial = geometry.materials[materialID];
|
||||||
fbxMaterial.materialID = materialID;
|
fbxMaterial.materialID = materialID;
|
||||||
fbxMaterial._material = std::make_shared<model::Material>();
|
fbxMaterial._material = std::make_shared<graphics::Material>();
|
||||||
model::MaterialPointer modelMaterial = fbxMaterial._material;
|
graphics::MaterialPointer modelMaterial = fbxMaterial._material;
|
||||||
|
|
||||||
if (!objMaterial.diffuseTextureFilename.isEmpty()) {
|
if (!objMaterial.diffuseTextureFilename.isEmpty()) {
|
||||||
fbxMaterial.albedoTexture.filename = objMaterial.diffuseTextureFilename;
|
fbxMaterial.albedoTexture.filename = objMaterial.diffuseTextureFilename;
|
||||||
|
@ -763,7 +763,7 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping,
|
||||||
modelMaterial->setEmissive(fbxMaterial.emissiveColor);
|
modelMaterial->setEmissive(fbxMaterial.emissiveColor);
|
||||||
modelMaterial->setAlbedo(fbxMaterial.diffuseColor);
|
modelMaterial->setAlbedo(fbxMaterial.diffuseColor);
|
||||||
modelMaterial->setMetallic(glm::length(fbxMaterial.specularColor));
|
modelMaterial->setMetallic(glm::length(fbxMaterial.specularColor));
|
||||||
modelMaterial->setRoughness(model::Material::shininessToRoughness(fbxMaterial.shininess));
|
modelMaterial->setRoughness(graphics::Material::shininessToRoughness(fbxMaterial.shininess));
|
||||||
|
|
||||||
if (fbxMaterial.opacity <= 0.0f) {
|
if (fbxMaterial.opacity <= 0.0f) {
|
||||||
modelMaterial->setOpacity(1.0f);
|
modelMaterial->setOpacity(1.0f);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "model/Geometry.h"
|
#include "graphics/Geometry.h"
|
||||||
#include "OBJWriter.h"
|
#include "OBJWriter.h"
|
||||||
#include "ModelFormatLogging.h"
|
#include "ModelFormatLogging.h"
|
||||||
|
|
||||||
|
@ -105,13 +105,13 @@ bool writeOBJToTextStream(QTextStream& out, QList<MeshPointer> meshes) {
|
||||||
const gpu::BufferView& partBuffer = mesh->getPartBuffer();
|
const gpu::BufferView& partBuffer = mesh->getPartBuffer();
|
||||||
const gpu::BufferView& indexBuffer = mesh->getIndexBuffer();
|
const gpu::BufferView& indexBuffer = mesh->getIndexBuffer();
|
||||||
|
|
||||||
model::Index partCount = (model::Index)mesh->getNumParts();
|
graphics::Index partCount = (graphics::Index)mesh->getNumParts();
|
||||||
for (int partIndex = 0; partIndex < partCount; partIndex++) {
|
for (int partIndex = 0; partIndex < partCount; partIndex++) {
|
||||||
const model::Mesh::Part& part = partBuffer.get<model::Mesh::Part>(partIndex);
|
const graphics::Mesh::Part& part = partBuffer.get<graphics::Mesh::Part>(partIndex);
|
||||||
|
|
||||||
out << "g part-" << nth++ << "\n";
|
out << "g part-" << nth++ << "\n";
|
||||||
|
|
||||||
// model::Mesh::TRIANGLES
|
// graphics::Mesh::TRIANGLES
|
||||||
// TODO -- handle other formats
|
// TODO -- handle other formats
|
||||||
gpu::BufferView::Iterator<const uint32_t> indexItr = indexBuffer.cbegin<uint32_t>();
|
gpu::BufferView::Iterator<const uint32_t> indexItr = indexBuffer.cbegin<uint32_t>();
|
||||||
indexItr += part._startIndex;
|
indexItr += part._startIndex;
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <model/Geometry.h>
|
#include <graphics/Geometry.h>
|
||||||
|
|
||||||
using MeshPointer = std::shared_ptr<model::Mesh>;
|
using MeshPointer = std::shared_ptr<graphics::Mesh>;
|
||||||
|
|
||||||
bool writeOBJToTextStream(QTextStream& out, QList<MeshPointer> meshes);
|
bool writeOBJToTextStream(QTextStream& out, QList<MeshPointer> meshes);
|
||||||
bool writeOBJToFile(QString path, QList<MeshPointer> meshes);
|
bool writeOBJToFile(QString path, QList<MeshPointer> meshes);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
set(TARGET_NAME model)
|
set(TARGET_NAME graphics)
|
||||||
AUTOSCRIBE_SHADER_LIB(gpu model)
|
AUTOSCRIBE_SHADER_LIB(gpu graphics)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared ktx gpu image)
|
link_hifi_libraries(shared ktx gpu image)
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Asset.cpp
|
// Asset.cpp
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 08/21/2015.
|
// Created by Sam Gateau on 08/21/2015.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
//
|
//
|
||||||
#include "Asset.h"
|
#include "Asset.h"
|
||||||
|
|
||||||
using namespace model;
|
using namespace graphics;
|
||||||
|
|
||||||
Asset::Asset() {
|
Asset::Asset() {
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Asset.h
|
// Asset.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 08/21/2015.
|
// Created by Sam Gateau on 08/21/2015.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
#include "Material.h"
|
#include "Material.h"
|
||||||
#include "Geometry.h"
|
#include "Geometry.h"
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class Table {
|
class Table {
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Forward.h
|
// Forward.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Bradley Austin Davis on 2017/06/21
|
// Created by Bradley Austin Davis on 2017/06/21
|
||||||
// Copyright 2013-2017 High Fidelity, Inc.
|
// Copyright 2013-2017 High Fidelity, Inc.
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
#ifndef hifi_model_Forward_h
|
#ifndef hifi_model_Forward_h
|
||||||
#define hifi_model_Forward_h
|
#define hifi_model_Forward_h
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
class Mesh;
|
class Mesh;
|
||||||
using MeshPointer = std::shared_ptr<Mesh>;
|
using MeshPointer = std::shared_ptr<Mesh>;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Geometry.cpp
|
// Geometry.cpp
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 12/5/2014.
|
// Created by Sam Gateau on 12/5/2014.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include <glm/gtc/packing.hpp>
|
#include <glm/gtc/packing.hpp>
|
||||||
|
|
||||||
using namespace model;
|
using namespace graphics;
|
||||||
|
|
||||||
Mesh::Mesh() :
|
Mesh::Mesh() :
|
||||||
_vertexBuffer(gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)),
|
_vertexBuffer(gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)),
|
||||||
|
@ -137,7 +137,7 @@ Box Mesh::evalPartsBound(int partStart, int partEnd) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
model::MeshPointer Mesh::map(std::function<glm::vec3(glm::vec3)> vertexFunc,
|
graphics::MeshPointer Mesh::map(std::function<glm::vec3(glm::vec3)> vertexFunc,
|
||||||
std::function<glm::vec3(glm::vec3)> colorFunc,
|
std::function<glm::vec3(glm::vec3)> colorFunc,
|
||||||
std::function<glm::vec3(glm::vec3)> normalFunc,
|
std::function<glm::vec3(glm::vec3)> normalFunc,
|
||||||
std::function<uint32_t(uint32_t)> indexFunc) const {
|
std::function<uint32_t(uint32_t)> indexFunc) const {
|
||||||
|
@ -223,7 +223,7 @@ model::MeshPointer Mesh::map(std::function<glm::vec3(glm::vec3)> vertexFunc,
|
||||||
indexDataCursor += sizeof(index);
|
indexDataCursor += sizeof(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
model::MeshPointer result(new model::Mesh());
|
graphics::MeshPointer result(new graphics::Mesh());
|
||||||
|
|
||||||
gpu::Element vertexElement = gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ);
|
gpu::Element vertexElement = gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ);
|
||||||
gpu::Buffer* resultVertexBuffer = new gpu::Buffer(vertexSize, resultVertexData.get());
|
gpu::Buffer* resultVertexBuffer = new gpu::Buffer(vertexSize, resultVertexData.get());
|
||||||
|
@ -252,12 +252,12 @@ model::MeshPointer Mesh::map(std::function<glm::vec3(glm::vec3)> vertexFunc,
|
||||||
|
|
||||||
// TODO -- shouldn't assume just one part
|
// TODO -- shouldn't assume just one part
|
||||||
|
|
||||||
std::vector<model::Mesh::Part> parts;
|
std::vector<graphics::Mesh::Part> parts;
|
||||||
parts.emplace_back(model::Mesh::Part((model::Index)0, // startIndex
|
parts.emplace_back(graphics::Mesh::Part((graphics::Index)0, // startIndex
|
||||||
(model::Index)result->getNumIndices(), // numIndices
|
(graphics::Index)result->getNumIndices(), // numIndices
|
||||||
(model::Index)0, // baseVertex
|
(graphics::Index)0, // baseVertex
|
||||||
model::Mesh::TRIANGLES)); // topology
|
graphics::Mesh::TRIANGLES)); // topology
|
||||||
result->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part),
|
result->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part),
|
||||||
(gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
(gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -350,9 +350,9 @@ MeshPointer Mesh::createIndexedTriangles_P3F(uint32_t numVertices, uint32_t numI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<model::Mesh::Part> parts;
|
std::vector<graphics::Mesh::Part> parts;
|
||||||
parts.push_back(model::Mesh::Part(0, numIndices, 0, model::Mesh::TRIANGLES));
|
parts.push_back(graphics::Mesh::Part(0, numIndices, 0, graphics::Mesh::TRIANGLES));
|
||||||
mesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
mesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
||||||
|
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Geometry.h
|
// Geometry.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 12/5/2014.
|
// Created by Sam Gateau on 12/5/2014.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
#include <gpu/Resource.h>
|
#include <gpu/Resource.h>
|
||||||
#include <gpu/Stream.h>
|
#include <gpu/Stream.h>
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
typedef gpu::BufferView::Index Index;
|
typedef gpu::BufferView::Index Index;
|
||||||
typedef gpu::BufferView BufferView;
|
typedef gpu::BufferView BufferView;
|
||||||
typedef AABox Box;
|
typedef AABox Box;
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
typedef gpu::Stream::Format VertexFormat;
|
typedef gpu::Stream::Format VertexFormat;
|
||||||
typedef std::map< Slot, BufferView > BufferViewMap;
|
typedef std::map< Slot, BufferView > BufferViewMap;
|
||||||
|
|
||||||
typedef model::Vec3 Vec3;
|
typedef graphics::Vec3 Vec3;
|
||||||
|
|
||||||
Mesh();
|
Mesh();
|
||||||
Mesh(const Mesh& mesh);
|
Mesh(const Mesh& mesh);
|
|
@ -6,6 +6,6 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "ModelLogging.h"
|
#include "GraphicsLogging.h"
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(modelLog, "hifi.model")
|
Q_LOGGING_CATEGORY(graphicsLog, "hifi.graphics")
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// ModelLogging.h
|
// GraphicsLogging.h
|
||||||
// hifi
|
// hifi
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 9/20/15.
|
// Created by Sam Gateau on 9/20/15.
|
||||||
|
@ -11,4 +11,4 @@
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(modelLog)
|
Q_DECLARE_LOGGING_CATEGORY(graphicsLog)
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Haze.cpp
|
// Haze.cpp
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Nissim Hadar on 9/13/2017.
|
// Created by Nissim Hadar on 9/13/2017.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "Haze.h"
|
#include "Haze.h"
|
||||||
|
|
||||||
using namespace model;
|
using namespace graphics;
|
||||||
|
|
||||||
const float Haze::INITIAL_HAZE_RANGE{ 1000.0f };
|
const float Haze::INITIAL_HAZE_RANGE{ 1000.0f };
|
||||||
const float Haze::INITIAL_HAZE_HEIGHT{ 200.0f };
|
const float Haze::INITIAL_HAZE_HEIGHT{ 200.0f };
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// MakeHaze.h
|
// MakeHaze.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Nissim Hadar on 9/13/2017.
|
// Created by Nissim Hadar on 9/13/2017.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
#include "Transform.h"
|
#include "Transform.h"
|
||||||
#include "NumericalConstants.h"
|
#include "NumericalConstants.h"
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
// Haze range is defined here as the range the visibility is reduced by 95%
|
// 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%
|
// Haze altitude is defined here as the altitude (above 0) that the haze is reduced by 95%
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Light.cpp
|
// Light.cpp
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 1/26/2014.
|
// Created by Sam Gateau on 1/26/2014.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
//
|
//
|
||||||
#include "Light.h"
|
#include "Light.h"
|
||||||
|
|
||||||
using namespace model;
|
using namespace graphics;
|
||||||
|
|
||||||
Light::Light() {
|
Light::Light() {
|
||||||
updateLightRadius();
|
updateLightRadius();
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Light.h
|
// Light.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 12/10/2014.
|
// Created by Sam Gateau on 12/10/2014.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
#include "gpu/Resource.h"
|
#include "gpu/Resource.h"
|
||||||
#include "gpu/Texture.h"
|
#include "gpu/Texture.h"
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
typedef gpu::BufferView UniformBufferView;
|
typedef gpu::BufferView UniformBufferView;
|
||||||
typedef gpu::TextureView TextureView;
|
typedef gpu::TextureView TextureView;
|
||||||
typedef glm::vec3 Vec3;
|
typedef glm::vec3 Vec3;
|
|
@ -11,8 +11,8 @@
|
||||||
<@if not MODEL_LIGHT_SLH@>
|
<@if not MODEL_LIGHT_SLH@>
|
||||||
<@def MODEL_LIGHT_SLH@>
|
<@def MODEL_LIGHT_SLH@>
|
||||||
|
|
||||||
<@include model/LightVolume.shared.slh@>
|
<@include graphics/LightVolume.shared.slh@>
|
||||||
<@include model/LightIrradiance.shared.slh@>
|
<@include graphics/LightIrradiance.shared.slh@>
|
||||||
|
|
||||||
// NOw lets define Light
|
// NOw lets define Light
|
||||||
struct Light {
|
struct Light {
|
||||||
|
@ -30,7 +30,7 @@ float getLightIntensity(Light l) { return lightIrradiance_getIntensity(l.irradia
|
||||||
vec3 getLightIrradiance(Light l) { return lightIrradiance_getIrradiance(l.irradiance); }
|
vec3 getLightIrradiance(Light l) { return lightIrradiance_getIrradiance(l.irradiance); }
|
||||||
|
|
||||||
// AMbient lighting needs extra info provided from a different Buffer
|
// AMbient lighting needs extra info provided from a different Buffer
|
||||||
<@include model/SphericalHarmonics.shared.slh@>
|
<@include graphics/SphericalHarmonics.shared.slh@>
|
||||||
// Light Ambient
|
// Light Ambient
|
||||||
struct LightAmbient {
|
struct LightAmbient {
|
||||||
vec4 _ambient;
|
vec4 _ambient;
|
|
@ -3,7 +3,7 @@
|
||||||
#define LightVolume_Shared_slh
|
#define LightVolume_Shared_slh
|
||||||
|
|
||||||
// Light.shared.slh
|
// Light.shared.slh
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 14/9/2016.
|
// Created by Sam Gateau on 14/9/2016.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Material.cpp
|
// Material.cpp
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 12/10/2014.
|
// Created by Sam Gateau on 12/10/2014.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include "TextureMap.h"
|
#include "TextureMap.h"
|
||||||
|
|
||||||
using namespace model;
|
using namespace graphics;
|
||||||
using namespace gpu;
|
using namespace gpu;
|
||||||
|
|
||||||
Material::Material() :
|
Material::Material() :
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Material.h
|
// Material.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 12/10/2014.
|
// Created by Sam Gateau on 12/10/2014.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include <gpu/Resource.h>
|
#include <gpu/Resource.h>
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
|
|
||||||
class TextureMap;
|
class TextureMap;
|
||||||
typedef std::shared_ptr< TextureMap > TextureMapPointer;
|
typedef std::shared_ptr< TextureMap > TextureMapPointer;
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Skybox.cpp
|
// Skybox.cpp
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 5/4/2015.
|
// Created by Sam Gateau on 5/4/2015.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
#include "skybox_vert.h"
|
#include "skybox_vert.h"
|
||||||
#include "skybox_frag.h"
|
#include "skybox_frag.h"
|
||||||
|
|
||||||
using namespace model;
|
using namespace graphics;
|
||||||
|
|
||||||
Skybox::Skybox() {
|
Skybox::Skybox() {
|
||||||
Schema schema;
|
Schema schema;
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Skybox.h
|
// Skybox.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 5/4/2015.
|
// Created by Sam Gateau on 5/4/2015.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
@ -19,7 +19,7 @@ class ViewFrustum;
|
||||||
|
|
||||||
namespace gpu { class Batch; }
|
namespace gpu { class Batch; }
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
|
|
||||||
typedef glm::vec3 Color;
|
typedef glm::vec3 Color;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#define SphericalHarmonics_Shared_slh
|
#define SphericalHarmonics_Shared_slh
|
||||||
|
|
||||||
// SphericalHarmonics.shared.slh
|
// SphericalHarmonics.shared.slh
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 14/9/2016.
|
// Created by Sam Gateau on 14/9/2016.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Stage.cpp
|
// Stage.cpp
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 2/24/2015.
|
// Created by Sam Gateau on 2/24/2015.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
#include <qcompilerdetection.h>
|
#include <qcompilerdetection.h>
|
||||||
#include <ComponentMode.h>
|
#include <ComponentMode.h>
|
||||||
|
|
||||||
using namespace model;
|
using namespace graphics;
|
||||||
|
|
||||||
|
|
||||||
void EarthSunModel::updateAll() const {
|
void EarthSunModel::updateAll() const {
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Stage.h
|
// Stage.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 2/24/2015.
|
// Created by Sam Gateau on 2/24/2015.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
#include "Light.h"
|
#include "Light.h"
|
||||||
#include "Skybox.h"
|
#include "Skybox.h"
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
|
|
||||||
typedef glm::dvec3 Vec3d;
|
typedef glm::dvec3 Vec3d;
|
||||||
typedef glm::dvec4 Vec4d;
|
typedef glm::dvec4 Vec4d;
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// TextureMap.cpp
|
// TextureMap.cpp
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 5/6/2015.
|
// Created by Sam Gateau on 5/6/2015.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
//
|
//
|
||||||
#include "TextureMap.h"
|
#include "TextureMap.h"
|
||||||
|
|
||||||
using namespace model;
|
using namespace graphics;
|
||||||
using namespace gpu;
|
using namespace gpu;
|
||||||
|
|
||||||
void TextureMap::setTextureSource(TextureSourcePointer& textureSource) {
|
void TextureMap::setTextureSource(TextureSourcePointer& textureSource) {
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// TextureMap.h
|
// TextureMap.h
|
||||||
// libraries/model/src/model
|
// libraries/graphics/src/graphics
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 5/6/2015.
|
// Created by Sam Gateau on 5/6/2015.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "Transform.h"
|
#include "Transform.h"
|
||||||
|
|
||||||
namespace model {
|
namespace graphics {
|
||||||
|
|
||||||
class TextureMap {
|
class TextureMap {
|
||||||
public:
|
public:
|
|
@ -1,4 +1,4 @@
|
||||||
set(TARGET_NAME model-networking)
|
set(TARGET_NAME model-networking)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared networking model fbx ktx image)
|
link_hifi_libraries(shared networking graphics fbx ktx image)
|
||||||
include_hifi_library_headers(gpu)
|
include_hifi_library_headers(gpu)
|
||||||
|
|
|
@ -516,13 +516,13 @@ QUrl NetworkMaterial::getTextureUrl(const QUrl& baseUrl, const FBXTexture& textu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& baseUrl, const FBXTexture& fbxTexture,
|
graphics::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& baseUrl, const FBXTexture& fbxTexture,
|
||||||
image::TextureUsage::Type type, MapChannel channel) {
|
image::TextureUsage::Type type, MapChannel channel) {
|
||||||
const auto url = getTextureUrl(baseUrl, fbxTexture);
|
const auto url = getTextureUrl(baseUrl, fbxTexture);
|
||||||
const auto texture = DependencyManager::get<TextureCache>()->getTexture(url, type, fbxTexture.content, fbxTexture.maxNumPixels);
|
const auto texture = DependencyManager::get<TextureCache>()->getTexture(url, type, fbxTexture.content, fbxTexture.maxNumPixels);
|
||||||
_textures[channel] = Texture { fbxTexture.name, texture };
|
_textures[channel] = Texture { fbxTexture.name, texture };
|
||||||
|
|
||||||
auto map = std::make_shared<model::TextureMap>();
|
auto map = std::make_shared<graphics::TextureMap>();
|
||||||
if (texture) {
|
if (texture) {
|
||||||
map->setTextureSource(texture->_textureSource);
|
map->setTextureSource(texture->_textureSource);
|
||||||
}
|
}
|
||||||
|
@ -531,18 +531,18 @@ model::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& baseUrl, c
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
model::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& url, image::TextureUsage::Type type, MapChannel channel) {
|
graphics::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& url, image::TextureUsage::Type type, MapChannel channel) {
|
||||||
const auto texture = DependencyManager::get<TextureCache>()->getTexture(url, type);
|
const auto texture = DependencyManager::get<TextureCache>()->getTexture(url, type);
|
||||||
_textures[channel].texture = texture;
|
_textures[channel].texture = texture;
|
||||||
|
|
||||||
auto map = std::make_shared<model::TextureMap>();
|
auto map = std::make_shared<graphics::TextureMap>();
|
||||||
map->setTextureSource(texture->_textureSource);
|
map->setTextureSource(texture->_textureSource);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkMaterial::NetworkMaterial(const FBXMaterial& material, const QUrl& textureBaseUrl) :
|
NetworkMaterial::NetworkMaterial(const FBXMaterial& material, const QUrl& textureBaseUrl) :
|
||||||
model::Material(*material._material)
|
graphics::Material(*material._material)
|
||||||
{
|
{
|
||||||
_textures = Textures(MapChannel::NUM_MAP_CHANNELS);
|
_textures = Textures(MapChannel::NUM_MAP_CHANNELS);
|
||||||
if (!material.albedoTexture.filename.isEmpty()) {
|
if (!material.albedoTexture.filename.isEmpty()) {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
|
|
||||||
#include <model/Material.h>
|
#include <graphics/Material.h>
|
||||||
#include <model/Asset.h>
|
#include <graphics/Asset.h>
|
||||||
|
|
||||||
#include "FBXReader.h"
|
#include "FBXReader.h"
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
@ -38,7 +38,7 @@ public:
|
||||||
Geometry(const Geometry& geometry);
|
Geometry(const Geometry& geometry);
|
||||||
|
|
||||||
// Immutable over lifetime
|
// Immutable over lifetime
|
||||||
using GeometryMeshes = std::vector<std::shared_ptr<const model::Mesh>>;
|
using GeometryMeshes = std::vector<std::shared_ptr<const graphics::Mesh>>;
|
||||||
using GeometryMeshParts = std::vector<std::shared_ptr<const MeshPart>>;
|
using GeometryMeshParts = std::vector<std::shared_ptr<const MeshPart>>;
|
||||||
|
|
||||||
// Mutable, but must retain structure of vector
|
// Mutable, but must retain structure of vector
|
||||||
|
@ -157,9 +157,9 @@ private:
|
||||||
virtual ~ModelCache() = default;
|
virtual ~ModelCache() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NetworkMaterial : public model::Material {
|
class NetworkMaterial : public graphics::Material {
|
||||||
public:
|
public:
|
||||||
using MapChannel = model::Material::MapChannel;
|
using MapChannel = graphics::Material::MapChannel;
|
||||||
|
|
||||||
NetworkMaterial(const FBXMaterial& material, const QUrl& textureBaseUrl);
|
NetworkMaterial(const FBXMaterial& material, const QUrl& textureBaseUrl);
|
||||||
|
|
||||||
|
@ -185,9 +185,9 @@ protected:
|
||||||
private:
|
private:
|
||||||
// Helpers for the ctors
|
// Helpers for the ctors
|
||||||
QUrl getTextureUrl(const QUrl& baseUrl, const FBXTexture& fbxTexture);
|
QUrl getTextureUrl(const QUrl& baseUrl, const FBXTexture& fbxTexture);
|
||||||
model::TextureMapPointer fetchTextureMap(const QUrl& baseUrl, const FBXTexture& fbxTexture,
|
graphics::TextureMapPointer fetchTextureMap(const QUrl& baseUrl, const FBXTexture& fbxTexture,
|
||||||
image::TextureUsage::Type type, MapChannel channel);
|
image::TextureUsage::Type type, MapChannel channel);
|
||||||
model::TextureMapPointer fetchTextureMap(const QUrl& url, image::TextureUsage::Type type, MapChannel channel);
|
graphics::TextureMapPointer fetchTextureMap(const QUrl& url, image::TextureUsage::Type type, MapChannel channel);
|
||||||
|
|
||||||
Transform _albedoTransform;
|
Transform _albedoTransform;
|
||||||
Transform _lightmapTransform;
|
Transform _lightmapTransform;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "SimpleMeshProxy.h"
|
#include "SimpleMeshProxy.h"
|
||||||
|
|
||||||
#include <model/Geometry.h>
|
#include <graphics/Geometry.h>
|
||||||
|
|
||||||
MeshPointer SimpleMeshProxy::getMeshPointer() const {
|
MeshPointer SimpleMeshProxy::getMeshPointer() const {
|
||||||
return _mesh;
|
return _mesh;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
#include <model/TextureMap.h>
|
#include <graphics/TextureMap.h>
|
||||||
#include <image/Image.h>
|
#include <image/Image.h>
|
||||||
#include <ktx/KTX.h>
|
#include <ktx/KTX.h>
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,32 @@ const QString INDEX_PATH = "/";
|
||||||
|
|
||||||
const QString GET_PLACE = "/api/v1/places/%1";
|
const QString GET_PLACE = "/api/v1/places/%1";
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* The location API provides facilities related to your current location in the metaverse.
|
||||||
|
*
|
||||||
|
* @namespace location
|
||||||
|
* @property {Uuid} domainId - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid|Uuid.NULL} if you're not
|
||||||
|
* connected to the domain.
|
||||||
|
* <em>Read-only.</em>
|
||||||
|
* @property {string} hostname - The name of the domain for your current metaverse address (e.g., <code>"AvatarIsland"</code>,
|
||||||
|
* <code>localhost</code>, or an IP address).
|
||||||
|
* <em>Read-only.</em>
|
||||||
|
* @property {string} href - Your current metaverse address (e.g., <code>"hifi://avatarisland/15,-10,26/0,0,0,1"</code>)
|
||||||
|
* regardless of whether or not you're connected to the domain.
|
||||||
|
* <em>Read-only.</em>
|
||||||
|
* @property {boolean} isConnected - <code>true</code> if you're connected to the domain in your current <code>href</code>
|
||||||
|
* metaverse address, otherwise <code>false</code>.
|
||||||
|
* <em>Read-only.</em>
|
||||||
|
* @property {string} pathname - The location and orientation in your current <code>href</code> metaverse address
|
||||||
|
* (e.g., <code>"/15,-10,26/0,0,0,1"</code>).
|
||||||
|
* <em>Read-only.</em>
|
||||||
|
* @property {string} placename - The place name in your current <code>href</code> metaverse address
|
||||||
|
* (e.g., <code>"AvatarIsland"</code>). Is blank if your <code>hostname</code> is an IP address.
|
||||||
|
* <em>Read-only.</em>
|
||||||
|
* @property {string} protocol - The protocol of your current <code>href</code> metaverse address (e.g., <code>"hifi"</code>).
|
||||||
|
* <em>Read-only.</em>
|
||||||
|
*/
|
||||||
|
|
||||||
class AddressManager : public QObject, public Dependency {
|
class AddressManager : public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
@ -42,10 +68,77 @@ class AddressManager : public QObject, public Dependency {
|
||||||
Q_PROPERTY(QString placename READ getPlaceName)
|
Q_PROPERTY(QString placename READ getPlaceName)
|
||||||
Q_PROPERTY(QString domainId READ getDomainId)
|
Q_PROPERTY(QString domainId READ getDomainId)
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Get Interface's protocol version.
|
||||||
|
* @function location.protocolVersion
|
||||||
|
* @returns {string} A string uniquely identifying the version of the metaverse protocol that Interface is using.
|
||||||
|
*/
|
||||||
Q_INVOKABLE QString protocolVersion();
|
Q_INVOKABLE QString protocolVersion();
|
||||||
|
|
||||||
using PositionGetter = std::function<glm::vec3()>;
|
using PositionGetter = std::function<glm::vec3()>;
|
||||||
using OrientationGetter = std::function<glm::quat()>;
|
using OrientationGetter = std::function<glm::quat()>;
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* <p>The reasons for an address lookup via the metaverse API are defined by numeric values:</p>
|
||||||
|
* <table>
|
||||||
|
* <thead>
|
||||||
|
* <tr>
|
||||||
|
* <th>Name</th>
|
||||||
|
* <th>Value</th>
|
||||||
|
* <th>Description</th>
|
||||||
|
* </tr>
|
||||||
|
* </thead>
|
||||||
|
* <tbody>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>UserInput</strong></td>
|
||||||
|
* <td><code>0</code></td>
|
||||||
|
* <td>User-typed input.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>Back</strong></td>
|
||||||
|
* <td><code>1</code></td>
|
||||||
|
* <td>Address from a {@link location.goBack|goBack} call.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>Forward</strong></td>
|
||||||
|
* <td><code>2</code></td>
|
||||||
|
* <td>Address from a {@link location.goForward|goForward} call.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>StartupFromSettings</strong></td>
|
||||||
|
* <td><code>3</code></td>
|
||||||
|
* <td>Initial location at Interface start-up from settings.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>DomainPathResponse</strong></td>
|
||||||
|
* <td><code>4</code></td>
|
||||||
|
* <td>A named path in the domain.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>Internal</strong></td>
|
||||||
|
* <td><code>5</code></td>
|
||||||
|
* <td>An internal attempt to resolve an alternative path.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>AttemptedRefresh</strong></td>
|
||||||
|
* <td><code>6</code></td>
|
||||||
|
* <td>A refresh after connecting to a domain.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>Suggestions</strong></td>
|
||||||
|
* <td><code>7</code></td>
|
||||||
|
* <td>Address from the Goto dialog.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td><strong>VisitUserFromPAL</strong></td>
|
||||||
|
* <td><code>8</code></td>
|
||||||
|
* <td>User from the People dialog.</td>
|
||||||
|
* </tr>
|
||||||
|
* </tbody>
|
||||||
|
* </table>
|
||||||
|
* @typedef location.LookupTrigger
|
||||||
|
*/
|
||||||
enum LookupTrigger {
|
enum LookupTrigger {
|
||||||
UserInput,
|
UserInput,
|
||||||
Back,
|
Back,
|
||||||
|
@ -83,43 +176,240 @@ public:
|
||||||
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
/**jsdoc
|
||||||
|
* Go to a specified metaverse address.
|
||||||
|
* @function location.handleLookupString
|
||||||
|
* @param {string} address - The address to go to: a <code>"hifi:/"<code> address, an IP address (e.g.,
|
||||||
|
* <code>"127.0.0.1"</code> or <code>"localhost"</code>), a domain name, a named path on a domain (starts with
|
||||||
|
* <code>"/"</code>), a position or position and orientation, or a user (starts with <code>"@"</code>).
|
||||||
|
* @param {boolean} fromSuggestions=false - Set to <code>true</code> if the address is obtained from the "Goto" dialog.
|
||||||
|
* Helps ensure that user's location history is correctly maintained.
|
||||||
|
*/
|
||||||
void handleLookupString(const QString& lookupString, bool fromSuggestions = false);
|
void handleLookupString(const QString& lookupString, bool fromSuggestions = false);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Go to a position and orientation resulting from a lookup for a named path in the domain (set in the domain server's
|
||||||
|
* settings).
|
||||||
|
* @function location.goToViewpointForPath
|
||||||
|
* @param {string} path - The position and orientation corresponding to the named path.
|
||||||
|
* @param {string} namedPath - The named path that was looked up on the server.
|
||||||
|
* @deprecated This function is deprecated and will be removed.
|
||||||
|
*/
|
||||||
|
// This function is marked as deprecated in anticipation that it will not be included in the JavaScript API if and when the
|
||||||
|
// functions and signals that should be exposed are moved to a scripting interface class.
|
||||||
|
//
|
||||||
// we currently expect this to be called from NodeList once handleLookupString has been called with a path
|
// we currently expect this to be called from NodeList once handleLookupString has been called with a path
|
||||||
bool goToViewpointForPath(const QString& viewpointString, const QString& pathString)
|
bool goToViewpointForPath(const QString& viewpointString, const QString& pathString)
|
||||||
{ return handleViewpoint(viewpointString, false, DomainPathResponse, false, pathString); }
|
{ return handleViewpoint(viewpointString, false, DomainPathResponse, false, pathString); }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Go back to the previous location in your navigation history, if there is one.
|
||||||
|
* @function location.goBack
|
||||||
|
*/
|
||||||
void goBack();
|
void goBack();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Go forward to the next location in your navigation history, if there is one.
|
||||||
|
* @function location.goForward
|
||||||
|
*/
|
||||||
void goForward();
|
void goForward();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Go to the local Sandbox server that's running on the same PC as Interface.
|
||||||
|
* @function location.goToLocalSandbox
|
||||||
|
* @param {string} path="" - The position and orientation to go to (e.g., <code>"/0,0,0"</code>).
|
||||||
|
* @param {location.LookupTrigger} trigger=StartupFromSettings - The reason for the function call. Helps ensure that user's
|
||||||
|
* location history is correctly maintained.
|
||||||
|
*/
|
||||||
void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger); }
|
void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger); }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Go to the default "welcome" metaverse address.
|
||||||
|
* @function location.goToEntry
|
||||||
|
* @param {location.LookupTrigger} trigger=StartupFromSettings - The reason for the function call. Helps ensure that user's
|
||||||
|
* location history is correctly maintained.
|
||||||
|
*/
|
||||||
void goToEntry(LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(DEFAULT_HIFI_ADDRESS, trigger); }
|
void goToEntry(LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(DEFAULT_HIFI_ADDRESS, trigger); }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Go to the specified user's location.
|
||||||
|
* @function location.goToUser
|
||||||
|
* @param {string} username - The user's username.
|
||||||
|
* @param {boolean} matchOrientation=true - If <code>true</code> then go to a location just in front of the user and turn to face
|
||||||
|
* them, otherwise go to the user's exact location and orientation.
|
||||||
|
*/
|
||||||
void goToUser(const QString& username, bool shouldMatchOrientation = true);
|
void goToUser(const QString& username, bool shouldMatchOrientation = true);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Refresh the current address, e.g., after connecting to a domain in order to position the user to the desired location.
|
||||||
|
* @function location.refreshPreviousLookup
|
||||||
|
* @deprecated This function is deprecated and will be removed.
|
||||||
|
*/
|
||||||
|
// This function is marked as deprecated in anticipation that it will not be included in the JavaScript API if and when the
|
||||||
|
// functions and signals that should be exposed are moved to a scripting interface class.
|
||||||
void refreshPreviousLookup();
|
void refreshPreviousLookup();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Update your current metaverse location in Interface's {@link Settings} file as your last-known address. This can be used
|
||||||
|
* to ensure that you start up at that address if you exit Interface without a later address automatically being saved.
|
||||||
|
* @function location.storeCurrentAddress
|
||||||
|
*/
|
||||||
void storeCurrentAddress();
|
void storeCurrentAddress();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Copy your current metaverse address (i.e., <code>location.href</code> property value) to the OS clipboard.
|
||||||
|
* @function location.copyAddress
|
||||||
|
*/
|
||||||
void copyAddress();
|
void copyAddress();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Copy your current metaverse location and orientation (i.e., <code>location.pathname</code> property value) to the OS
|
||||||
|
* clipboard.
|
||||||
|
* @function location.copyPath
|
||||||
|
*/
|
||||||
void copyPath();
|
void copyPath();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Retrieve and remember the place name for the given domain ID if the place name is not already known.
|
||||||
|
* @function location.lookupShareableNameForDomainID
|
||||||
|
* @param {Uuid} domainID - The UUID of the domain.
|
||||||
|
* @deprecated This function is deprecated and will be removed.
|
||||||
|
*/
|
||||||
|
// This function is marked as deprecated in anticipation that it will not be included in the JavaScript API if and when the
|
||||||
|
// functions and signals that should be exposed are moved to a scripting interface class.
|
||||||
void lookupShareableNameForDomainID(const QUuid& domainID);
|
void lookupShareableNameForDomainID(const QUuid& domainID);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when looking up the details of a metaverse user or location to go to has completed (successfully or
|
||||||
|
* unsuccessfully).
|
||||||
|
* @function location.lookupResultsFinished
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
void lookupResultsFinished();
|
void lookupResultsFinished();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when looking up the details of a metaverse user or location to go to has completed and the domain or user is
|
||||||
|
* offline.
|
||||||
|
* @function location.lookupResultIsOffline
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
void lookupResultIsOffline();
|
void lookupResultIsOffline();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when looking up the details of a metaverse user or location to go to has completed and the domain or user could
|
||||||
|
* not be found.
|
||||||
|
* @function location.lookupResultIsNotFound
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
void lookupResultIsNotFound();
|
void lookupResultIsNotFound();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when a request is made to go to an IP address.
|
||||||
|
* @function location.possibleDomainChangeRequired
|
||||||
|
* @param {string} hostName - The name of the domain to go do.
|
||||||
|
* @param {number} port - The integer number of the network port to connect to.
|
||||||
|
* @param {Uuid} domainID - The UUID of the domain to go to.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
// No example because this function isn't typically used in scripts.
|
||||||
void possibleDomainChangeRequired(const QString& newHostname, quint16 newPort, const QUuid& domainID);
|
void possibleDomainChangeRequired(const QString& newHostname, quint16 newPort, const QUuid& domainID);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when a request is made to go to a named domain or user.
|
||||||
|
* @function location.possibleDomainChangeRequiredViaICEForID
|
||||||
|
* @param {string} iceServerHostName - IP address of the ICE server.
|
||||||
|
* @param {Uuid} domainID - The UUID of the domain to go to.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
// No example because this function isn't typically used in scripts.
|
||||||
void possibleDomainChangeRequiredViaICEForID(const QString& iceServerHostname, const QUuid& domainID);
|
void possibleDomainChangeRequiredViaICEForID(const QString& iceServerHostname, const QUuid& domainID);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when an attempt is made to send your avatar to a specified position on the current domain. For example, when
|
||||||
|
* you change domains or enter a position to go to in the "Goto" dialog.
|
||||||
|
* @function location.locationChangeRequired
|
||||||
|
* @param {Vec3} position - The position to go to.
|
||||||
|
* @param {boolean} hasOrientationChange - If <code>true</code> then a new <code>orientation</code> has been requested.
|
||||||
|
* @param {Quat} orientation - The orientation to change to. Is {@link Quat(0)|Quat.IDENTITY} if
|
||||||
|
* <code>hasOrientationChange</code> is <code>false</code>.
|
||||||
|
* @param {boolean} shouldFaceLocation - If <code>true</code> then the request is to go to a position near that specified
|
||||||
|
* and orient your avatar to face it. For example when you visit someone from the "People" dialog.
|
||||||
|
* @returns {Signal}
|
||||||
|
* @example <caption>Report location change requests.</caption>
|
||||||
|
* function onLocationChangeRequired(newPosition, hasOrientationChange, newOrientation, shouldFaceLocation) {
|
||||||
|
* print("Location change required:");
|
||||||
|
* print("- New position = " + JSON.stringify(newPosition));
|
||||||
|
* print("- Has orientation change = " + hasOrientationChange);
|
||||||
|
* print("- New orientation = " + JSON.stringify(newOrientation));
|
||||||
|
* print("- Should face location = " + shouldFaceLocation);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* location.locationChangeRequired.connect(onLocationChangeRequired);
|
||||||
|
*/
|
||||||
void locationChangeRequired(const glm::vec3& newPosition,
|
void locationChangeRequired(const glm::vec3& newPosition,
|
||||||
bool hasOrientationChange, const glm::quat& newOrientation,
|
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||||
bool shouldFaceLocation);
|
bool shouldFaceLocation);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when an attempt is made to send your avatar to a new named path on the domain (set in the domain server's
|
||||||
|
* settings). For example, when you enter a "/" followed by the path's name in the "GOTO" dialog.
|
||||||
|
* @function location.pathChangeRequired
|
||||||
|
* @param {string} path - The name of the path to go to.
|
||||||
|
* @returns {Signal}
|
||||||
|
* @example <caption>Report path change requests.</caption>
|
||||||
|
* function onPathChangeRequired(newPath) {
|
||||||
|
* print("onPathChangeRequired: newPath = " + newPath);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* location.pathChangeRequired.connect(onPathChangeRequired);
|
||||||
|
*/
|
||||||
void pathChangeRequired(const QString& newPath);
|
void pathChangeRequired(const QString& newPath);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when you navigate to a new domain.
|
||||||
|
* @function location.hostChanged
|
||||||
|
* @param {string} hostname - The new domain's host name.
|
||||||
|
* @returns {Signal}
|
||||||
|
* @example <caption>Report when you navigate to a new domain.</caption>
|
||||||
|
* function onHostChanged(host) {
|
||||||
|
* print("Host changed to: " + host);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* location.hostChanged.connect(onHostChanged);
|
||||||
|
*/
|
||||||
void hostChanged(const QString& newHost);
|
void hostChanged(const QString& newHost);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when there's a change in whether or not there's a previous location that can be navigated to using
|
||||||
|
* {@link location.goBack|goBack}. (Reflects changes in the state of the "Goto" dialog's back arrow.)
|
||||||
|
* @function location.goBackPossible
|
||||||
|
* @param {boolean} isPossible - <code>true</code> if there's a previous location to navigate to, otherwise
|
||||||
|
* <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
* @example <caption>Report when ability to navigate back changes.</caption>
|
||||||
|
* function onGoBackPossible(isPossible) {
|
||||||
|
* print("Go back possible: " + isPossible);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* location.goBackPossible.connect(onGoBackPossible);
|
||||||
|
*/
|
||||||
void goBackPossible(bool isPossible);
|
void goBackPossible(bool isPossible);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when there's a change in whether or not there's a forward location that can be navigated to using
|
||||||
|
* {@link location.goForward|goForward}. (Reflects changes in the state of the "Goto" dialog's forward arrow.)
|
||||||
|
* @function location.goForwardPossible
|
||||||
|
* @param {boolean} isPossible - <code>true</code> if there's a forward location to navigate to, otherwise
|
||||||
|
* <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
* @example <caption>Report when ability to navigate forward changes.</caption>
|
||||||
|
* function onGoForwardPossible(isPossible) {
|
||||||
|
* print("Go forward possible: " + isPossible);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* location.goForwardPossible.connect(onGoForwardPossible);
|
||||||
|
*/
|
||||||
void goForwardPossible(bool isPossible);
|
void goForwardPossible(bool isPossible);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -437,7 +437,7 @@ void NodeList::sendPendingDSPathQuery() {
|
||||||
QString pendingPath = _domainHandler.getPendingPath();
|
QString pendingPath = _domainHandler.getPendingPath();
|
||||||
|
|
||||||
if (!pendingPath.isEmpty()) {
|
if (!pendingPath.isEmpty()) {
|
||||||
qCDebug(networking) << "Attemping to send pending query to DS for path" << pendingPath;
|
qCDebug(networking) << "Attempting to send pending query to DS for path" << pendingPath;
|
||||||
|
|
||||||
// this is a slot triggered if we just established a network link with a DS and want to send a path query
|
// this is a slot triggered if we just established a network link with a DS and want to send a path query
|
||||||
sendDSPathQuery(_domainHandler.getPendingPath());
|
sendDSPathQuery(_domainHandler.getPendingPath());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
set(TARGET_NAME physics)
|
set(TARGET_NAME physics)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared fbx entities model)
|
link_hifi_libraries(shared fbx entities graphics)
|
||||||
include_hifi_library_headers(networking)
|
include_hifi_library_headers(networking)
|
||||||
include_hifi_library_headers(gpu)
|
include_hifi_library_headers(gpu)
|
||||||
include_hifi_library_headers(avatars)
|
include_hifi_library_headers(avatars)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
const int32_t MAX_HULL_INDICES = 6 * MAX_HULL_POINTS;
|
const int32_t MAX_HULL_INDICES = 6 * MAX_HULL_POINTS;
|
||||||
const int32_t MAX_HULL_NORMALS = MAX_HULL_INDICES;
|
const int32_t MAX_HULL_NORMALS = MAX_HULL_INDICES;
|
||||||
float tempVertices[MAX_HULL_NORMALS];
|
float tempVertices[MAX_HULL_NORMALS];
|
||||||
model::Index tempIndexBuffer[MAX_HULL_INDICES];
|
graphics::Index tempIndexBuffer[MAX_HULL_INDICES];
|
||||||
|
|
||||||
bool copyShapeToMesh(const btTransform& transform, const btConvexShape* shape,
|
bool copyShapeToMesh(const btTransform& transform, const btConvexShape* shape,
|
||||||
gpu::BufferView& vertices, gpu::BufferView& indices, gpu::BufferView& parts,
|
gpu::BufferView& vertices, gpu::BufferView& indices, gpu::BufferView& parts,
|
||||||
|
@ -40,21 +40,21 @@ bool copyShapeToMesh(const btTransform& transform, const btConvexShape* shape,
|
||||||
assert(numHullVertices <= MAX_HULL_POINTS);
|
assert(numHullVertices <= MAX_HULL_POINTS);
|
||||||
|
|
||||||
{ // new part
|
{ // new part
|
||||||
model::Mesh::Part part;
|
graphics::Mesh::Part part;
|
||||||
part._startIndex = (model::Index)indices.getNumElements();
|
part._startIndex = (graphics::Index)indices.getNumElements();
|
||||||
part._numIndices = (model::Index)numHullIndices;
|
part._numIndices = (graphics::Index)numHullIndices;
|
||||||
// FIXME: the render code cannot handle the case where part._baseVertex != 0
|
// FIXME: the render code cannot handle the case where part._baseVertex != 0
|
||||||
//part._baseVertex = vertices.getNumElements(); // DOES NOT WORK
|
//part._baseVertex = vertices.getNumElements(); // DOES NOT WORK
|
||||||
part._baseVertex = 0;
|
part._baseVertex = 0;
|
||||||
|
|
||||||
gpu::BufferView::Size numBytes = sizeof(model::Mesh::Part);
|
gpu::BufferView::Size numBytes = sizeof(graphics::Mesh::Part);
|
||||||
const gpu::Byte* data = reinterpret_cast<const gpu::Byte*>(&part);
|
const gpu::Byte* data = reinterpret_cast<const gpu::Byte*>(&part);
|
||||||
parts._buffer->append(numBytes, data);
|
parts._buffer->append(numBytes, data);
|
||||||
parts._size = parts._buffer->getSize();
|
parts._size = parts._buffer->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int32_t SIZE_OF_VEC3 = 3 * sizeof(float);
|
const int32_t SIZE_OF_VEC3 = 3 * sizeof(float);
|
||||||
model::Index indexOffset = (model::Index)vertices.getNumElements();
|
graphics::Index indexOffset = (graphics::Index)vertices.getNumElements();
|
||||||
|
|
||||||
{ // new indices
|
{ // new indices
|
||||||
const uint32_t* hullIndices = hull.getIndexPointer();
|
const uint32_t* hullIndices = hull.getIndexPointer();
|
||||||
|
@ -64,7 +64,7 @@ bool copyShapeToMesh(const btTransform& transform, const btConvexShape* shape,
|
||||||
tempIndexBuffer[i] = hullIndices[i] + indexOffset;
|
tempIndexBuffer[i] = hullIndices[i] + indexOffset;
|
||||||
}
|
}
|
||||||
const gpu::Byte* data = reinterpret_cast<const gpu::Byte*>(tempIndexBuffer);
|
const gpu::Byte* data = reinterpret_cast<const gpu::Byte*>(tempIndexBuffer);
|
||||||
gpu::BufferView::Size numBytes = (gpu::BufferView::Size)(sizeof(model::Index) * numHullIndices);
|
gpu::BufferView::Size numBytes = (gpu::BufferView::Size)(sizeof(graphics::Index) * numHullIndices);
|
||||||
indices._buffer->append(numBytes, data);
|
indices._buffer->append(numBytes, data);
|
||||||
indices._size = indices._buffer->getSize();
|
indices._size = indices._buffer->getSize();
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,8 @@ bool copyShapeToMesh(const btTransform& transform, const btConvexShape* shape,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
model::MeshPointer createMeshFromShape(const void* pointer) {
|
graphics::MeshPointer createMeshFromShape(const void* pointer) {
|
||||||
model::MeshPointer mesh;
|
graphics::MeshPointer mesh;
|
||||||
if (!pointer) {
|
if (!pointer) {
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ model::MeshPointer createMeshFromShape(const void* pointer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (numSuccesses > 0) {
|
if (numSuccesses > 0) {
|
||||||
mesh = std::make_shared<model::Mesh>();
|
mesh = std::make_shared<graphics::Mesh>();
|
||||||
mesh->setVertexBuffer(vertices);
|
mesh->setVertexBuffer(vertices);
|
||||||
mesh->setIndexBuffer(indices);
|
mesh->setIndexBuffer(indices);
|
||||||
mesh->setPartBuffer(parts);
|
mesh->setPartBuffer(parts);
|
||||||
|
@ -167,8 +167,8 @@ CollisionRenderMeshCache::~CollisionRenderMeshCache() {
|
||||||
_pendingGarbage.clear();
|
_pendingGarbage.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
model::MeshPointer CollisionRenderMeshCache::getMesh(CollisionRenderMeshCache::Key key) {
|
graphics::MeshPointer CollisionRenderMeshCache::getMesh(CollisionRenderMeshCache::Key key) {
|
||||||
model::MeshPointer mesh;
|
graphics::MeshPointer mesh;
|
||||||
if (key) {
|
if (key) {
|
||||||
CollisionMeshMap::const_iterator itr = _meshMap.find(key);
|
CollisionMeshMap::const_iterator itr = _meshMap.find(key);
|
||||||
if (itr == _meshMap.end()) {
|
if (itr == _meshMap.end()) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <model/Geometry.h>
|
#include <graphics/Geometry.h>
|
||||||
|
|
||||||
|
|
||||||
class CollisionRenderMeshCache {
|
class CollisionRenderMeshCache {
|
||||||
|
@ -27,7 +27,7 @@ public:
|
||||||
~CollisionRenderMeshCache();
|
~CollisionRenderMeshCache();
|
||||||
|
|
||||||
/// \return pointer to geometry
|
/// \return pointer to geometry
|
||||||
model::MeshPointer getMesh(Key key);
|
graphics::MeshPointer getMesh(Key key);
|
||||||
|
|
||||||
/// \return true if geometry was found and released
|
/// \return true if geometry was found and released
|
||||||
bool releaseMesh(Key key);
|
bool releaseMesh(Key key);
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
bool hasMesh(Key key) const { return _meshMap.find(key) == _meshMap.end(); }
|
bool hasMesh(Key key) const { return _meshMap.find(key) == _meshMap.end(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using CollisionMeshMap = std::unordered_map<Key, model::MeshPointer>;
|
using CollisionMeshMap = std::unordered_map<Key, graphics::MeshPointer>;
|
||||||
CollisionMeshMap _meshMap;
|
CollisionMeshMap _meshMap;
|
||||||
std::vector<Key> _pendingGarbage;
|
std::vector<Key> _pendingGarbage;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
set(TARGET_NAME procedural)
|
set(TARGET_NAME procedural)
|
||||||
AUTOSCRIBE_SHADER_LIB(gpu model)
|
AUTOSCRIBE_SHADER_LIB(gpu graphics)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared gpu networking model model-networking ktx image)
|
link_hifi_libraries(shared gpu networking graphics model-networking ktx image)
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
#include <gpu/Context.h>
|
#include <gpu/Context.h>
|
||||||
#include <ViewFrustum.h>
|
#include <ViewFrustum.h>
|
||||||
|
|
||||||
#include <model/skybox_vert.h>
|
#include <graphics/skybox_vert.h>
|
||||||
#include <model/skybox_frag.h>
|
#include <graphics/skybox_frag.h>
|
||||||
|
|
||||||
ProceduralSkybox::ProceduralSkybox() : model::Skybox() {
|
ProceduralSkybox::ProceduralSkybox() : graphics::Skybox() {
|
||||||
_procedural._vertexSource = skybox_vert;
|
_procedural._vertexSource = skybox_vert;
|
||||||
_procedural._fragmentSource = skybox_frag;
|
_procedural._fragmentSource = skybox_frag;
|
||||||
// Adjust the pipeline state for background using the stencil test
|
// Adjust the pipeline state for background using the stencil test
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
#ifndef hifi_ProceduralSkybox_h
|
#ifndef hifi_ProceduralSkybox_h
|
||||||
#define hifi_ProceduralSkybox_h
|
#define hifi_ProceduralSkybox_h
|
||||||
|
|
||||||
#include <model/Skybox.h>
|
#include <graphics/Skybox.h>
|
||||||
|
|
||||||
#include "Procedural.h"
|
#include "Procedural.h"
|
||||||
|
|
||||||
class ProceduralSkybox: public model::Skybox {
|
class ProceduralSkybox: public graphics::Skybox {
|
||||||
public:
|
public:
|
||||||
ProceduralSkybox();
|
ProceduralSkybox();
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
set(TARGET_NAME render-utils)
|
set(TARGET_NAME render-utils)
|
||||||
AUTOSCRIBE_SHADER_LIB(gpu model render)
|
AUTOSCRIBE_SHADER_LIB(gpu graphics render)
|
||||||
# pull in the resources.qrc file
|
# pull in the resources.qrc file
|
||||||
qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc")
|
qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc")
|
||||||
setup_hifi_library(Widgets OpenGL Network Qml Quick Script)
|
setup_hifi_library(Widgets OpenGL Network Qml Quick Script)
|
||||||
link_hifi_libraries(shared ktx gpu model model-networking render animation fbx image procedural)
|
link_hifi_libraries(shared ktx gpu graphics model-networking render animation fbx image procedural)
|
||||||
include_hifi_library_headers(networking)
|
include_hifi_library_headers(networking)
|
||||||
include_hifi_library_headers(octree)
|
include_hifi_library_headers(octree)
|
||||||
include_hifi_library_headers(audio)
|
include_hifi_library_headers(audio)
|
||||||
|
|
|
@ -64,8 +64,8 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
|
||||||
auto backgroundStage = renderContext->_scene->getStage<BackgroundStage>();
|
auto backgroundStage = renderContext->_scene->getStage<BackgroundStage>();
|
||||||
assert(backgroundStage);
|
assert(backgroundStage);
|
||||||
|
|
||||||
model::SunSkyStagePointer background;
|
graphics::SunSkyStagePointer background;
|
||||||
model::SkyboxPointer skybox;
|
graphics::SkyboxPointer skybox;
|
||||||
if (backgroundStage->_currentFrame._backgrounds.size()) {
|
if (backgroundStage->_currentFrame._backgrounds.size()) {
|
||||||
auto backgroundId = backgroundStage->_currentFrame._backgrounds.front();
|
auto backgroundId = backgroundStage->_currentFrame._backgrounds.front();
|
||||||
auto background = backgroundStage->getBackground(backgroundId);
|
auto background = backgroundStage->getBackground(backgroundId);
|
||||||
|
@ -76,7 +76,7 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
|
||||||
/* auto backgroundMode = skyStage->getBackgroundMode();
|
/* auto backgroundMode = skyStage->getBackgroundMode();
|
||||||
|
|
||||||
switch (backgroundMode) {
|
switch (backgroundMode) {
|
||||||
case model::SunSkyStage::SKY_DEFAULT: {
|
case graphics::SunSkyStage::SKY_DEFAULT: {
|
||||||
auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
|
auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
|
||||||
auto sceneKeyLight = scene->getKeyLight();
|
auto sceneKeyLight = scene->getKeyLight();
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
|
||||||
// fall through: render a skybox (if available), or the defaults (if requested)
|
// fall through: render a skybox (if available), or the defaults (if requested)
|
||||||
}
|
}
|
||||||
|
|
||||||
case model::SunSkyStage::SKY_BOX: {*/
|
case graphics::SunSkyStage::SKY_BOX: {*/
|
||||||
if (skybox && !skybox->empty()) {
|
if (skybox && !skybox->empty()) {
|
||||||
PerformanceTimer perfTimer("skybox");
|
PerformanceTimer perfTimer("skybox");
|
||||||
auto args = renderContext->args;
|
auto args = renderContext->args;
|
||||||
|
@ -118,7 +118,7 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
|
||||||
// fall through: render defaults (if requested)
|
// fall through: render defaults (if requested)
|
||||||
// }
|
// }
|
||||||
/*
|
/*
|
||||||
case model::SunSkyStage::SKY_DEFAULT_AMBIENT_TEXTURE: {
|
case graphics::SunSkyStage::SKY_DEFAULT_AMBIENT_TEXTURE: {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::DefaultSkybox)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::DefaultSkybox)) {
|
||||||
auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
|
auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
|
||||||
auto sceneKeyLight = scene->getKeyLight();
|
auto sceneKeyLight = scene->getKeyLight();
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#ifndef hifi_render_utils_BackgroundStage_h
|
#ifndef hifi_render_utils_BackgroundStage_h
|
||||||
#define hifi_render_utils_BackgroundStage_h
|
#define hifi_render_utils_BackgroundStage_h
|
||||||
|
|
||||||
#include <model/Stage.h>
|
#include <graphics/Stage.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <render/IndexedContainer.h>
|
#include <render/IndexedContainer.h>
|
||||||
|
@ -30,8 +30,8 @@ public:
|
||||||
static const Index INVALID_INDEX;
|
static const Index INVALID_INDEX;
|
||||||
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
||||||
|
|
||||||
using BackgroundPointer = model::SunSkyStagePointer;
|
using BackgroundPointer = graphics::SunSkyStagePointer;
|
||||||
using Backgrounds = render::indexed_container::IndexedPointerVector<model::SunSkyStage>;
|
using Backgrounds = render::indexed_container::IndexedPointerVector<graphics::SunSkyStage>;
|
||||||
using BackgroundMap = std::unordered_map<BackgroundPointer, Index>;
|
using BackgroundMap = std::unordered_map<BackgroundPointer, Index>;
|
||||||
|
|
||||||
using BackgroundIndices = std::vector<Index>;
|
using BackgroundIndices = std::vector<Index>;
|
||||||
|
|
|
@ -46,6 +46,15 @@ struct DeferredFragment {
|
||||||
float depthVal;
|
float depthVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
<@if not GETFRESNEL0@>
|
||||||
|
<@def GETFRESNEL0@>
|
||||||
|
vec3 getFresnelF0(float metallic, vec3 metalF0) {
|
||||||
|
// Enable continuous metallness value by lerping between dielectric
|
||||||
|
// and metal fresnel F0 value based on the "metallic" parameter
|
||||||
|
return mix(vec3(0.03), metalF0, metallic);
|
||||||
|
}
|
||||||
|
<@endif@>
|
||||||
|
|
||||||
DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
|
DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
|
||||||
vec4 normalVal;
|
vec4 normalVal;
|
||||||
vec4 diffuseVal;
|
vec4 diffuseVal;
|
||||||
|
@ -73,13 +82,7 @@ DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
|
||||||
frag.scattering = specularVal.x;
|
frag.scattering = specularVal.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frag.metallic <= 0.5) {
|
frag.fresnel = getFresnelF0(frag.metallic, diffuseVal.xyz);
|
||||||
frag.metallic = 0.0;
|
|
||||||
frag.fresnel = vec3(0.03); // Default Di-electric fresnel value
|
|
||||||
} else {
|
|
||||||
frag.fresnel = vec3(diffuseVal.xyz);
|
|
||||||
frag.metallic = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return frag;
|
return frag;
|
||||||
}
|
}
|
||||||
|
@ -106,14 +109,7 @@ DeferredFragment unpackDeferredFragmentNoPositionNoAmbient(vec2 texcoord) {
|
||||||
//frag.emissive = specularVal.xyz;
|
//frag.emissive = specularVal.xyz;
|
||||||
frag.obscurance = 1.0;
|
frag.obscurance = 1.0;
|
||||||
|
|
||||||
|
frag.fresnel = getFresnelF0(frag.metallic, diffuseVal.xyz);
|
||||||
if (frag.metallic <= 0.5) {
|
|
||||||
frag.metallic = 0.0;
|
|
||||||
frag.fresnel = vec3(0.03); // Default Di-electric fresnel value
|
|
||||||
} else {
|
|
||||||
frag.fresnel = vec3(diffuseVal.xyz);
|
|
||||||
frag.metallic = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return frag;
|
return frag;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<@if not DEFERRED_GLOBAL_LIGHT_SLH@>
|
<@if not DEFERRED_GLOBAL_LIGHT_SLH@>
|
||||||
<@def DEFERRED_GLOBAL_LIGHT_SLH@>
|
<@def DEFERRED_GLOBAL_LIGHT_SLH@>
|
||||||
|
|
||||||
<@include model/Light.slh@>
|
<@include graphics/Light.slh@>
|
||||||
|
|
||||||
<@include LightingModel.slh@>
|
<@include LightingModel.slh@>
|
||||||
<$declareLightBuffer()$>
|
<$declareLightBuffer()$>
|
||||||
|
@ -65,10 +65,12 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
|
||||||
|
|
||||||
<$prepareGlobalLight($supportScattering$)$>
|
<$prepareGlobalLight($supportScattering$)$>
|
||||||
|
|
||||||
|
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||||
|
|
||||||
// Ambient
|
// Ambient
|
||||||
vec3 ambientDiffuse;
|
vec3 ambientDiffuse;
|
||||||
vec3 ambientSpecular;
|
vec3 ambientSpecular;
|
||||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance
|
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@> );
|
<@endif@> );
|
||||||
|
@ -79,7 +81,7 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
|
||||||
// Directional
|
// Directional
|
||||||
vec3 directionalDiffuse;
|
vec3 directionalDiffuse;
|
||||||
vec3 directionalSpecular;
|
vec3 directionalSpecular;
|
||||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation
|
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@> );
|
<@endif@> );
|
||||||
|
@ -110,10 +112,12 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
) {
|
) {
|
||||||
<$prepareGlobalLight($supportScattering$)$>
|
<$prepareGlobalLight($supportScattering$)$>
|
||||||
|
|
||||||
|
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||||
|
|
||||||
// Ambient
|
// Ambient
|
||||||
vec3 ambientDiffuse;
|
vec3 ambientDiffuse;
|
||||||
vec3 ambientSpecular;
|
vec3 ambientSpecular;
|
||||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance
|
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
@ -123,7 +127,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
|
|
||||||
vec3 directionalDiffuse;
|
vec3 directionalDiffuse;
|
||||||
vec3 directionalSpecular;
|
vec3 directionalSpecular;
|
||||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation
|
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
@ -174,19 +178,21 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur
|
||||||
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) {
|
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) {
|
||||||
<$prepareGlobalLight()$>
|
<$prepareGlobalLight()$>
|
||||||
|
|
||||||
|
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||||
|
|
||||||
color += emissive * isEmissiveEnabled();
|
color += emissive * isEmissiveEnabled();
|
||||||
|
|
||||||
// Ambient
|
// Ambient
|
||||||
vec3 ambientDiffuse;
|
vec3 ambientDiffuse;
|
||||||
vec3 ambientSpecular;
|
vec3 ambientSpecular;
|
||||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance);
|
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance);
|
||||||
color += ambientDiffuse;
|
color += ambientDiffuse;
|
||||||
color += ambientSpecular / opacity;
|
color += ambientSpecular / opacity;
|
||||||
|
|
||||||
// Directional
|
// Directional
|
||||||
vec3 directionalDiffuse;
|
vec3 directionalDiffuse;
|
||||||
vec3 directionalSpecular;
|
vec3 directionalSpecular;
|
||||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation);
|
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation);
|
||||||
color += directionalDiffuse;
|
color += directionalDiffuse;
|
||||||
color += directionalSpecular / opacity;
|
color += directionalSpecular / opacity;
|
||||||
|
|
||||||
|
@ -199,19 +205,21 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
||||||
{
|
{
|
||||||
<$prepareGlobalLight()$>
|
<$prepareGlobalLight()$>
|
||||||
|
|
||||||
|
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||||
|
|
||||||
color += emissive * isEmissiveEnabled();
|
color += emissive * isEmissiveEnabled();
|
||||||
|
|
||||||
// Ambient
|
// Ambient
|
||||||
vec3 ambientDiffuse;
|
vec3 ambientDiffuse;
|
||||||
vec3 ambientSpecular;
|
vec3 ambientSpecular;
|
||||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance);
|
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance);
|
||||||
color += ambientDiffuse;
|
color += ambientDiffuse;
|
||||||
color += ambientSpecular / opacity;
|
color += ambientSpecular / opacity;
|
||||||
|
|
||||||
// Directional
|
// Directional
|
||||||
vec3 directionalDiffuse;
|
vec3 directionalDiffuse;
|
||||||
vec3 directionalSpecular;
|
vec3 directionalSpecular;
|
||||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation);
|
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation);
|
||||||
color += directionalDiffuse;
|
color += directionalDiffuse;
|
||||||
color += directionalSpecular / opacity;
|
color += directionalSpecular / opacity;
|
||||||
|
|
||||||
|
|
|
@ -106,13 +106,13 @@ void DeferredLightingEffect::init() {
|
||||||
|
|
||||||
void DeferredLightingEffect::setupKeyLightBatch(const RenderArgs* args, gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit) {
|
void DeferredLightingEffect::setupKeyLightBatch(const RenderArgs* args, gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit) {
|
||||||
PerformanceTimer perfTimer("DLE->setupBatch()");
|
PerformanceTimer perfTimer("DLE->setupBatch()");
|
||||||
model::LightPointer keySunLight;
|
graphics::LightPointer keySunLight;
|
||||||
auto lightStage = args->_scene->getStage<LightStage>();
|
auto lightStage = args->_scene->getStage<LightStage>();
|
||||||
if (lightStage) {
|
if (lightStage) {
|
||||||
keySunLight = lightStage->getCurrentKeyLight();
|
keySunLight = lightStage->getCurrentKeyLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
model::LightPointer keyAmbiLight;
|
graphics::LightPointer keyAmbiLight;
|
||||||
if (lightStage) {
|
if (lightStage) {
|
||||||
keyAmbiLight = lightStage->getCurrentAmbientLight();
|
keyAmbiLight = lightStage->getCurrentAmbientLight();
|
||||||
}
|
}
|
||||||
|
@ -232,9 +232,9 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
|
||||||
|
|
||||||
#include <shared/Shapes.h>
|
#include <shared/Shapes.h>
|
||||||
|
|
||||||
model::MeshPointer DeferredLightingEffect::getPointLightMesh() {
|
graphics::MeshPointer DeferredLightingEffect::getPointLightMesh() {
|
||||||
if (!_pointLightMesh) {
|
if (!_pointLightMesh) {
|
||||||
_pointLightMesh = std::make_shared<model::Mesh>();
|
_pointLightMesh = std::make_shared<graphics::Mesh>();
|
||||||
|
|
||||||
// let's use a icosahedron
|
// let's use a icosahedron
|
||||||
auto solid = geometry::icosahedron();
|
auto solid = geometry::icosahedron();
|
||||||
|
@ -259,19 +259,19 @@ model::MeshPointer DeferredLightingEffect::getPointLightMesh() {
|
||||||
delete[] indexData;
|
delete[] indexData;
|
||||||
|
|
||||||
|
|
||||||
std::vector<model::Mesh::Part> parts;
|
std::vector<graphics::Mesh::Part> parts;
|
||||||
parts.push_back(model::Mesh::Part(0, nbIndices, 0, model::Mesh::TRIANGLES));
|
parts.push_back(graphics::Mesh::Part(0, nbIndices, 0, graphics::Mesh::TRIANGLES));
|
||||||
parts.push_back(model::Mesh::Part(0, nbIndices, 0, model::Mesh::LINE_STRIP)); // outline version
|
parts.push_back(graphics::Mesh::Part(0, nbIndices, 0, graphics::Mesh::LINE_STRIP)); // outline version
|
||||||
|
|
||||||
|
|
||||||
_pointLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
_pointLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
||||||
}
|
}
|
||||||
return _pointLightMesh;
|
return _pointLightMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
graphics::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
||||||
if (!_spotLightMesh) {
|
if (!_spotLightMesh) {
|
||||||
_spotLightMesh = std::make_shared<model::Mesh>();
|
_spotLightMesh = std::make_shared<graphics::Mesh>();
|
||||||
|
|
||||||
int slices = 16;
|
int slices = 16;
|
||||||
int rings = 3;
|
int rings = 3;
|
||||||
|
@ -356,12 +356,12 @@ model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
||||||
delete[] indexData;
|
delete[] indexData;
|
||||||
|
|
||||||
|
|
||||||
std::vector<model::Mesh::Part> parts;
|
std::vector<graphics::Mesh::Part> parts;
|
||||||
parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::TRIANGLES));
|
parts.push_back(graphics::Mesh::Part(0, indices, 0, graphics::Mesh::TRIANGLES));
|
||||||
parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::LINE_STRIP)); // outline version
|
parts.push_back(graphics::Mesh::Part(0, indices, 0, graphics::Mesh::LINE_STRIP)); // outline version
|
||||||
|
|
||||||
|
|
||||||
_spotLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
_spotLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
||||||
}
|
}
|
||||||
return _spotLightMesh;
|
return _spotLightMesh;
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
|
||||||
const DeferredFrameTransformPointer& frameTransform,
|
const DeferredFrameTransformPointer& frameTransform,
|
||||||
const DeferredFramebufferPointer& deferredFramebuffer,
|
const DeferredFramebufferPointer& deferredFramebuffer,
|
||||||
const LightingModelPointer& lightingModel,
|
const LightingModelPointer& lightingModel,
|
||||||
const model::HazePointer& haze,
|
const graphics::HazePointer& haze,
|
||||||
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
|
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
|
||||||
const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer,
|
const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer,
|
||||||
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource) {
|
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource) {
|
||||||
|
@ -516,7 +516,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
|
||||||
|
|
||||||
auto keyLight = lightAndShadow.first;
|
auto keyLight = lightAndShadow.first;
|
||||||
|
|
||||||
model::LightPointer keyAmbientLight;
|
graphics::LightPointer keyAmbientLight;
|
||||||
if (lightStage && lightStage->_currentFrame._ambientLights.size()) {
|
if (lightStage && lightStage->_currentFrame._ambientLights.size()) {
|
||||||
keyAmbientLight = lightStage->getLight(lightStage->_currentFrame._ambientLights.front());
|
keyAmbientLight = lightStage->getLight(lightStage->_currentFrame._ambientLights.front());
|
||||||
}
|
}
|
||||||
|
@ -749,12 +749,12 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) {
|
||||||
if (lightStage) {
|
if (lightStage) {
|
||||||
|
|
||||||
// Allocate a default global light directional and ambient
|
// Allocate a default global light directional and ambient
|
||||||
auto lp = std::make_shared<model::Light>();
|
auto lp = std::make_shared<graphics::Light>();
|
||||||
lp->setType(model::Light::SUN);
|
lp->setType(graphics::Light::SUN);
|
||||||
lp->setDirection(glm::vec3(-1.0f));
|
lp->setDirection(glm::vec3(-1.0f));
|
||||||
lp->setColor(glm::vec3(1.0f));
|
lp->setColor(glm::vec3(1.0f));
|
||||||
lp->setIntensity(1.0f);
|
lp->setIntensity(1.0f);
|
||||||
lp->setType(model::Light::SUN);
|
lp->setType(graphics::Light::SUN);
|
||||||
lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset::OLD_TOWN_SQUARE);
|
lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset::OLD_TOWN_SQUARE);
|
||||||
|
|
||||||
lp->setAmbientIntensity(0.5f);
|
lp->setAmbientIntensity(0.5f);
|
||||||
|
@ -776,7 +776,7 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) {
|
||||||
auto backgroundStage = renderContext->_scene->getStage<BackgroundStage>();
|
auto backgroundStage = renderContext->_scene->getStage<BackgroundStage>();
|
||||||
if (backgroundStage) {
|
if (backgroundStage) {
|
||||||
|
|
||||||
auto background = std::make_shared<model::SunSkyStage>();
|
auto background = std::make_shared<graphics::SunSkyStage>();
|
||||||
background->setSkybox(_defaultSkybox);
|
background->setSkybox(_defaultSkybox);
|
||||||
|
|
||||||
// capture deault background
|
// capture deault background
|
||||||
|
@ -791,7 +791,7 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) {
|
||||||
auto hazeStage = renderContext->_scene->getStage<HazeStage>();
|
auto hazeStage = renderContext->_scene->getStage<HazeStage>();
|
||||||
if (hazeStage) {
|
if (hazeStage) {
|
||||||
|
|
||||||
auto haze = std::make_shared<model::Haze>();
|
auto haze = std::make_shared<graphics::Haze>();
|
||||||
|
|
||||||
_defaultHaze = haze;
|
_defaultHaze = haze;
|
||||||
_defaultHazeID = hazeStage->addHaze(_defaultHaze);
|
_defaultHazeID = hazeStage->addHaze(_defaultHaze);
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <NumericalConstants.h>
|
#include <NumericalConstants.h>
|
||||||
|
|
||||||
#include "model/Light.h"
|
#include "graphics/Light.h"
|
||||||
#include "model/Geometry.h"
|
#include "graphics/Geometry.h"
|
||||||
|
|
||||||
#include <procedural/ProceduralSkybox.h>
|
#include <procedural/ProceduralSkybox.h>
|
||||||
|
|
||||||
|
@ -61,10 +61,10 @@ private:
|
||||||
bool _shadowMapEnabled{ false };
|
bool _shadowMapEnabled{ false };
|
||||||
bool _ambientOcclusionEnabled{ false };
|
bool _ambientOcclusionEnabled{ false };
|
||||||
|
|
||||||
model::MeshPointer _pointLightMesh;
|
graphics::MeshPointer _pointLightMesh;
|
||||||
model::MeshPointer getPointLightMesh();
|
graphics::MeshPointer getPointLightMesh();
|
||||||
model::MeshPointer _spotLightMesh;
|
graphics::MeshPointer _spotLightMesh;
|
||||||
model::MeshPointer getSpotLightMesh();
|
graphics::MeshPointer getSpotLightMesh();
|
||||||
|
|
||||||
gpu::PipelinePointer _directionalSkyboxLight;
|
gpu::PipelinePointer _directionalSkyboxLight;
|
||||||
gpu::PipelinePointer _directionalAmbientSphereLight;
|
gpu::PipelinePointer _directionalAmbientSphereLight;
|
||||||
|
@ -121,7 +121,7 @@ public:
|
||||||
const DeferredFrameTransformPointer& frameTransform,
|
const DeferredFrameTransformPointer& frameTransform,
|
||||||
const DeferredFramebufferPointer& deferredFramebuffer,
|
const DeferredFramebufferPointer& deferredFramebuffer,
|
||||||
const LightingModelPointer& lightingModel,
|
const LightingModelPointer& lightingModel,
|
||||||
const model::HazePointer& haze,
|
const graphics::HazePointer& haze,
|
||||||
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
|
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
|
||||||
const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer,
|
const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer,
|
||||||
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource);
|
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource);
|
||||||
|
@ -158,7 +158,7 @@ class RenderDeferred {
|
||||||
public:
|
public:
|
||||||
using Inputs = render::VaryingSet8 <
|
using Inputs = render::VaryingSet8 <
|
||||||
DeferredFrameTransformPointer, DeferredFramebufferPointer, LightingModelPointer, SurfaceGeometryFramebufferPointer,
|
DeferredFrameTransformPointer, DeferredFramebufferPointer, LightingModelPointer, SurfaceGeometryFramebufferPointer,
|
||||||
AmbientOcclusionFramebufferPointer, SubsurfaceScatteringResourcePointer, LightClustersPointer, model::HazePointer>;
|
AmbientOcclusionFramebufferPointer, SubsurfaceScatteringResourcePointer, LightClustersPointer, graphics::HazePointer>;
|
||||||
|
|
||||||
using Config = RenderDeferredConfig;
|
using Config = RenderDeferredConfig;
|
||||||
using JobModel = render::Job::ModelI<RenderDeferred, Inputs, Config>;
|
using JobModel = render::Job::ModelI<RenderDeferred, Inputs, Config>;
|
||||||
|
@ -184,13 +184,13 @@ public:
|
||||||
void run(const render::RenderContextPointer& renderContext);
|
void run(const render::RenderContextPointer& renderContext);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
model::LightPointer _defaultLight;
|
graphics::LightPointer _defaultLight;
|
||||||
LightStage::Index _defaultLightID{ LightStage::INVALID_INDEX };
|
LightStage::Index _defaultLightID{ LightStage::INVALID_INDEX };
|
||||||
model::SunSkyStagePointer _defaultBackground;
|
graphics::SunSkyStagePointer _defaultBackground;
|
||||||
BackgroundStage::Index _defaultBackgroundID{ BackgroundStage::INVALID_INDEX };
|
BackgroundStage::Index _defaultBackgroundID{ BackgroundStage::INVALID_INDEX };
|
||||||
model::HazePointer _defaultHaze{ nullptr };
|
graphics::HazePointer _defaultHaze{ nullptr };
|
||||||
HazeStage::Index _defaultHazeID{ HazeStage::INVALID_INDEX };
|
HazeStage::Index _defaultHazeID{ HazeStage::INVALID_INDEX };
|
||||||
model::SkyboxPointer _defaultSkybox { new ProceduralSkybox() };
|
graphics::SkyboxPointer _defaultSkybox { new ProceduralSkybox() };
|
||||||
gpu::TexturePointer _defaultSkyboxTexture;
|
gpu::TexturePointer _defaultSkyboxTexture;
|
||||||
gpu::TexturePointer _defaultSkyboxAmbientTexture;
|
gpu::TexturePointer _defaultSkyboxAmbientTexture;
|
||||||
};
|
};
|
||||||
|
|
|
@ -78,12 +78,12 @@ void HazeConfig::setHazeBackgroundBlend(const float value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeHaze::MakeHaze() {
|
MakeHaze::MakeHaze() {
|
||||||
_haze = std::make_shared<model::Haze>();
|
_haze = std::make_shared<graphics::Haze>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeHaze::configure(const Config& config) {
|
void MakeHaze::configure(const Config& config) {
|
||||||
_haze->setHazeColor(config.hazeColor);
|
_haze->setHazeColor(config.hazeColor);
|
||||||
_haze->setHazeGlareBlend(model::Haze::convertGlareAngleToPower(config.hazeGlareAngle));
|
_haze->setHazeGlareBlend(graphics::Haze::convertGlareAngleToPower(config.hazeGlareAngle));
|
||||||
|
|
||||||
_haze->setHazeGlareColor(config.hazeGlareColor);
|
_haze->setHazeGlareColor(config.hazeGlareColor);
|
||||||
_haze->setHazeBaseReference(config.hazeBaseReference);
|
_haze->setHazeBaseReference(config.hazeBaseReference);
|
||||||
|
@ -94,16 +94,16 @@ void MakeHaze::configure(const Config& config) {
|
||||||
_haze->setModulateColorActive(config.isModulateColorActive);
|
_haze->setModulateColorActive(config.isModulateColorActive);
|
||||||
_haze->setHazeEnableGlare(config.isHazeEnableGlare);
|
_haze->setHazeEnableGlare(config.isHazeEnableGlare);
|
||||||
|
|
||||||
_haze->setHazeRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(config.hazeRange));
|
_haze->setHazeRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(config.hazeRange));
|
||||||
_haze->setHazeAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight));
|
_haze->setHazeAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight));
|
||||||
|
|
||||||
_haze->setHazeKeyLightRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange));
|
_haze->setHazeKeyLightRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange));
|
||||||
_haze->setHazeKeyLightAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude));
|
_haze->setHazeKeyLightAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude));
|
||||||
|
|
||||||
_haze->setHazeBackgroundBlend(config.hazeBackgroundBlend);
|
_haze->setHazeBackgroundBlend(config.hazeBackgroundBlend);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeHaze::run(const render::RenderContextPointer& renderContext, model::HazePointer& haze) {
|
void MakeHaze::run(const render::RenderContextPointer& renderContext, graphics::HazePointer& haze) {
|
||||||
haze = _haze;
|
haze = _haze;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
|
||||||
|
|
||||||
auto hazeStage = args->_scene->getStage<HazeStage>();
|
auto hazeStage = args->_scene->getStage<HazeStage>();
|
||||||
if (hazeStage && hazeStage->_currentFrame._hazes.size() > 0) {
|
if (hazeStage && hazeStage->_currentFrame._hazes.size() > 0) {
|
||||||
model::HazePointer hazePointer = hazeStage->getHaze(hazeStage->_currentFrame._hazes.front());
|
graphics::HazePointer hazePointer = hazeStage->getHaze(hazeStage->_currentFrame._hazes.front());
|
||||||
if (hazePointer) {
|
if (hazePointer) {
|
||||||
batch.setUniformBuffer(HazeEffect_ParamsSlot, hazePointer->getHazeParametersBuffer());
|
batch.setUniformBuffer(HazeEffect_ParamsSlot, hazePointer->getHazeParametersBuffer());
|
||||||
} else {
|
} else {
|
||||||
|
@ -181,7 +181,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
|
||||||
|
|
||||||
auto lightStage = args->_scene->getStage<LightStage>();
|
auto lightStage = args->_scene->getStage<LightStage>();
|
||||||
if (lightStage) {
|
if (lightStage) {
|
||||||
model::LightPointer keyLight;
|
graphics::LightPointer keyLight;
|
||||||
keyLight = lightStage->getCurrentKeyLight();
|
keyLight = lightStage->getCurrentKeyLight();
|
||||||
if (keyLight) {
|
if (keyLight) {
|
||||||
batch.setUniformBuffer(HazeEffect_LightingMapSlot, keyLight->getLightSchemaBuffer());
|
batch.setUniformBuffer(HazeEffect_LightingMapSlot, keyLight->getLightSchemaBuffer());
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <gpu/Pipeline.h>
|
#include <gpu/Pipeline.h>
|
||||||
#include <render/Forward.h>
|
#include <render/Forward.h>
|
||||||
#include <render/DrawTask.h>
|
#include <render/DrawTask.h>
|
||||||
#include <model/Haze.h>
|
#include <graphics/Haze.h>
|
||||||
|
|
||||||
#include "SurfaceGeometryPass.h"
|
#include "SurfaceGeometryPass.h"
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ class MakeHazeConfig : public render::Job::Config {
|
||||||
public:
|
public:
|
||||||
MakeHazeConfig() : render::Job::Config() {}
|
MakeHazeConfig() : render::Job::Config() {}
|
||||||
|
|
||||||
glm::vec3 hazeColor{ model::Haze::INITIAL_HAZE_COLOR };
|
glm::vec3 hazeColor{ graphics::Haze::INITIAL_HAZE_COLOR };
|
||||||
float hazeGlareAngle{ model::Haze::INITIAL_HAZE_GLARE_ANGLE };
|
float hazeGlareAngle{ graphics::Haze::INITIAL_HAZE_GLARE_ANGLE };
|
||||||
|
|
||||||
glm::vec3 hazeGlareColor{ model::Haze::INITIAL_HAZE_GLARE_COLOR };
|
glm::vec3 hazeGlareColor{ graphics::Haze::INITIAL_HAZE_GLARE_COLOR };
|
||||||
float hazeBaseReference{ model::Haze::INITIAL_HAZE_BASE_REFERENCE };
|
float hazeBaseReference{ graphics::Haze::INITIAL_HAZE_BASE_REFERENCE };
|
||||||
|
|
||||||
bool isHazeActive{ false };
|
bool isHazeActive{ false };
|
||||||
bool isAltitudeBased{ false };
|
bool isAltitudeBased{ false };
|
||||||
|
@ -63,13 +63,13 @@ public:
|
||||||
bool isModulateColorActive{ false };
|
bool isModulateColorActive{ false };
|
||||||
bool isHazeEnableGlare{ false };
|
bool isHazeEnableGlare{ false };
|
||||||
|
|
||||||
float hazeRange{ model::Haze::INITIAL_HAZE_RANGE };
|
float hazeRange{ graphics::Haze::INITIAL_HAZE_RANGE };
|
||||||
float hazeHeight{ model::Haze::INITIAL_HAZE_HEIGHT };
|
float hazeHeight{ graphics::Haze::INITIAL_HAZE_HEIGHT };
|
||||||
|
|
||||||
float hazeKeyLightRange{ model::Haze::INITIAL_KEY_LIGHT_RANGE };
|
float hazeKeyLightRange{ graphics::Haze::INITIAL_KEY_LIGHT_RANGE };
|
||||||
float hazeKeyLightAltitude{ model::Haze::INITIAL_KEY_LIGHT_ALTITUDE };
|
float hazeKeyLightAltitude{ graphics::Haze::INITIAL_KEY_LIGHT_ALTITUDE };
|
||||||
|
|
||||||
float hazeBackgroundBlend{ model::Haze::INITIAL_HAZE_BACKGROUND_BLEND };
|
float hazeBackgroundBlend{ graphics::Haze::INITIAL_HAZE_BACKGROUND_BLEND };
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); }
|
void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); }
|
||||||
|
@ -99,15 +99,15 @@ signals:
|
||||||
class MakeHaze {
|
class MakeHaze {
|
||||||
public:
|
public:
|
||||||
using Config = MakeHazeConfig;
|
using Config = MakeHazeConfig;
|
||||||
using JobModel = render::Job::ModelO<MakeHaze, model::HazePointer, Config>;
|
using JobModel = render::Job::ModelO<MakeHaze, graphics::HazePointer, Config>;
|
||||||
|
|
||||||
MakeHaze();
|
MakeHaze();
|
||||||
|
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void run(const render::RenderContextPointer& renderContext, model::HazePointer& haze);
|
void run(const render::RenderContextPointer& renderContext, graphics::HazePointer& haze);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
model::HazePointer _haze;
|
graphics::HazePointer _haze;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HazeConfig : public render::Job::Config {
|
class HazeConfig : public render::Job::Config {
|
||||||
|
@ -115,11 +115,11 @@ public:
|
||||||
HazeConfig() : render::Job::Config(true) {}
|
HazeConfig() : render::Job::Config(true) {}
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
glm::vec3 hazeColor{ model::Haze::INITIAL_HAZE_COLOR };
|
glm::vec3 hazeColor{ graphics::Haze::INITIAL_HAZE_COLOR };
|
||||||
float hazeGlareAngle{ model::Haze::INITIAL_HAZE_GLARE_ANGLE };
|
float hazeGlareAngle{ graphics::Haze::INITIAL_HAZE_GLARE_ANGLE };
|
||||||
|
|
||||||
glm::vec3 hazeGlareColor{ model::Haze::INITIAL_HAZE_GLARE_COLOR };
|
glm::vec3 hazeGlareColor{ graphics::Haze::INITIAL_HAZE_GLARE_COLOR };
|
||||||
float hazeBaseReference{ model::Haze::INITIAL_HAZE_BASE_REFERENCE };
|
float hazeBaseReference{ graphics::Haze::INITIAL_HAZE_BASE_REFERENCE };
|
||||||
|
|
||||||
bool isHazeActive{ false }; // Setting this to true will set haze to on
|
bool isHazeActive{ false }; // Setting this to true will set haze to on
|
||||||
bool isAltitudeBased{ false };
|
bool isAltitudeBased{ false };
|
||||||
|
@ -127,13 +127,13 @@ public:
|
||||||
bool isModulateColorActive{ false };
|
bool isModulateColorActive{ false };
|
||||||
bool isHazeEnableGlare{ false };
|
bool isHazeEnableGlare{ false };
|
||||||
|
|
||||||
float hazeRange{ model::Haze::INITIAL_HAZE_RANGE };
|
float hazeRange{ graphics::Haze::INITIAL_HAZE_RANGE };
|
||||||
float hazeHeight{ model::Haze::INITIAL_HAZE_HEIGHT };
|
float hazeHeight{ graphics::Haze::INITIAL_HAZE_HEIGHT };
|
||||||
|
|
||||||
float hazeKeyLightRange{ model::Haze::INITIAL_KEY_LIGHT_RANGE };
|
float hazeKeyLightRange{ graphics::Haze::INITIAL_KEY_LIGHT_RANGE };
|
||||||
float hazeKeyLightAltitude{ model::Haze::INITIAL_KEY_LIGHT_ALTITUDE };
|
float hazeKeyLightAltitude{ graphics::Haze::INITIAL_KEY_LIGHT_ALTITUDE };
|
||||||
|
|
||||||
float hazeBackgroundBlend{ model::Haze::INITIAL_HAZE_BACKGROUND_BLEND };
|
float hazeBackgroundBlend{ graphics::Haze::INITIAL_HAZE_BACKGROUND_BLEND };
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
void setHazeColor(const glm::vec3 value);
|
void setHazeColor(const glm::vec3 value);
|
||||||
|
@ -159,7 +159,7 @@ public:
|
||||||
|
|
||||||
class DrawHaze {
|
class DrawHaze {
|
||||||
public:
|
public:
|
||||||
using Inputs = render::VaryingSet5<model::HazePointer, gpu::FramebufferPointer, LinearDepthFramebufferPointer, DeferredFrameTransformPointer, gpu::FramebufferPointer>;
|
using Inputs = render::VaryingSet5<graphics::HazePointer, gpu::FramebufferPointer, LinearDepthFramebufferPointer, DeferredFrameTransformPointer, gpu::FramebufferPointer>;
|
||||||
using Config = HazeConfig;
|
using Config = HazeConfig;
|
||||||
using JobModel = render::Job::ModelI<DrawHaze, Inputs, Config>;
|
using JobModel = render::Job::ModelI<DrawHaze, Inputs, Config>;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<@if not DEFERRED_GLOBAL_LIGHT_SLH@>
|
<@if not DEFERRED_GLOBAL_LIGHT_SLH@>
|
||||||
<@def DEFERRED_GLOBAL_LIGHT_SLH@>
|
<@def DEFERRED_GLOBAL_LIGHT_SLH@>
|
||||||
|
|
||||||
<@include model/Light.slh@>
|
<@include graphics/Light.slh@>
|
||||||
|
|
||||||
<@include LightingModel.slh@>
|
<@include LightingModel.slh@>
|
||||||
<$declareLightBuffer()$>
|
<$declareLightBuffer()$>
|
||||||
|
@ -65,10 +65,12 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
|
||||||
|
|
||||||
<$prepareGlobalLight($supportScattering$)$>
|
<$prepareGlobalLight($supportScattering$)$>
|
||||||
|
|
||||||
|
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||||
|
|
||||||
// Ambient
|
// Ambient
|
||||||
vec3 ambientDiffuse;
|
vec3 ambientDiffuse;
|
||||||
vec3 ambientSpecular;
|
vec3 ambientSpecular;
|
||||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance
|
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@> );
|
<@endif@> );
|
||||||
|
@ -79,7 +81,7 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
|
||||||
// Directional
|
// Directional
|
||||||
vec3 directionalDiffuse;
|
vec3 directionalDiffuse;
|
||||||
vec3 directionalSpecular;
|
vec3 directionalSpecular;
|
||||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation
|
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@> );
|
<@endif@> );
|
||||||
|
@ -109,10 +111,12 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
) {
|
) {
|
||||||
<$prepareGlobalLight($supportScattering$)$>
|
<$prepareGlobalLight($supportScattering$)$>
|
||||||
|
|
||||||
|
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||||
|
|
||||||
// Ambient
|
// Ambient
|
||||||
vec3 ambientDiffuse;
|
vec3 ambientDiffuse;
|
||||||
vec3 ambientSpecular;
|
vec3 ambientSpecular;
|
||||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance
|
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
@ -124,7 +128,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
// Directional
|
// Directional
|
||||||
vec3 directionalDiffuse;
|
vec3 directionalDiffuse;
|
||||||
vec3 directionalSpecular;
|
vec3 directionalSpecular;
|
||||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation
|
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
@ -173,19 +177,21 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur
|
||||||
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) {
|
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) {
|
||||||
<$prepareGlobalLight()$>
|
<$prepareGlobalLight()$>
|
||||||
|
|
||||||
|
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||||
|
|
||||||
color += emissive * isEmissiveEnabled();
|
color += emissive * isEmissiveEnabled();
|
||||||
|
|
||||||
// Ambient
|
// Ambient
|
||||||
vec3 ambientDiffuse;
|
vec3 ambientDiffuse;
|
||||||
vec3 ambientSpecular;
|
vec3 ambientSpecular;
|
||||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance);
|
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance);
|
||||||
color += ambientDiffuse;
|
color += ambientDiffuse;
|
||||||
color += ambientSpecular / opacity;
|
color += ambientSpecular / opacity;
|
||||||
|
|
||||||
// Directional
|
// Directional
|
||||||
vec3 directionalDiffuse;
|
vec3 directionalDiffuse;
|
||||||
vec3 directionalSpecular;
|
vec3 directionalSpecular;
|
||||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation);
|
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation);
|
||||||
color += directionalDiffuse;
|
color += directionalDiffuse;
|
||||||
color += directionalSpecular / opacity;
|
color += directionalSpecular / opacity;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include "gpu/StandardShaderLib.h"
|
#include "gpu/StandardShaderLib.h"
|
||||||
|
|
||||||
#include "model/TextureMap.h"
|
#include "graphics/TextureMap.h"
|
||||||
#include "render/Args.h"
|
#include "render/Args.h"
|
||||||
|
|
||||||
#include "standardTransformPNTC_vert.h"
|
#include "standardTransformPNTC_vert.h"
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
|
|
||||||
#include <render/ShapePipeline.h>
|
#include <render/ShapePipeline.h>
|
||||||
|
|
||||||
#include <model/Material.h>
|
#include <graphics/Material.h>
|
||||||
#include <model/Asset.h>
|
#include <graphics/Asset.h>
|
||||||
|
|
||||||
class SimpleProgramKey;
|
class SimpleProgramKey;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<@include DeferredTransform.slh@>
|
<@include DeferredTransform.slh@>
|
||||||
<$declareDeferredFrameTransform()$>
|
<$declareDeferredFrameTransform()$>
|
||||||
|
|
||||||
<@include model/Light.slh@>
|
<@include graphics/Light.slh@>
|
||||||
|
|
||||||
<@include LightingModel.slh@>
|
<@include LightingModel.slh@>
|
||||||
<$declareLightBuffer()$>
|
<$declareLightBuffer()$>
|
||||||
|
|
|
@ -17,12 +17,12 @@ std::string HazeStage::_stageName { "HAZE_STAGE"};
|
||||||
const HazeStage::Index HazeStage::INVALID_INDEX { render::indexed_container::INVALID_INDEX };
|
const HazeStage::Index HazeStage::INVALID_INDEX { render::indexed_container::INVALID_INDEX };
|
||||||
|
|
||||||
FetchHazeStage::FetchHazeStage() {
|
FetchHazeStage::FetchHazeStage() {
|
||||||
_haze = std::make_shared<model::Haze>();
|
_haze = std::make_shared<graphics::Haze>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchHazeStage::configure(const Config& config) {
|
void FetchHazeStage::configure(const Config& config) {
|
||||||
_haze->setHazeColor(config.hazeColor);
|
_haze->setHazeColor(config.hazeColor);
|
||||||
_haze->setHazeGlareBlend(model::Haze::convertGlareAngleToPower(config.hazeGlareAngle));
|
_haze->setHazeGlareBlend(graphics::Haze::convertGlareAngleToPower(config.hazeGlareAngle));
|
||||||
|
|
||||||
_haze->setHazeGlareColor(config.hazeGlareColor);
|
_haze->setHazeGlareColor(config.hazeGlareColor);
|
||||||
_haze->setHazeBaseReference(config.hazeBaseReference);
|
_haze->setHazeBaseReference(config.hazeBaseReference);
|
||||||
|
@ -33,11 +33,11 @@ void FetchHazeStage::configure(const Config& config) {
|
||||||
_haze->setModulateColorActive(config.isModulateColorActive);
|
_haze->setModulateColorActive(config.isModulateColorActive);
|
||||||
_haze->setHazeEnableGlare(config.isHazeEnableGlare);
|
_haze->setHazeEnableGlare(config.isHazeEnableGlare);
|
||||||
|
|
||||||
_haze->setHazeRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(config.hazeRange));
|
_haze->setHazeRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(config.hazeRange));
|
||||||
_haze->setHazeAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight));
|
_haze->setHazeAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight));
|
||||||
|
|
||||||
_haze->setHazeKeyLightRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange));
|
_haze->setHazeKeyLightRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange));
|
||||||
_haze->setHazeKeyLightAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude));
|
_haze->setHazeKeyLightAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude));
|
||||||
|
|
||||||
_haze->setHazeBackgroundBlend(config.hazeBackgroundBlend);
|
_haze->setHazeBackgroundBlend(config.hazeBackgroundBlend);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ void HazeStageSetup::run(const render::RenderContextPointer& renderContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchHazeStage::run(const render::RenderContextPointer& renderContext, model::HazePointer& haze) {
|
void FetchHazeStage::run(const render::RenderContextPointer& renderContext, graphics::HazePointer& haze) {
|
||||||
auto hazeStage = renderContext->_scene->getStage<HazeStage>();
|
auto hazeStage = renderContext->_scene->getStage<HazeStage>();
|
||||||
assert(hazeStage);
|
assert(hazeStage);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#ifndef hifi_render_utils_HazeStage_h
|
#ifndef hifi_render_utils_HazeStage_h
|
||||||
#define hifi_render_utils_HazeStage_h
|
#define hifi_render_utils_HazeStage_h
|
||||||
|
|
||||||
#include <model/Stage.h>
|
#include <graphics/Stage.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <render/IndexedContainer.h>
|
#include <render/IndexedContainer.h>
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <render/Forward.h>
|
#include <render/Forward.h>
|
||||||
#include <render/DrawTask.h>
|
#include <render/DrawTask.h>
|
||||||
#include <model/Haze.h>
|
#include <graphics/Haze.h>
|
||||||
|
|
||||||
// Haze stage to set up haze-related rendering tasks
|
// Haze stage to set up haze-related rendering tasks
|
||||||
class HazeStage : public render::Stage {
|
class HazeStage : public render::Stage {
|
||||||
|
@ -31,8 +31,8 @@ public:
|
||||||
static const Index INVALID_INDEX;
|
static const Index INVALID_INDEX;
|
||||||
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
||||||
|
|
||||||
using HazePointer = model::HazePointer;
|
using HazePointer = graphics::HazePointer;
|
||||||
using Hazes = render::indexed_container::IndexedPointerVector<model::Haze>;
|
using Hazes = render::indexed_container::IndexedPointerVector<graphics::Haze>;
|
||||||
using HazeMap = std::unordered_map<HazePointer, Index>;
|
using HazeMap = std::unordered_map<HazePointer, Index>;
|
||||||
|
|
||||||
using HazeIndices = std::vector<Index>;
|
using HazeIndices = std::vector<Index>;
|
||||||
|
@ -106,11 +106,11 @@ class FetchHazeConfig : public render::Job::Config {
|
||||||
public:
|
public:
|
||||||
FetchHazeConfig() : render::Job::Config() {}
|
FetchHazeConfig() : render::Job::Config() {}
|
||||||
|
|
||||||
glm::vec3 hazeColor{ model::Haze::INITIAL_HAZE_COLOR };
|
glm::vec3 hazeColor{ graphics::Haze::INITIAL_HAZE_COLOR };
|
||||||
float hazeGlareAngle{ model::Haze::INITIAL_HAZE_GLARE_ANGLE };
|
float hazeGlareAngle{ graphics::Haze::INITIAL_HAZE_GLARE_ANGLE };
|
||||||
|
|
||||||
glm::vec3 hazeGlareColor{ model::Haze::INITIAL_HAZE_GLARE_COLOR };
|
glm::vec3 hazeGlareColor{ graphics::Haze::INITIAL_HAZE_GLARE_COLOR };
|
||||||
float hazeBaseReference{ model::Haze::INITIAL_HAZE_BASE_REFERENCE };
|
float hazeBaseReference{ graphics::Haze::INITIAL_HAZE_BASE_REFERENCE };
|
||||||
|
|
||||||
bool isHazeActive{ false };
|
bool isHazeActive{ false };
|
||||||
bool isAltitudeBased{ false };
|
bool isAltitudeBased{ false };
|
||||||
|
@ -118,13 +118,13 @@ public:
|
||||||
bool isModulateColorActive{ false };
|
bool isModulateColorActive{ false };
|
||||||
bool isHazeEnableGlare{ false };
|
bool isHazeEnableGlare{ false };
|
||||||
|
|
||||||
float hazeRange{ model::Haze::INITIAL_HAZE_RANGE };
|
float hazeRange{ graphics::Haze::INITIAL_HAZE_RANGE };
|
||||||
float hazeHeight{ model::Haze::INITIAL_HAZE_HEIGHT };
|
float hazeHeight{ graphics::Haze::INITIAL_HAZE_HEIGHT };
|
||||||
|
|
||||||
float hazeKeyLightRange{ model::Haze::INITIAL_KEY_LIGHT_RANGE };
|
float hazeKeyLightRange{ graphics::Haze::INITIAL_KEY_LIGHT_RANGE };
|
||||||
float hazeKeyLightAltitude{ model::Haze::INITIAL_KEY_LIGHT_ALTITUDE };
|
float hazeKeyLightAltitude{ graphics::Haze::INITIAL_KEY_LIGHT_ALTITUDE };
|
||||||
|
|
||||||
float hazeBackgroundBlend{ model::Haze::INITIAL_HAZE_BACKGROUND_BLEND };
|
float hazeBackgroundBlend{ graphics::Haze::INITIAL_HAZE_BACKGROUND_BLEND };
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); }
|
void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); }
|
||||||
|
@ -154,15 +154,15 @@ signals:
|
||||||
class FetchHazeStage {
|
class FetchHazeStage {
|
||||||
public:
|
public:
|
||||||
using Config = FetchHazeConfig;
|
using Config = FetchHazeConfig;
|
||||||
using JobModel = render::Job::ModelO<FetchHazeStage, model::HazePointer, Config>;
|
using JobModel = render::Job::ModelO<FetchHazeStage, graphics::HazePointer, Config>;
|
||||||
|
|
||||||
FetchHazeStage();
|
FetchHazeStage();
|
||||||
|
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void run(const render::RenderContextPointer& renderContext, model::HazePointer& haze);
|
void run(const render::RenderContextPointer& renderContext, graphics::HazePointer& haze);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
model::HazePointer _haze;
|
graphics::HazePointer _haze;
|
||||||
gpu::PipelinePointer _hazePipeline;
|
gpu::PipelinePointer _hazePipeline;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,22 +16,27 @@ uniform samplerCube skyboxMap;
|
||||||
vec4 evalSkyboxLight(vec3 direction, float lod) {
|
vec4 evalSkyboxLight(vec3 direction, float lod) {
|
||||||
// textureQueryLevels is not available until #430, so we require explicit lod
|
// textureQueryLevels is not available until #430, so we require explicit lod
|
||||||
// float mipmapLevel = lod * textureQueryLevels(skyboxMap);
|
// float mipmapLevel = lod * textureQueryLevels(skyboxMap);
|
||||||
|
float filterLod = textureQueryLod(skyboxMap, direction).x;
|
||||||
|
// Keep texture filtering LOD as limit to prevent aliasing on specular reflection
|
||||||
|
lod = max(lod, filterLod);
|
||||||
return textureLod(skyboxMap, direction, lod);
|
return textureLod(skyboxMap, direction, lod);
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
<@func declareEvalAmbientSpecularIrradiance(supportAmbientSphere, supportAmbientMap, supportIfAmbientMapElseAmbientSphere)@>
|
<@func declareEvalAmbientSpecularIrradiance(supportAmbientSphere, supportAmbientMap, supportIfAmbientMapElseAmbientSphere)@>
|
||||||
|
|
||||||
vec3 fresnelSchlickAmbient(vec3 fresnelColor, vec3 lightDir, vec3 halfDir, float gloss) {
|
vec3 fresnelSchlickAmbient(vec3 fresnelColor, float ndotd, float gloss) {
|
||||||
return fresnelColor + (max(vec3(gloss), fresnelColor) - fresnelColor) * pow(1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0), 5.0);
|
float f = pow(1.0 - ndotd, 5.0);
|
||||||
|
return fresnelColor + (max(vec3(gloss), fresnelColor) - fresnelColor) * f;
|
||||||
|
// return fresnelColor + (vec3(1.0) - fresnelColor) * f;
|
||||||
}
|
}
|
||||||
|
|
||||||
<@if supportAmbientMap@>
|
<@if supportAmbientMap@>
|
||||||
<$declareSkyboxMap()$>
|
<$declareSkyboxMap()$>
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
||||||
vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, vec3 fragEyeDir, vec3 fragNormal, float roughness) {
|
vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, SurfaceData surface) {
|
||||||
vec3 direction = -reflect(fragEyeDir, fragNormal);
|
vec3 lightDir = -reflect(surface.eyeDir, surface.normal);
|
||||||
vec3 specularLight;
|
vec3 specularLight;
|
||||||
<@if supportIfAmbientMapElseAmbientSphere@>
|
<@if supportIfAmbientMapElseAmbientSphere@>
|
||||||
if (getLightHasAmbientMap(ambient))
|
if (getLightHasAmbientMap(ambient))
|
||||||
|
@ -39,8 +44,10 @@ vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, vec3 fragEyeDir, vec3 f
|
||||||
<@if supportAmbientMap@>
|
<@if supportAmbientMap@>
|
||||||
{
|
{
|
||||||
float levels = getLightAmbientMapNumMips(ambient);
|
float levels = getLightAmbientMapNumMips(ambient);
|
||||||
float lod = min(((roughness)* levels), levels);
|
float m = 12.0 / (1.0+11.0*surface.roughness);
|
||||||
specularLight = evalSkyboxLight(direction, lod).xyz;
|
float lod = levels - m;
|
||||||
|
lod = max(lod, 0);
|
||||||
|
specularLight = evalSkyboxLight(lightDir, lod).xyz;
|
||||||
}
|
}
|
||||||
<@endif@>
|
<@endif@>
|
||||||
<@if supportIfAmbientMapElseAmbientSphere@>
|
<@if supportIfAmbientMapElseAmbientSphere@>
|
||||||
|
@ -48,11 +55,11 @@ vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, vec3 fragEyeDir, vec3 f
|
||||||
<@endif@>
|
<@endif@>
|
||||||
<@if supportAmbientSphere@>
|
<@if supportAmbientSphere@>
|
||||||
{
|
{
|
||||||
specularLight = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), direction).xyz;
|
specularLight = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), lightDir).xyz;
|
||||||
}
|
}
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
||||||
return specularLight;
|
return specularLight;
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
@ -66,21 +73,21 @@ float curvatureAO(in float k) {
|
||||||
}
|
}
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
||||||
void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambient, vec3 eyeDir, vec3 normal,
|
void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambient, SurfaceData surface,
|
||||||
float roughness, float metallic, vec3 fresnel, vec3 albedo, float obscurance
|
float metallic, vec3 fresnelF0, vec3 albedo, float obscurance
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||||
<@endif@>
|
<@endif@>
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// Fresnel
|
// Fresnel
|
||||||
vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, eyeDir, normal, 1.0 - roughness);
|
vec3 ambientFresnel = fresnelSchlickAmbient(fresnelF0, surface.ndotv, 1.0-surface.roughness);
|
||||||
|
|
||||||
// Diffuse from ambient
|
// Diffuse from ambient
|
||||||
diffuse = (1.0 - metallic) * (vec3(1.0) - ambientFresnel) * sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), normal).xyz;
|
diffuse = (1.0 - metallic) * (vec3(1.0) - ambientFresnel) * sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), surface.normal).xyz;
|
||||||
|
|
||||||
// Specular highlight from ambient
|
// Specular highlight from ambient
|
||||||
specular = evalAmbientSpecularIrradiance(ambient, eyeDir, normal, roughness) * ambientFresnel;
|
specular = evalAmbientSpecularIrradiance(ambient, surface) * ambientFresnel;
|
||||||
|
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
if (scattering * isScatteringEnabled() > 0.0) {
|
if (scattering * isScatteringEnabled() > 0.0) {
|
||||||
|
@ -92,7 +99,7 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambie
|
||||||
|
|
||||||
// Diffuse from ambient
|
// Diffuse from ambient
|
||||||
diffuse = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), lowNormalCurvature.xyz).xyz;
|
diffuse = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), lowNormalCurvature.xyz).xyz;
|
||||||
|
diffuse /= 3.1415926;
|
||||||
specular = vec3(0.0);
|
specular = vec3(0.0);
|
||||||
}
|
}
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
@ -107,8 +114,9 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambie
|
||||||
diffuse *= albedo;
|
diffuse *= albedo;
|
||||||
}
|
}
|
||||||
|
|
||||||
diffuse *= lightEnergy * isDiffuseEnabled() * isAmbientEnabled();
|
lightEnergy *= isAmbientEnabled();
|
||||||
specular *= lightEnergy * isSpecularEnabled() * isAmbientEnabled();
|
diffuse *= lightEnergy * isDiffuseEnabled();
|
||||||
|
specular *= lightEnergy * isSpecularEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<@func declareLightingDirectional(supportScattering)@>
|
<@func declareLightingDirectional(supportScattering)@>
|
||||||
|
|
||||||
void evalLightingDirectional(out vec3 diffuse, out vec3 specular, vec3 lightDir, vec3 lightIrradiance,
|
void evalLightingDirectional(out vec3 diffuse, out vec3 specular, vec3 lightDir, vec3 lightIrradiance,
|
||||||
vec3 eyeDir, vec3 normal, float roughness,
|
SurfaceData surface,
|
||||||
float metallic, vec3 fresnel, vec3 albedo, float shadow
|
float metallic, vec3 fresnel, vec3 albedo, float shadow
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||||
|
@ -22,14 +22,17 @@ void evalLightingDirectional(out vec3 diffuse, out vec3 specular, vec3 lightDir,
|
||||||
// Attenuation
|
// Attenuation
|
||||||
vec3 lightEnergy = shadow * lightIrradiance;
|
vec3 lightEnergy = shadow * lightIrradiance;
|
||||||
|
|
||||||
evalFragShading(diffuse, specular, normal, -lightDir, eyeDir, metallic, fresnel, roughness, albedo
|
updateSurfaceDataWithLight(surface, -lightDir);
|
||||||
|
|
||||||
|
evalFragShading(diffuse, specular, metallic, fresnel, surface, albedo
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@>
|
<@endif@>
|
||||||
);
|
);
|
||||||
|
|
||||||
diffuse *= lightEnergy * isDiffuseEnabled() * isDirectionalEnabled();
|
lightEnergy *= isDirectionalEnabled();
|
||||||
specular *= lightEnergy * isSpecularEnabled() * isDirectionalEnabled();
|
diffuse *= lightEnergy * isDiffuseEnabled();
|
||||||
|
specular *= lightEnergy * isSpecularEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace render {
|
||||||
}
|
}
|
||||||
|
|
||||||
LightPayload::LightPayload() :
|
LightPayload::LightPayload() :
|
||||||
_light(std::make_shared<model::Light>())
|
_light(std::make_shared<graphics::Light>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ namespace render {
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyLightPayload::KeyLightPayload() :
|
KeyLightPayload::KeyLightPayload() :
|
||||||
_light(std::make_shared<model::Light>())
|
_light(std::make_shared<graphics::Light>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#define hifi_LightPayload_h
|
#define hifi_LightPayload_h
|
||||||
|
|
||||||
|
|
||||||
#include <model/Light.h>
|
#include <graphics/Light.h>
|
||||||
#include <render/Item.h>
|
#include <render/Item.h>
|
||||||
#include "LightStage.h"
|
#include "LightStage.h"
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
@ -26,14 +26,14 @@ public:
|
||||||
~LightPayload();
|
~LightPayload();
|
||||||
void render(RenderArgs* args);
|
void render(RenderArgs* args);
|
||||||
|
|
||||||
model::LightPointer editLight() { _needUpdate = true; return _light; }
|
graphics::LightPointer editLight() { _needUpdate = true; return _light; }
|
||||||
render::Item::Bound& editBound() { _needUpdate = true; return _bound; }
|
render::Item::Bound& editBound() { _needUpdate = true; return _bound; }
|
||||||
|
|
||||||
void setVisible(bool visible) { _isVisible = visible; }
|
void setVisible(bool visible) { _isVisible = visible; }
|
||||||
bool isVisible() const { return _isVisible; }
|
bool isVisible() const { return _isVisible; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
model::LightPointer _light;
|
graphics::LightPointer _light;
|
||||||
render::Item::Bound _bound;
|
render::Item::Bound _bound;
|
||||||
LightStagePointer _stage;
|
LightStagePointer _stage;
|
||||||
LightStage::Index _index { LightStage::INVALID_INDEX };
|
LightStage::Index _index { LightStage::INVALID_INDEX };
|
||||||
|
@ -56,7 +56,7 @@ public:
|
||||||
~KeyLightPayload();
|
~KeyLightPayload();
|
||||||
void render(RenderArgs* args);
|
void render(RenderArgs* args);
|
||||||
|
|
||||||
model::LightPointer editLight() { _needUpdate = true; return _light; }
|
graphics::LightPointer editLight() { _needUpdate = true; return _light; }
|
||||||
render::Item::Bound& editBound() { _needUpdate = true; return _bound; }
|
render::Item::Bound& editBound() { _needUpdate = true; return _bound; }
|
||||||
|
|
||||||
void setVisible(bool visible) { _isVisible = visible; }
|
void setVisible(bool visible) { _isVisible = visible; }
|
||||||
|
@ -69,7 +69,7 @@ public:
|
||||||
bool _pendingAmbientTexture { false };
|
bool _pendingAmbientTexture { false };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
model::LightPointer _light;
|
graphics::LightPointer _light;
|
||||||
render::Item::Bound _bound;
|
render::Item::Bound _bound;
|
||||||
LightStagePointer _stage;
|
LightStagePointer _stage;
|
||||||
LightStage::Index _index { LightStage::INVALID_INDEX };
|
LightStage::Index _index { LightStage::INVALID_INDEX };
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<@func declareLightingPoint(supportScattering)@>
|
<@func declareLightingPoint(supportScattering)@>
|
||||||
|
|
||||||
void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
|
void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
vec4 fragLightDirLen, vec3 fragEyeDir, vec3 normal, float roughness,
|
vec4 fragLightDirLen, SurfaceData surface,
|
||||||
float metallic, vec3 fresnel, vec3 albedo, float shadow
|
float metallic, vec3 fresnel, vec3 albedo, float shadow
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||||
|
@ -23,19 +23,22 @@ void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
float fragLightDistance = fragLightDirLen.w;
|
float fragLightDistance = fragLightDirLen.w;
|
||||||
vec3 fragLightDir = fragLightDirLen.xyz;
|
vec3 fragLightDir = fragLightDirLen.xyz;
|
||||||
|
|
||||||
|
updateSurfaceDataWithLight(surface, fragLightDir);
|
||||||
|
|
||||||
// Eval attenuation
|
// Eval attenuation
|
||||||
float radialAttenuation = lightIrradiance_evalLightAttenuation(light.irradiance, fragLightDistance);
|
float radialAttenuation = lightIrradiance_evalLightAttenuation(light.irradiance, fragLightDistance);
|
||||||
vec3 lightEnergy = radialAttenuation * shadow * getLightIrradiance(light);
|
vec3 lightEnergy = radialAttenuation * shadow * getLightIrradiance(light);
|
||||||
|
|
||||||
// Eval shading
|
// Eval shading
|
||||||
evalFragShading(diffuse, specular, normal, fragLightDir, fragEyeDir, metallic, fresnel, roughness, albedo
|
evalFragShading(diffuse, specular, metallic, fresnel, surface, albedo
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@>
|
<@endif@>
|
||||||
);
|
);
|
||||||
|
|
||||||
diffuse *= lightEnergy * isDiffuseEnabled() * isPointEnabled();
|
lightEnergy *= isPointEnabled();
|
||||||
specular *= lightEnergy * isSpecularEnabled() * isPointEnabled();
|
diffuse *= lightEnergy * isDiffuseEnabled();
|
||||||
|
specular *= lightEnergy * isSpecularEnabled();
|
||||||
|
|
||||||
if (isShowLightContour() > 0.0) {
|
if (isShowLightContour() > 0.0) {
|
||||||
// Show edge
|
// Show edge
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<@func declareLightingSpot(supportScattering)@>
|
<@func declareLightingSpot(supportScattering)@>
|
||||||
|
|
||||||
void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
vec4 fragLightDirLen, float cosSpotAngle, vec3 fragEyeDir, vec3 normal, float roughness,
|
vec4 fragLightDirLen, float cosSpotAngle, SurfaceData surface,
|
||||||
float metallic, vec3 fresnel, vec3 albedo, float shadow
|
float metallic, vec3 fresnel, vec3 albedo, float shadow
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||||
|
@ -23,6 +23,7 @@ void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
float fragLightDistance = fragLightDirLen.w;
|
float fragLightDistance = fragLightDirLen.w;
|
||||||
vec3 fragLightDir = fragLightDirLen.xyz;
|
vec3 fragLightDir = fragLightDirLen.xyz;
|
||||||
|
|
||||||
|
updateSurfaceDataWithLight(surface, fragLightDir);
|
||||||
|
|
||||||
// Eval attenuation
|
// Eval attenuation
|
||||||
float radialAttenuation = lightIrradiance_evalLightAttenuation(light.irradiance, fragLightDistance);
|
float radialAttenuation = lightIrradiance_evalLightAttenuation(light.irradiance, fragLightDistance);
|
||||||
|
@ -30,14 +31,15 @@ void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
vec3 lightEnergy = angularAttenuation * radialAttenuation * shadow *getLightIrradiance(light);
|
vec3 lightEnergy = angularAttenuation * radialAttenuation * shadow *getLightIrradiance(light);
|
||||||
|
|
||||||
// Eval shading
|
// Eval shading
|
||||||
evalFragShading(diffuse, specular, normal, fragLightDir, fragEyeDir, metallic, fresnel, roughness, albedo
|
evalFragShading(diffuse, specular, metallic, fresnel, surface, albedo
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
,scattering, midNormalCurvature, lowNormalCurvature
|
,scattering, midNormalCurvature, lowNormalCurvature
|
||||||
<@endif@>
|
<@endif@>
|
||||||
);
|
);
|
||||||
|
|
||||||
diffuse *= lightEnergy * isDiffuseEnabled() * isSpotEnabled();
|
lightEnergy *= isSpotEnabled();
|
||||||
specular *= lightEnergy * isSpecularEnabled() * isSpotEnabled();
|
diffuse *= lightEnergy * isDiffuseEnabled();
|
||||||
|
specular *= lightEnergy * isSpecularEnabled();
|
||||||
|
|
||||||
if (isShowLightContour() > 0.0) {
|
if (isShowLightContour() > 0.0) {
|
||||||
// Show edges
|
// Show edges
|
||||||
|
|
|
@ -29,32 +29,32 @@ const LightStage::Index LightStage::INVALID_INDEX { render::indexed_container::I
|
||||||
|
|
||||||
LightStage::LightStage() {
|
LightStage::LightStage() {
|
||||||
// Add off lights
|
// Add off lights
|
||||||
const LightPointer ambientOffLight { std::make_shared<model::Light>() };
|
const LightPointer ambientOffLight { std::make_shared<graphics::Light>() };
|
||||||
ambientOffLight->setAmbientIntensity(0.0f);
|
ambientOffLight->setAmbientIntensity(0.0f);
|
||||||
ambientOffLight->setColor(model::Vec3(0.0));
|
ambientOffLight->setColor(graphics::Vec3(0.0));
|
||||||
ambientOffLight->setIntensity(0.0f);
|
ambientOffLight->setIntensity(0.0f);
|
||||||
ambientOffLight->setType(model::Light::Type::AMBIENT);
|
ambientOffLight->setType(graphics::Light::Type::AMBIENT);
|
||||||
_ambientOffLightId = addLight(ambientOffLight);
|
_ambientOffLightId = addLight(ambientOffLight);
|
||||||
|
|
||||||
const LightPointer pointOffLight { std::make_shared<model::Light>() };
|
const LightPointer pointOffLight { std::make_shared<graphics::Light>() };
|
||||||
pointOffLight->setAmbientIntensity(0.0f);
|
pointOffLight->setAmbientIntensity(0.0f);
|
||||||
pointOffLight->setColor(model::Vec3(0.0));
|
pointOffLight->setColor(graphics::Vec3(0.0));
|
||||||
pointOffLight->setIntensity(0.0f);
|
pointOffLight->setIntensity(0.0f);
|
||||||
pointOffLight->setType(model::Light::Type::POINT);
|
pointOffLight->setType(graphics::Light::Type::POINT);
|
||||||
_pointOffLightId = addLight(pointOffLight);
|
_pointOffLightId = addLight(pointOffLight);
|
||||||
|
|
||||||
const LightPointer spotOffLight { std::make_shared<model::Light>() };
|
const LightPointer spotOffLight { std::make_shared<graphics::Light>() };
|
||||||
spotOffLight->setAmbientIntensity(0.0f);
|
spotOffLight->setAmbientIntensity(0.0f);
|
||||||
spotOffLight->setColor(model::Vec3(0.0));
|
spotOffLight->setColor(graphics::Vec3(0.0));
|
||||||
spotOffLight->setIntensity(0.0f);
|
spotOffLight->setIntensity(0.0f);
|
||||||
spotOffLight->setType(model::Light::Type::SPOT);
|
spotOffLight->setType(graphics::Light::Type::SPOT);
|
||||||
_spotOffLightId = addLight(spotOffLight);
|
_spotOffLightId = addLight(spotOffLight);
|
||||||
|
|
||||||
const LightPointer sunOffLight { std::make_shared<model::Light>() };
|
const LightPointer sunOffLight { std::make_shared<graphics::Light>() };
|
||||||
sunOffLight->setAmbientIntensity(0.0f);
|
sunOffLight->setAmbientIntensity(0.0f);
|
||||||
sunOffLight->setColor(model::Vec3(0.0));
|
sunOffLight->setColor(graphics::Vec3(0.0));
|
||||||
sunOffLight->setIntensity(0.0f);
|
sunOffLight->setIntensity(0.0f);
|
||||||
sunOffLight->setType(model::Light::Type::SUN);
|
sunOffLight->setType(graphics::Light::Type::SUN);
|
||||||
_sunOffLightId = addLight(sunOffLight);
|
_sunOffLightId = addLight(sunOffLight);
|
||||||
|
|
||||||
// Set default light to the off ambient light (until changed)
|
// Set default light to the off ambient light (until changed)
|
||||||
|
@ -123,7 +123,7 @@ float LightStage::Shadow::Cascade::computeFarDistance(const ViewFrustum& viewFru
|
||||||
return far;
|
return far;
|
||||||
}
|
}
|
||||||
|
|
||||||
LightStage::Shadow::Shadow(model::LightPointer light, float maxDistance, unsigned int cascadeCount) :
|
LightStage::Shadow::Shadow(graphics::LightPointer light, float maxDistance, unsigned int cascadeCount) :
|
||||||
_light{ light } {
|
_light{ light } {
|
||||||
cascadeCount = std::min(cascadeCount, (unsigned int)SHADOW_CASCADE_MAX_COUNT);
|
cascadeCount = std::min(cascadeCount, (unsigned int)SHADOW_CASCADE_MAX_COUNT);
|
||||||
Schema schema;
|
Schema schema;
|
||||||
|
@ -404,14 +404,14 @@ LightStage::Index LightStage::getShadowId(Index lightId) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightStage::updateLightArrayBuffer(Index lightId) {
|
void LightStage::updateLightArrayBuffer(Index lightId) {
|
||||||
auto lightSize = sizeof(model::Light::LightSchema);
|
auto lightSize = sizeof(graphics::Light::LightSchema);
|
||||||
if (!_lightArrayBuffer) {
|
if (!_lightArrayBuffer) {
|
||||||
_lightArrayBuffer = std::make_shared<gpu::Buffer>(lightSize);
|
_lightArrayBuffer = std::make_shared<gpu::Buffer>(lightSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(checkLightId(lightId));
|
assert(checkLightId(lightId));
|
||||||
|
|
||||||
if (lightId > (Index)_lightArrayBuffer->getNumTypedElements<model::Light::LightSchema>()) {
|
if (lightId > (Index)_lightArrayBuffer->getNumTypedElements<graphics::Light::LightSchema>()) {
|
||||||
_lightArrayBuffer->resize(lightSize * (lightId + 10));
|
_lightArrayBuffer->resize(lightSize * (lightId + 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ void LightStage::updateLightArrayBuffer(Index lightId) {
|
||||||
auto light = _lights._elements[lightId];
|
auto light = _lights._elements[lightId];
|
||||||
if (light) {
|
if (light) {
|
||||||
const auto& lightSchema = light->getLightSchemaBuffer().get();
|
const auto& lightSchema = light->getLightSchemaBuffer().get();
|
||||||
_lightArrayBuffer->setSubData<model::Light::LightSchema>(lightId, lightSchema);
|
_lightArrayBuffer->setSubData<graphics::Light::LightSchema>(lightId, lightSchema);
|
||||||
} else {
|
} else {
|
||||||
// this should not happen ?
|
// this should not happen ?
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include <gpu/Framebuffer.h>
|
#include <gpu/Framebuffer.h>
|
||||||
|
|
||||||
#include <model/Light.h>
|
#include <graphics/Light.h>
|
||||||
|
|
||||||
#include <render/IndexedContainer.h>
|
#include <render/IndexedContainer.h>
|
||||||
#include <render/Stage.h>
|
#include <render/Stage.h>
|
||||||
|
@ -35,8 +35,8 @@ public:
|
||||||
static const Index INVALID_INDEX;
|
static const Index INVALID_INDEX;
|
||||||
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
||||||
|
|
||||||
using LightPointer = model::LightPointer;
|
using LightPointer = graphics::LightPointer;
|
||||||
using Lights = render::indexed_container::IndexedPointerVector<model::Light>;
|
using Lights = render::indexed_container::IndexedPointerVector<graphics::Light>;
|
||||||
using LightMap = std::unordered_map<LightPointer, Index>;
|
using LightMap = std::unordered_map<LightPointer, Index>;
|
||||||
|
|
||||||
using LightIndices = std::vector<Index>;
|
using LightIndices = std::vector<Index>;
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
float left, float right, float bottom, float top, float viewMaxShadowDistance) const;
|
float left, float right, float bottom, float top, float viewMaxShadowDistance) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
Shadow(model::LightPointer light, float maxDistance, unsigned int cascadeCount = 1);
|
Shadow(graphics::LightPointer light, float maxDistance, unsigned int cascadeCount = 1);
|
||||||
|
|
||||||
void setKeylightFrustum(const ViewFrustum& viewFrustum,
|
void setKeylightFrustum(const ViewFrustum& viewFrustum,
|
||||||
float nearDepth = 1.0f, float farDepth = 1000.0f);
|
float nearDepth = 1.0f, float farDepth = 1000.0f);
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
float getMaxDistance() const { return _maxDistance; }
|
float getMaxDistance() const { return _maxDistance; }
|
||||||
void setMaxDistance(float value);
|
void setMaxDistance(float value);
|
||||||
|
|
||||||
const model::LightPointer& getLight() const { return _light; }
|
const graphics::LightPointer& getLight() const { return _light; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public:
|
||||||
|
|
||||||
static const glm::mat4 _biasMatrix;
|
static const glm::mat4 _biasMatrix;
|
||||||
|
|
||||||
model::LightPointer _light;
|
graphics::LightPointer _light;
|
||||||
float _maxDistance;
|
float _maxDistance;
|
||||||
Cascades _cascades;
|
Cascades _cascades;
|
||||||
|
|
||||||
|
@ -165,12 +165,12 @@ public:
|
||||||
Frame() {}
|
Frame() {}
|
||||||
|
|
||||||
void clear() { _pointLights.clear(); _spotLights.clear(); _sunLights.clear(); _ambientLights.clear(); }
|
void clear() { _pointLights.clear(); _spotLights.clear(); _sunLights.clear(); _ambientLights.clear(); }
|
||||||
void pushLight(LightStage::Index index, model::Light::Type type) {
|
void pushLight(LightStage::Index index, graphics::Light::Type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case model::Light::POINT: { pushPointLight(index); break; }
|
case graphics::Light::POINT: { pushPointLight(index); break; }
|
||||||
case model::Light::SPOT: { pushSpotLight(index); break; }
|
case graphics::Light::SPOT: { pushSpotLight(index); break; }
|
||||||
case model::Light::SUN: { pushSunLight(index); break; }
|
case graphics::Light::SUN: { pushSunLight(index); break; }
|
||||||
case model::Light::AMBIENT: { pushAmbientLight(index); break; }
|
case graphics::Light::AMBIENT: { pushAmbientLight(index); break; }
|
||||||
default: { break; }
|
default: { break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue