Merge pull request #14093 from SamGondelman/police

Case 19409, Case 19468: Fading fixes and shader cleanup
This commit is contained in:
Sam Gondelman 2018-11-13 15:00:23 -08:00 committed by GitHub
commit 13f650d514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 453 additions and 449 deletions

View file

@ -207,7 +207,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
{
// lock the hash for read to check the size
QReadLocker lock(&_hashLock);
if (_avatarHash.size() < 2 && _avatarsToFade.isEmpty()) {
if (_avatarHash.size() < 2 && _avatarsToFadeOut.isEmpty()) {
return;
}
}
@ -367,23 +367,23 @@ void AvatarManager::sendIdentityRequest(const QUuid& avatarID) const {
}
void AvatarManager::simulateAvatarFades(float deltaTime) {
if (_avatarsToFade.empty()) {
if (_avatarsToFadeOut.empty()) {
return;
}
QReadLocker locker(&_hashLock);
QVector<AvatarSharedPointer>::iterator avatarItr = _avatarsToFade.begin();
QVector<AvatarSharedPointer>::iterator avatarItr = _avatarsToFadeOut.begin();
const render::ScenePointer& scene = qApp->getMain3DScene();
render::Transaction transaction;
while (avatarItr != _avatarsToFade.end()) {
while (avatarItr != _avatarsToFadeOut.end()) {
auto avatar = std::static_pointer_cast<Avatar>(*avatarItr);
avatar->updateFadingStatus(scene);
avatar->updateFadingStatus();
if (!avatar->isFading()) {
// fading to zero is such a rare event we push a unique transaction for each
if (avatar->isInScene()) {
avatar->removeFromScene(*avatarItr, scene, transaction);
}
avatarItr = _avatarsToFade.erase(avatarItr);
avatarItr = _avatarsToFadeOut.erase(avatarItr);
} else {
++avatarItr;
}
@ -478,7 +478,7 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar
DependencyManager::get<UsersScriptingInterface>()->avatarDisconnected(avatar->getSessionUUID());
avatar->fadeOut(qApp->getMain3DScene(), removalReason);
}
_avatarsToFade.push_back(removedAvatar);
_avatarsToFadeOut.push_back(removedAvatar);
}
void AvatarManager::clearOtherAvatars() {

View file

@ -223,7 +223,7 @@ private:
KillAvatarReason removalReason = KillAvatarReason::NoReason) override;
void handleTransitAnimations(AvatarTransit::Status status);
QVector<AvatarSharedPointer> _avatarsToFade;
QVector<AvatarSharedPointer> _avatarsToFadeOut;
using SetOfOtherAvatars = std::set<OtherAvatarPointer>;
SetOfOtherAvatars _avatarsToChangeInPhysics;

View file

@ -963,6 +963,8 @@ void MyAvatar::simulate(float deltaTime) {
}
updateAvatarEntities();
updateFadingStatus();
}
// As far as I know no HMD system supports a play area of a kilometer in radius.

View file

@ -616,6 +616,8 @@ void Avatar::simulate(float deltaTime, bool inView) {
PROFILE_RANGE(simulation, "entities");
updateAvatarEntities();
}
updateFadingStatus();
}
float Avatar::getSimulationRate(const QString& rateName) const {
@ -761,8 +763,7 @@ void Avatar::fadeOut(render::ScenePointer scene, KillAvatarReason reason) {
if (reason == KillAvatarReason::YourAvatarEnteredTheirBubble) {
transitionType = render::Transition::BUBBLE_ISECT_TRESPASSER;
}
else if (reason == KillAvatarReason::TheirAvatarEnteredYourBubble) {
} else if (reason == KillAvatarReason::TheirAvatarEnteredYourBubble) {
transitionType = render::Transition::BUBBLE_ISECT_OWNER;
}
fade(transaction, transitionType);
@ -779,14 +780,16 @@ void Avatar::fade(render::Transaction& transaction, render::Transition::Type typ
_isFading = true;
}
void Avatar::updateFadingStatus(render::ScenePointer scene) {
render::Transaction transaction;
transaction.queryTransitionOnItem(_renderItemID, [this](render::ItemID id, const render::Transition* transition) {
if (transition == nullptr || transition->isFinished) {
_isFading = false;
}
});
scene->enqueueTransaction(transaction);
void Avatar::updateFadingStatus() {
if (_isFading) {
render::Transaction transaction;
transaction.queryTransitionOnItem(_renderItemID, [this](render::ItemID id, const render::Transition* transition) {
if (!transition || transition->isFinished) {
_isFading = false;
}
});
AbstractViewStateInterface::instance()->getMain3DScene()->enqueueTransaction(transaction);
}
}
void Avatar::removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {

View file

@ -409,7 +409,7 @@ public:
void fadeIn(render::ScenePointer scene);
void fadeOut(render::ScenePointer scene, KillAvatarReason reason);
bool isFading() const { return _isFading; }
void updateFadingStatus(render::ScenePointer scene);
void updateFadingStatus();
// JSDoc is in AvatarData.h.
Q_INVOKABLE virtual float getEyeHeight() const override;

View file

@ -30,6 +30,5 @@ void main(void) {
float(frontCondition) * interpolatedNormal,
texel.a * varColor.a,
color * texel.rgb,
vec3(0.01, 0.01, 0.01),
10.0);
}

View file

@ -48,6 +48,5 @@ void main(void) {
interpolatedNormal * float(frontCondition),
texel.a * varColor.a,
polyline.color * texel.rgb + fadeEmissive,
vec3(0.01, 0.01, 0.01),
10.0);
}

View file

@ -982,7 +982,7 @@ HFMModel::Pointer OBJReader::readOBJ(QByteArray& data, const QVariantHash& mappi
modelMaterial->setMetallic(ILLUMINATION_MODEL_APPLY_NON_METALLIC);
}
if (fresnelOn) {
modelMaterial->setFresnel(glm::vec3(1.0f));
// TODO: how to turn fresnel on?
}
modelMaterial->setOpacity(hfmMaterial.opacity);

View file

@ -22,7 +22,7 @@ struct GPUTextureTable {
#define tableTex(name, slot) sampler2D(name._textures[slot].xy)
#define tableTexMinLod(name, slot) float(name._textures[slot].z)
#define tableTexValue(name, slot, uv) tableTexValueLod(tableTex(matTex, albedoMap), tableTexMinLod(matTex, albedoMap), uv)
#define tableTexValue(name, slot, uv) tableTexValueLod(tableTex(matTex, slot), tableTexMinLod(matTex, slot), uv)
vec4 tableTexValueLod(sampler2D sampler, float minLod, vec2 uv) {
float queryLod = textureQueryLod(sampler, uv).x;

View file

@ -38,7 +38,7 @@ QMap<QString,int> ATTRIBUTES{
{"position", gpu::Stream::POSITION },
{"normal", gpu::Stream::NORMAL },
{"color", gpu::Stream::COLOR },
{"tangent", gpu::Stream::TEXCOORD0 },
{"tangent", gpu::Stream::TANGENT },
{"skin_cluster_index", gpu::Stream::SKIN_CLUSTER_INDEX },
{"skin_cluster_weight", gpu::Stream::SKIN_CLUSTER_WEIGHT },
{"texcoord0", gpu::Stream::TEXCOORD0 },

View file

@ -58,7 +58,7 @@ Material& Material::operator= (const Material& material) {
Material::~Material() {
}
void Material::setEmissive(const Color& emissive, bool isSRGB) {
void Material::setEmissive(const Color& emissive, bool isSRGB) {
_key.setEmissive(glm::any(glm::greaterThan(emissive, Color(0.0f))));
_schemaBuffer.edit<Schema>()._key = (uint32) _key._flags.to_ulong();
_schemaBuffer.edit<Schema>()._emissive = (isSRGB ? ColorUtils::sRGBToLinearVec3(emissive) : emissive);
@ -88,11 +88,6 @@ void Material::setRoughness(float roughness) {
_schemaBuffer.edit<Schema>()._roughness = roughness;
}
void Material::setFresnel(const Color& fresnel, bool isSRGB) {
//_key.setAlbedo(glm::any(glm::greaterThan(albedo, Color(0.0f))));
_schemaBuffer.edit<Schema>()._fresnel = (isSRGB ? ColorUtils::sRGBToLinearVec3(fresnel) : fresnel);
}
void Material::setMetallic(float metallic) {
metallic = glm::clamp(metallic, 0.0f, 1.0f);
_key.setMetallic(metallic > 0.0f);

View file

@ -294,9 +294,6 @@ public:
void setAlbedo(const Color& albedo, bool isSRGB = true);
Color getAlbedo(bool SRGB = true) const { return (SRGB ? ColorUtils::tosRGBVec3(_schemaBuffer.get<Schema>()._albedo) : _schemaBuffer.get<Schema>()._albedo); }
void setFresnel(const Color& fresnel, bool isSRGB = true);
Color getFresnel(bool SRGB = true) const { return (SRGB ? ColorUtils::tosRGBVec3(_schemaBuffer.get<Schema>()._fresnel) : _schemaBuffer.get<Schema>()._fresnel); }
void setMetallic(float metallic);
float getMetallic() const { return _schemaBuffer.get<Schema>()._metallic; }
@ -309,23 +306,24 @@ public:
// Schema to access the attribute values of the material
class Schema {
public:
glm::vec3 _emissive{ 0.0f }; // No Emissive
float _opacity{ 1.0f }; // Opacity = 1 => Not Transparent
glm::vec3 _emissive { 0.0f }; // No Emissive
float _opacity { 1.0f }; // Opacity = 1 => Not Transparent
glm::vec3 _albedo{ 0.5f }; // Grey albedo => isAlbedo
float _roughness{ 1.0f }; // Roughness = 1 => Not Glossy
glm::vec3 _fresnel{ 0.03f }; // Fresnel value for a default non metallic
float _metallic{ 0.0f }; // Not Metallic
float _scattering{ 0.0f }; // Scattering info
glm::vec3 _albedo { 0.5f }; // Grey albedo => isAlbedo
float _roughness { 1.0f }; // Roughness = 1 => Not Glossy
float _metallic { 0.0f }; // Not Metallic
float _scattering { 0.0f }; // Scattering info
#if defined(__clang__)
__attribute__((unused))
#endif
glm::vec2 _spare{ 0.0f }; // Padding
glm::vec2 _spare { 0.0f }; // Padding
uint32_t _key{ 0 }; // a copy of the materialKey
uint32_t _key { 0 }; // a copy of the materialKey
#if defined(__clang__)
__attribute__((unused))
#endif
glm::vec3 _spare2 { 0.0f };
// for alignment beauty, Material size == Mat4x4

View file

@ -44,11 +44,11 @@ struct TexMapArray {
struct Material {
vec4 _emissiveOpacity;
vec4 _albedoRoughness;
vec4 _fresnelMetallic;
vec4 _scatteringSpare2Key;
vec4 _metallicScatteringSpare2;
vec4 _keySpare3;
};
LAYOUT(binding=GRAPHICS_BUFFER_MATERIAL) uniform materialBuffer {
LAYOUT_STD140(binding=GRAPHICS_BUFFER_MATERIAL) uniform materialBuffer {
Material _mat;
TexMapArray _texMapArray;
};
@ -65,15 +65,12 @@ float getMaterialOpacity(Material m) { return m._emissiveOpacity.a; }
vec3 getMaterialAlbedo(Material m) { return m._albedoRoughness.rgb; }
float getMaterialRoughness(Material m) { return m._albedoRoughness.a; }
vec3 getMaterialFresnel(Material m) { return m._fresnelMetallic.rgb; }
float getMaterialMetallic(Material m) { return m._fresnelMetallic.a; }
float getMaterialShininess(Material m) { return 1.0 - getMaterialRoughness(m); }
float getMaterialScattering(Material m) { return m._scatteringSpare2Key.x; }
float getMaterialMetallic(Material m) { return m._metallicScatteringSpare2.x; }
float getMaterialScattering(Material m) { return m._metallicScatteringSpare2.y; }
BITFIELD getMaterialKey(Material m) { return floatBitsToInt(m._scatteringSpare2Key.w); }
BITFIELD getMaterialKey(Material m) { return floatBitsToInt(m._keySpare3.x); }
const BITFIELD EMISSIVE_VAL_BIT = 0x00000001;
const BITFIELD UNLIT_VAL_BIT = 0x00000002;

View file

@ -171,12 +171,12 @@ float fetchScatteringMap(vec2 uv) {
<@endif@>
<@endfunc@>
<@func fetchMaterialTexturesCoord1(matKey, texcoord1, occlusion, lightmapVal)@>
<@func fetchMaterialTexturesCoord1(matKey, texcoord1, occlusion, lightmap)@>
<@if occlusion@>
float <$occlusion$> = (((<$matKey$> & OCCLUSION_MAP_BIT) != 0) ? fetchOcclusionMap(<$texcoord1$>) : 1.0);
<@endif@>
<@if lightmapVal@>
vec3 <$lightmapVal$> = fetchLightmapMap(<$texcoord1$>);
<@if lightmap@>
vec3 <$lightmap$> = fetchLightmapMap(<$texcoord1$>);
<@endif@>
<@endfunc@>
@ -193,16 +193,6 @@ vec3 fetchLightmapMap(vec2 uv) {
}
<@endfunc@>
<@func evalMaterialNormal(fetchedNormal, interpolatedNormal, interpolatedTangent, normal)@>
{
vec3 normalizedNormal = normalize(<$interpolatedNormal$>.xyz);
vec3 normalizedTangent = normalize(<$interpolatedTangent$>.xyz);
vec3 normalizedBitangent = cross(normalizedNormal, normalizedTangent);
vec3 localNormal = <$fetchedNormal$>;
<$normal$> = vec3(normalizedBitangent * localNormal.x + normalizedNormal * localNormal.y + normalizedTangent * localNormal.z);
}
<@endfunc@>
<@func evalMaterialNormalLOD(fragPosES, fetchedNormal, interpolatedNormal, interpolatedTangent, normal)@>
{
vec3 normalizedNormal = normalize(<$interpolatedNormal$>.xyz);

View file

@ -16,7 +16,6 @@
#define GRAPHICS_BUFFER_SKINNING 0
#define GRAPHICS_BUFFER_MATERIAL 1
#define GRAPHICS_BUFFER_TEXMAPARRAY 2
#define GRAPHICS_BUFFER_KEY_LIGHT 4
#define GRAPHICS_BUFFER_LIGHT 5
#define GRAPHICS_BUFFER_AMBIENT_LIGHT 6
@ -41,7 +40,6 @@ namespace buffer {
enum Buffer {
Skinning = GRAPHICS_BUFFER_SKINNING,
Material = GRAPHICS_BUFFER_MATERIAL,
TexMapArray = GRAPHICS_BUFFER_TEXMAPARRAY,
Light = GRAPHICS_BUFFER_LIGHT,
KeyLight = GRAPHICS_BUFFER_KEY_LIGHT,
AmbientLight = GRAPHICS_BUFFER_AMBIENT_LIGHT,

View file

@ -39,7 +39,7 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness
_fragColor3 = vec4(isEmissiveEnabled() * emissive, 1.0);
}
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 fresnel, vec3 lightmap) {
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 lightmap) {
if (alpha != 1.0) {
discard;
}
@ -61,7 +61,7 @@ void packDeferredFragmentUnlit(vec3 normal, float alpha, vec3 color) {
_fragColor3 = vec4(color, 1.0);
}
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness) {
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, float roughness) {
if (alpha <= 0.0) {
discard;
}

View file

@ -85,7 +85,11 @@ float evalFadeGradient(FadeObjectParams params, vec3 position) {
}
float evalFadeAlpha(FadeObjectParams params, vec3 position) {
return evalFadeGradient(params, position)-params.threshold;
float alpha = evalFadeGradient(params, position)-params.threshold;
if (fadeParameters[params.category]._isInverted != 0) {
alpha = -alpha;
}
return alpha;
}
void applyFadeClip(FadeObjectParams params, vec3 position) {
@ -96,9 +100,6 @@ void applyFadeClip(FadeObjectParams params, vec3 position) {
void applyFade(FadeObjectParams params, vec3 position, out vec3 emissive) {
float alpha = evalFadeAlpha(params, position);
if (fadeParameters[params.category]._isInverted!=0) {
alpha = -alpha;
}
if (alpha < 0.0) {
discard;

View file

@ -826,7 +826,7 @@ render::ShapePipelinePointer GeometryCache::getFadingShapePipeline(bool textured
bool unlit, bool depthBias) {
auto fadeEffect = DependencyManager::get<FadeEffect>();
auto fadeBatchSetter = fadeEffect->getBatchSetter();
auto fadeItemSetter = fadeEffect->getItemStoredSetter();
auto fadeItemSetter = fadeEffect->getItemUniformSetter();
return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, culled, unlit, depthBias, true), nullptr,
[fadeBatchSetter, fadeItemSetter](const render::ShapePipeline& shapePipeline, gpu::Batch& batch, render::Args* args) {
batch.setResourceTexture(gr::Texture::MaterialAlbedo, DependencyManager::get<TextureCache>()->getWhiteTexture());

View file

@ -22,6 +22,8 @@
#include "GeometryCache.h"
#include "CubeProjectedPolygon.h"
#include "FadeEffect.h"
#include "render-utils/ShaderConstants.h"
using namespace render;
@ -37,7 +39,7 @@ namespace gr {
#define OUTLINE_STENCIL_MASK 1
extern void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state);
extern void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter);
HighlightResources::HighlightResources() {
}
@ -156,7 +158,6 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
auto& highlight = highlightStage->getHighlight(highlightId);
RenderArgs* args = renderContext->args;
ShapeKey::Builder defaultKeyBuilder;
// Render full screen
outputs = args->_viewport;
@ -177,10 +178,6 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
gpu::doInBatch("DrawHighlightMask::run", args->_context, [&](gpu::Batch& batch) {
args->_batch = &batch;
auto maskPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder);
auto maskDeformedPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withDeformed());
auto maskDeformedDQPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withDeformed().withDualQuatSkinned());
// Setup camera, projection and viewport for all items
glm::mat4 projMat;
Transform viewMat;
@ -191,38 +188,54 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
batch.setProjectionJitter(jitter.x, jitter.y);
batch.setViewTransform(viewMat);
std::vector<ShapeKey> deformedShapeKeys;
std::vector<ShapeKey> deformedDQShapeKeys;
const std::vector<ShapeKey::Builder> keys = {
ShapeKey::Builder(), ShapeKey::Builder().withFade(),
ShapeKey::Builder().withDeformed(), ShapeKey::Builder().withDeformed().withFade(),
ShapeKey::Builder().withDeformed().withDualQuatSkinned(), ShapeKey::Builder().withDeformed().withDualQuatSkinned().withFade(),
ShapeKey::Builder().withOwnPipeline(), ShapeKey::Builder().withOwnPipeline().withFade()
};
std::vector<std::vector<ShapeKey>> sortedShapeKeys(keys.size());
// Iterate through all inShapes and render the unskinned
args->_shapePipeline = maskPipeline;
batch.setPipeline(maskPipeline->pipeline);
const int OWN_PIPELINE_INDEX = 6;
for (const auto& items : inShapes) {
itemBounds.insert(itemBounds.end(), items.second.begin(), items.second.end());
if (items.first.isDeformed() && items.first.isDualQuatSkinned()) {
deformedDQShapeKeys.push_back(items.first);
} else if (items.first.isDeformed()) {
deformedShapeKeys.push_back(items.first);
} else {
renderItems(renderContext, items.second);
int index = items.first.hasOwnPipeline() ? OWN_PIPELINE_INDEX : 0;
if (items.first.isDeformed()) {
index += 2;
if (items.first.isDualQuatSkinned()) {
index += 2;
}
}
if (items.first.isFaded()) {
index += 1;
}
sortedShapeKeys[index].push_back(items.first);
}
// Render non-withOwnPipeline things
for (size_t i = 0; i < OWN_PIPELINE_INDEX; i++) {
auto& shapeKeys = sortedShapeKeys[i];
if (shapeKeys.size() > 0) {
const auto& shapePipeline = _shapePlumber->pickPipeline(args, keys[i]);
args->_shapePipeline = shapePipeline;
for (const auto& key : shapeKeys) {
renderShapes(renderContext, _shapePlumber, inShapes.at(key));
}
}
}
// Reiterate to render the skinned
if (deformedShapeKeys.size() > 0) {
args->_shapePipeline = maskDeformedPipeline;
batch.setPipeline(maskDeformedPipeline->pipeline);
for (const auto& key : deformedShapeKeys) {
renderItems(renderContext, inShapes.at(key));
}
}
// Reiterate to render the DQ skinned
if (deformedDQShapeKeys.size() > 0) {
args->_shapePipeline = maskDeformedDQPipeline;
batch.setPipeline(maskDeformedDQPipeline->pipeline);
for (const auto& key : deformedDQShapeKeys) {
renderItems(renderContext, inShapes.at(key));
// Render withOwnPipeline things
for (size_t i = OWN_PIPELINE_INDEX; i < keys.size(); i++) {
auto& shapeKeys = sortedShapeKeys[i];
if (shapeKeys.size() > 0) {
args->_shapePipeline = nullptr;
for (const auto& key : shapeKeys) {
args->_itemShapeKey = key._flags.to_ulong();
renderShapes(renderContext, _shapePlumber, inShapes.at(key));
}
}
}
@ -497,7 +510,9 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren
state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setColorWriteMask(false, false, false, false);
initZPassPipelines(*shapePlumber, state);
auto fadeEffect = DependencyManager::get<FadeEffect>();
initZPassPipelines(*shapePlumber, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
}
auto sharedParameters = std::make_shared<HighlightSharedParameters>();

View file

@ -40,7 +40,7 @@ namespace gr {
void initDeferredPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter);
void initForwardPipelines(ShapePlumber& plumber);
void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state);
void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter);
void addPlumberPipeline(ShapePlumber& plumber,
const ShapeKey& key, int programId,
@ -201,31 +201,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent().withTangents().withFade(),
deformed_model_normal_map_translucent_fade_dq, batchSetter, itemSetter);
// Depth-only
addPipeline(
Key::Builder().withDepthOnly(),
model_shadow, nullptr, nullptr);
addPipeline(
Key::Builder().withDeformed().withDepthOnly(),
deformed_model_shadow, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withDepthOnly().withFade(),
model_shadow_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withDeformed().withDepthOnly().withFade(),
deformed_model_shadow_fade, batchSetter, itemSetter);
// Now repeat for dual quaternion
// Depth-only
addPipeline(
Key::Builder().withDeformed().withDualQuatSkinned().withDepthOnly(),
deformed_model_shadow_dq, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withDeformed().withDualQuatSkinned().withDepthOnly().withFade(),
deformed_model_shadow_fade_dq, batchSetter, itemSetter);
}
void initForwardPipelines(ShapePlumber& plumber) {
@ -254,7 +229,7 @@ void initForwardPipelines(ShapePlumber& plumber) {
// Opaques
addPipeline(Key::Builder().withMaterial(), program::forward_model);
addPipeline(Key::Builder().withMaterial().withUnlit(), program::forward_model_unlit);
addPipeline(Key::Builder().withMaterial().withTangents(), program::forward_model_translucent);
addPipeline(Key::Builder().withMaterial().withTangents(), program::forward_model_normal_map);
// Deformed Opaques
addPipeline(Key::Builder().withMaterial().withDeformed(), program::forward_deformed_model);
@ -272,6 +247,8 @@ void initForwardPipelines(ShapePlumber& plumber) {
addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent().withDualQuatSkinned(), program::forward_deformed_translucent_dq);
addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents().withDualQuatSkinned(), program::forward_deformed_translucent_normal_map_dq);
// FIXME: incorrent pipelines for normal mapped + translucent models
forceLightBatchSetter = false;
}
@ -362,37 +339,29 @@ void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderAr
}
}
void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state) {
void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state, const render::ShapePipeline::BatchSetter& extraBatchSetter, const render::ShapePipeline::ItemSetter& itemSetter) {
using namespace shader::render_utils::program;
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(model_shadow);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutDeformed().withoutFade(),
modelProgram, state);
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(deformed_model_shadow);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withoutDualQuatSkinned().withoutFade(),
skinProgram, state);
gpu::ShaderPointer modelFadeProgram = gpu::Shader::createProgram(model_shadow_fade);
gpu::Shader::createProgram(model_shadow), state);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutDeformed().withFade(),
modelFadeProgram, state);
gpu::Shader::createProgram(model_shadow_fade), state, extraBatchSetter, itemSetter);
gpu::ShaderPointer skinFadeProgram = gpu::Shader::createProgram(deformed_model_shadow_fade);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withoutDualQuatSkinned().withoutFade(),
gpu::Shader::createProgram(deformed_model_shadow), state);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withoutDualQuatSkinned().withFade(),
skinFadeProgram, state);
gpu::Shader::createProgram(deformed_model_shadow_fade), state, extraBatchSetter, itemSetter);
gpu::ShaderPointer skinModelShadowDualQuatProgram = gpu::Shader::createProgram(deformed_model_shadow_dq);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withDualQuatSkinned().withoutFade(),
skinModelShadowDualQuatProgram, state);
gpu::ShaderPointer skinModelShadowFadeDualQuatProgram = gpu::Shader::createProgram(deformed_model_shadow_fade_dq);
gpu::Shader::createProgram(deformed_model_shadow_dq), state);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withDualQuatSkinned().withFade(),
skinModelShadowFadeDualQuatProgram, state);
gpu::Shader::createProgram(deformed_model_shadow_fade_dq), state, extraBatchSetter, itemSetter);
}
// FIXME find a better way to setup the default textures

View file

@ -26,6 +26,8 @@
#include "RenderCommonTask.h"
#include "FadeEffect.h"
// These values are used for culling the objects rendered in the shadow map
// but are readjusted afterwards
#define SHADOW_FRUSTUM_NEAR 1.0f
@ -33,7 +35,7 @@
using namespace render;
extern void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state);
extern void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter);
void RenderShadowTask::configure(const Config& configuration) {
DependencyManager::get<DeferredLightingEffect>()->setShadowMapEnabled(configuration.enabled);
@ -49,7 +51,8 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL);
initZPassPipelines(*shapePlumber, state);
auto fadeEffect = DependencyManager::get<FadeEffect>();
initZPassPipelines(*shapePlumber, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
}
// FIXME: calling this here before the zones/lights are drawn during the deferred/forward passes means we're actually using the frames from the previous draw
@ -222,7 +225,6 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con
auto& fbo = cascade.framebuffer;
RenderArgs* args = renderContext->args;
ShapeKey::Builder defaultKeyBuilder;
auto adjustedShadowFrustum = args->getViewFrustum();
// Adjust the frustum near and far depths based on the rendered items bounding box to have
@ -253,53 +255,56 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con
batch.setProjectionTransform(projMat);
batch.setViewTransform(viewMat, false);
auto shadowPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder);
auto shadowDeformedPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withDeformed());
auto shadowDeformedDQPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withDeformed().withDualQuatSkinned());
const std::vector<ShapeKey::Builder> keys = {
ShapeKey::Builder(), ShapeKey::Builder().withFade(),
ShapeKey::Builder().withDeformed(), ShapeKey::Builder().withDeformed().withFade(),
ShapeKey::Builder().withDeformed().withDualQuatSkinned(), ShapeKey::Builder().withDeformed().withDualQuatSkinned().withFade(),
ShapeKey::Builder().withOwnPipeline(), ShapeKey::Builder().withOwnPipeline().withFade()
};
std::vector<std::vector<ShapeKey>> sortedShapeKeys(keys.size());
std::vector<ShapeKey> deformedShapeKeys{};
std::vector<ShapeKey> deformedDQShapeKeys{};
std::vector<ShapeKey> ownPipelineShapeKeys{};
// Iterate through all inShapes and render the unskinned
args->_shapePipeline = shadowPipeline;
batch.setPipeline(shadowPipeline->pipeline);
for (auto items : inShapes) {
const int OWN_PIPELINE_INDEX = 6;
for (const auto& items : inShapes) {
int index = items.first.hasOwnPipeline() ? OWN_PIPELINE_INDEX : 0;
if (items.first.isDeformed()) {
index += 2;
if (items.first.isDualQuatSkinned()) {
deformedDQShapeKeys.push_back(items.first);
} else {
deformedShapeKeys.push_back(items.first);
index += 2;
}
}
if (items.first.isFaded()) {
index += 1;
}
sortedShapeKeys[index].push_back(items.first);
}
// Render non-withOwnPipeline things
for (size_t i = 0; i < OWN_PIPELINE_INDEX; i++) {
auto& shapeKeys = sortedShapeKeys[i];
if (shapeKeys.size() > 0) {
const auto& shapePipeline = _shapePlumber->pickPipeline(args, keys[i]);
args->_shapePipeline = shapePipeline;
for (const auto& key : shapeKeys) {
renderShapes(renderContext, _shapePlumber, inShapes.at(key));
}
} else if (!items.first.hasOwnPipeline()) {
renderItems(renderContext, items.second);
} else {
ownPipelineShapeKeys.push_back(items.first);
}
}
// Reiterate to render the skinned
args->_shapePipeline = shadowDeformedPipeline;
batch.setPipeline(shadowDeformedPipeline->pipeline);
for (const auto& key : deformedShapeKeys) {
renderItems(renderContext, inShapes.at(key));
// Render withOwnPipeline things
for (size_t i = OWN_PIPELINE_INDEX; i < keys.size(); i++) {
auto& shapeKeys = sortedShapeKeys[i];
if (shapeKeys.size() > 0) {
args->_shapePipeline = nullptr;
for (const auto& key : shapeKeys) {
args->_itemShapeKey = key._flags.to_ulong();
renderShapes(renderContext, _shapePlumber, inShapes.at(key));
}
}
}
// Reiterate to render the DQ skinned
args->_shapePipeline = shadowDeformedDQPipeline;
batch.setPipeline(shadowDeformedDQPipeline->pipeline);
for (const auto& key : deformedDQShapeKeys) {
renderItems(renderContext, inShapes.at(key));
}
// Finally render the items with their own pipeline last to prevent them from breaking the
// render state. This is probably a temporary code as there is probably something better
// to do in the render call of objects that have their own pipeline.
args->_shapePipeline = nullptr;
for (const auto& key : ownPipelineShapeKeys) {
args->_itemShapeKey = key._flags.to_ulong();
renderItems(renderContext, inShapes.at(key));
}
}
args->_batch = nullptr;

View file

@ -31,7 +31,6 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal,

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_model.frag
// fragment shader
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 High Fidelity, Inc.
//
@ -12,15 +10,16 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<@include DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
@ -56,8 +55,12 @@ void main(void) {
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal = normalize(_normalWS);
@ -66,7 +69,7 @@ void main(void) {
vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPosition,
fragNormal,
albedo,

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_model_normal_map.frag
// fragment shader
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 High Fidelity, Inc.
//
@ -12,13 +10,16 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<@include DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
@ -55,18 +56,22 @@ void main(void) {
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal;
<$evalMaterialNormal(normalTex, _normalWS, _tangentWS, fragNormal)$>
<$evalMaterialNormalLOD(fragPosition, normalTex, _normalWS, _tangentWS, fragNormal)$>
TransformCamera cam = getTransformCamera();
vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPosition,
fragNormal,
albedo,
@ -74,7 +79,6 @@ void main(void) {
metallic,
roughness),
opacity);
color.rgb += emissive * isEmissiveEnabled();
_fragColor0 = color;

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_model_translucent.frag
// fragment shader
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 High Fidelity, Inc.
//
@ -12,13 +10,16 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<@include DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include ForwardGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlended()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
@ -51,8 +52,12 @@ void main(void) {
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
@ -64,7 +69,7 @@ void main(void) {
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPosition,
fragNormal,
albedo,

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_model_unlit.frag
// fragment shader
//
// Created by Sam Gateau on 5/5/2016.
// Copyright 2016 High Fidelity, Inc.
//
@ -12,11 +10,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include LightingModel.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightingModel.slh@>
<$declareMaterialTextures(ALBEDO)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
@ -27,7 +26,6 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
@ -40,8 +38,5 @@ void main(void) {
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
if (opacity != 1.0) {
discard;
}
_fragColor0 = vec4(albedo * isUnlitEnabled(), 1.0);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model.frag
// fragment shader
//
// Created by Andrzej Kapolka on 5/6/14.
// Copyright 2014 High Fidelity, Inc.
//
@ -42,11 +40,14 @@ void main(void) {
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
@ -58,6 +59,6 @@ void main(void) {
roughness,
metallic,
emissive,
occlusionTex,
occlusion,
scattering);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_fade.frag
// fragment shader
//
// Created by Olivier Prat on 06/05/17.
// Copyright 2017 High Fidelity, Inc.
//
@ -13,17 +11,15 @@
//
<@include DeferredBufferWrite.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
@ -34,13 +30,12 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, scatteringTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = 1.0;
@ -54,13 +49,17 @@ void main(void) {
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
packDeferredFragment(
normalize(_normalWS),
@ -68,7 +67,7 @@ void main(void) {
albedo,
roughness,
metallic,
emissive+fadeEmissive,
occlusionTex,
emissive + fadeEmissive,
occlusion,
scattering);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_lightmap.frag
// fragment shader
//
// Created by Samuel Gateau on 11/19/14.
// Copyright 2014 High Fidelity, Inc.
//
@ -20,7 +18,6 @@
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
<$declareMaterialLightmap()$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
@ -30,15 +27,24 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
packDeferredFragmentLightmap(
normalize(_normalWS),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
getMaterialAlbedo(mat) * albedo.rgb * _color.rgb,
getMaterialRoughness(mat) * roughness,
getMaterialMetallic(mat) * metallicTex,
/*metallicTex, // no use of */getMaterialFresnel(mat),
lightmapVal);
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
albedo,
roughness,
metallic,
lightmap);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_lightmap_fade.frag
// fragment shader
//
// Created by Olivier Prat on 06/05/17.
// Copyright 2017 High Fidelity, Inc.
//
@ -13,18 +11,16 @@
//
<@include DeferredBufferWrite.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
<$declareMaterialLightmap()$>
<@include Fade.slh@>
<$declareFadeFragment()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
@ -35,21 +31,29 @@ layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
packDeferredFragmentLightmap(
normalize(_normalWS),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
getMaterialAlbedo(mat) * albedo.rgb * _color.rgb,
getMaterialRoughness(mat) * roughness,
getMaterialMetallic(mat) * metallicTex,
/*metallicTex, // no use of */getMaterialFresnel(mat),
lightmapVal+fadeEmissive);
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
albedo,
roughness,
metallic,
lightmap + fadeEmissive);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_lightmap_normal_map.frag
// fragment shader
//
// Created by Samuel Gateau on 11/19/14.
// Copyright 2014 High Fidelity, Inc.
//
@ -31,18 +29,27 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fragNormal;
<$evalMaterialNormalLOD(_positionES, normalTexel, _normalWS, _tangentWS, fragNormal)$>
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormal)$>
packDeferredFragmentLightmap(
normalize(fragNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
getMaterialAlbedo(mat) * albedo.rgb * _color.rgb,
getMaterialRoughness(mat) * roughness,
getMaterialMetallic(mat) * metallicTex,
/*specular, // no use of */ getMaterialFresnel(mat),
lightmapVal);
normalize(fragNormal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
albedo,
roughness,
metallic,
lightmap);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_lightmap_normal_map_fade.frag
// fragment shader
//
// Created by Olivier Prat on 06/05/17.
// Copyright 2017 High Fidelity, Inc.
//
@ -13,18 +11,17 @@
//
<@include DeferredBufferWrite.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$>
<$declareMaterialLightmap()$>
<@include Fade.slh@>
<$declareFadeFragment()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
@ -32,29 +29,36 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fragNormal;
<$evalMaterialNormalLOD(_positionES, normalTexel, _normalWS, _tangentWS, fragNormal)$>
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormal)$>
packDeferredFragmentLightmap(
normalize(fragNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
getMaterialAlbedo(mat) * albedo.rgb * _color.rgb,
getMaterialRoughness(mat) * roughness,
getMaterialMetallic(mat) * metallicTex,
/*specular, // no use of */ getMaterialFresnel(mat),
lightmapVal+fadeEmissive);
normalize(fragNormal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
albedo,
roughness,
metallic,
lightmap + fadeEmissive);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_normal_map.frag
// fragment shader
//
// Created by Andrzej Kapolka on 5/6/14.
// Copyright 2014 High Fidelity, Inc.
//
@ -44,25 +42,28 @@ void main(void) {
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
vec3 fragNormalWS;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
vec3 fragNormalWS;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
packDeferredFragment(
normalize(fragNormalWS.xyz),
normalize(fragNormalWS),
opacity,
albedo,
roughness,
metallic,
emissive,
occlusionTex,
occlusion,
scattering);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_normal_map_fade.frag
// fragment shader
//
// Created by Olivier Prat on 06/05/17.
// Copyright 2017 High Fidelity, Inc.
//
@ -16,10 +14,10 @@
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
<@include Fade.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
@ -34,13 +32,12 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = 1.0;
@ -54,24 +51,28 @@ void main(void) {
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
vec3 fragNormalWS;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
float scattering = getMaterialScattering(mat);
packDeferredFragment(
normalize(fragNormalWS.xyz),
normalize(fragNormalWS),
opacity,
albedo,
roughness,
metallic,
emissive + fadeEmissive,
occlusionTex,
occlusion,
scattering);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_shadow.frag
// fragment shader
//
// Created by Andrzej Kapolka on 3/24/14.
// Copyright 2013 High Fidelity, Inc.
//

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_shadow_fade.frag
// fragment shader
//
// Created by Olivier Prat on 06/05/17.
// Copyright 2017 High Fidelity, Inc.
//
@ -12,19 +10,17 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include Fade.slh@>
<@include render-utils/ShaderConstants.h@>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=0) out vec4 _fragColor;
void main(void) {
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFadeClip(fadeParams, _positionWS.xyz);

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_translucent.frag
// fragment shader
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 High Fidelity, Inc.
//
@ -12,19 +10,20 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<@include DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightLocal.slh@>
<@include ShadingModel.slh@>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
@ -39,7 +38,7 @@ layout(location=0) out vec4 _fragColor;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
@ -54,11 +53,16 @@ void main(void) {
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPositionES = _positionES.xyz;
vec3 fragPositionWS = _positionWS.xyz;
// Lighting is done in world space
@ -70,7 +74,6 @@ void main(void) {
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
@ -81,7 +84,7 @@ void main(void) {
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPositionES,
fragPositionWS,
albedo,

View file

@ -1,29 +1,33 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
// model_translucent_fade.frag
//
// Created by Olivier Prat on 06/05/17.
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightLocal.slh@>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include LightLocal.slh@>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
@ -37,13 +41,12 @@ layout(location=0) out vec4 _fragColor;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
@ -58,11 +61,16 @@ void main(void) {
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPositionES = _positionES.xyz;
vec3 fragPositionWS = _positionWS.xyz;
// Lighting is done in world space
@ -74,7 +82,6 @@ void main(void) {
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
@ -85,7 +92,7 @@ void main(void) {
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPositionES,
fragPositionWS,
albedo,

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_translucent_normal_map.frag
// fragment shader
//
// Created by Olivier Prat on 23/01/2018.
// Copyright 2018 High Fidelity, Inc.
//
@ -12,21 +10,20 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightLocal.slh@>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include LightLocal.slh@>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
@ -42,7 +39,7 @@ layout(location=0) out vec4 _fragColor;
void main(void) {
Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
@ -57,11 +54,16 @@ void main(void) {
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPositionES = _positionES.xyz;
vec3 fragPositionWS = _positionWS.xyz;
// Lighting is done in world space
@ -71,10 +73,9 @@ void main(void) {
TransformCamera cam = getTransformCamera();
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
SurfaceData surfaceWS = initSurfaceData(roughness, normalize(fragNormalWS), fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
@ -85,7 +86,7 @@ void main(void) {
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPositionES,
fragPositionWS,
albedo,

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_translucent_normal_map_fade.frag
// fragment shader
//
// Created by Olivier Prat on 23/01/18.
// Copyright 2018 High Fidelity, Inc.
//
@ -12,47 +10,44 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include render-utils/ShaderConstants.h@>
<@include DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightLocal.slh@>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include LightLocal.slh@>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=0) out vec4 _fragColor;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex)$>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
@ -67,11 +62,16 @@ void main(void) {
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPositionES = _positionES.xyz;
vec3 fragPositionWS = _positionWS.xyz;
// Lighting is done in world space
@ -81,10 +81,9 @@ void main(void) {
TransformCamera cam = getTransformCamera();
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
SurfaceData surfaceWS = initSurfaceData(roughness, normalize(fragNormalWS), fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
@ -95,7 +94,7 @@ void main(void) {
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPositionES,
fragPositionWS,
albedo,

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_translucent_unlit.frag
// fragment shader
//
// Created by Zach Pomerantz on 2/3/2016.
// Copyright 2016 High Fidelity, Inc.
//
@ -13,12 +11,12 @@
//
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
<@include render-utils/ShaderConstants.h@>
<@include LightingModel.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_translucent_unlit_fade.frag
// fragment shader
//
// Created by Olivier Prat on 06/05/17.
// Copyright 2017 High Fidelity, Inc.
//
@ -13,16 +11,16 @@
//
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
<@include render-utils/ShaderConstants.h@>
<@include LightingModel.slh@>
<$declareMaterialTextures(ALBEDO)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
@ -34,7 +32,6 @@ layout(location=0) out vec4 _fragColor;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
@ -50,5 +47,6 @@ void main(void) {
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
albedo += fadeEmissive;
_fragColor = vec4(albedo * isUnlitEnabled(), opacity);
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// material_opaque_unlit.frag
// fragment shader
//
// Created by Sam Gateau on 5/5/2016.
// Copyright 2016 High Fidelity, Inc.
//
@ -12,12 +10,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferWrite.slh@>
<@include LightingModel.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include DeferredBufferWrite.slh@>
<@include LightingModel.slh@>
<$declareMaterialTextures(ALBEDO)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
@ -27,7 +26,6 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// model_unlit_fade.frag
// fragment shader
//
// Created by Olivier Prat on 06/05/17.
// Copyright 2017 High Fidelity, Inc.
//
@ -12,13 +10,14 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferWrite.slh@>
<@include LightingModel.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include Fade.slh@>
<@include DeferredBufferWrite.slh@>
<@include LightingModel.slh@>
<@include Fade.slh@>
<$declareFadeFragment()$>
<$declareMaterialTextures(ALBEDO)$>
@ -33,7 +32,6 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
@ -49,6 +47,7 @@ void main(void) {
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
albedo += fadeEmissive;
packDeferredFragmentUnlit(
normalize(_normalWS),
opacity,

View file

@ -14,5 +14,5 @@
layout(location=0) in vec4 _color;
void main(void) {
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_FRESNEL, DEFAULT_ROUGHNESS);
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_ROUGHNESS);
}

View file

@ -60,6 +60,5 @@ void main() {
normalize(_normalWS),
a * params.color.a,
params.color.rgb,
DEFAULT_FRESNEL,
DEFAULT_ROUGHNESS);
}

View file

@ -75,7 +75,6 @@ void main(void) {
diffuse,
max(0.0, 1.0 - shininess / 128.0),
DEFAULT_METALLIC,
specular,
vec3(clamp(emissiveAmount, 0.0, 1.0)));
} else {
packDeferredFragment(

View file

@ -53,7 +53,6 @@ void main(void) {
normalize(_normalWS),
colorAlpha * texel.a,
_color.rgb * texel.rgb + fadeEmissive,
DEFAULT_FRESNEL,
DEFAULT_ROUGHNESS);
} else {
packDeferredFragment(

View file

@ -41,7 +41,6 @@ void main(void) {
normalize(_normalWS),
colorAlpha * texel.a,
_color.rgb * texel.rgb,
DEFAULT_FRESNEL,
DEFAULT_ROUGHNESS);
} else {
packDeferredFragmentUnlit(

View file

@ -53,7 +53,6 @@ void main(void) {
normalize(_normalWS),
colorAlpha * texel.a,
_color.rgb * texel.rgb+fadeEmissive,
DEFAULT_FRESNEL,
DEFAULT_ROUGHNESS);
} else {
packDeferredFragmentUnlit(

View file

@ -34,6 +34,5 @@ void main(void) {
normalize(_normalWS),
colorAlpha,
_color.rgb * texel.rgb,
DEFAULT_FRESNEL,
DEFAULT_ROUGHNESS);
}

View file

@ -34,6 +34,5 @@ void main(void) {
normalize(_normalWS),
_color.a,
_color.rgb * texel.rgb,
DEFAULT_FRESNEL,
DEFAULT_ROUGHNESS);
}

View file

@ -391,15 +391,17 @@ void Scene::transitionItems(const Transaction::TransitionAdds& transactions) {
// Remove pre-existing transition, if need be
if (!TransitionStage::isIndexInvalid(transitionId)) {
transitionStage->removeTransition(transitionId);
transitionId = TransitionStage::INVALID_INDEX;
resetItemTransition(itemId);
}
// Add a new one.
if (transitionType != Transition::NONE) {
transitionId = transitionStage->addTransition(itemId, transitionType, boundId);
}
setItemTransition(itemId, transitionId);
if (!TransitionStage::isIndexInvalid(transitionId)) {
setItemTransition(itemId, transitionId);
}
}
}
}

View file

@ -97,7 +97,6 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
locations->lightingModelBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::LightModel);
locations->skinClusterBufferUnit = reflection.validUniformBuffer(graphics::slot::buffer::Skinning);
locations->materialBufferUnit = reflection.validUniformBuffer(graphics::slot::buffer::Material);
locations->texMapArrayBufferUnit = reflection.validUniformBuffer(graphics::slot::buffer::TexMapArray);
locations->keyLightBufferUnit = reflection.validUniformBuffer(graphics::slot::buffer::KeyLight);
locations->lightBufferUnit = reflection.validUniformBuffer(graphics::slot::buffer::Light);
locations->lightAmbientBufferUnit = reflection.validUniformBuffer(graphics::slot::buffer::AmbientLight);

View file

@ -32,7 +32,6 @@ public:
UNLIT,
DEFORMED,
DUAL_QUAT_SKINNED,
DEPTH_ONLY,
DEPTH_BIAS,
WIREFRAME,
NO_CULL_FACE,
@ -80,7 +79,6 @@ public:
Builder& withUnlit() { _flags.set(UNLIT); return (*this); }
Builder& withDeformed() { _flags.set(DEFORMED); return (*this); }
Builder& withDualQuatSkinned() { _flags.set(DUAL_QUAT_SKINNED); return (*this); }
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); return (*this); }
Builder& withDepthBias() { _flags.set(DEPTH_BIAS); return (*this); }
Builder& withWireframe() { _flags.set(WIREFRAME); return (*this); }
Builder& withoutCullFace() { _flags.set(NO_CULL_FACE); return (*this); }
@ -133,9 +131,6 @@ public:
Builder& withDualQuatSkinned() { _flags.set(DUAL_QUAT_SKINNED); _mask.set(DUAL_QUAT_SKINNED); return (*this); }
Builder& withoutDualQuatSkinned() { _flags.reset(DUAL_QUAT_SKINNED); _mask.set(DUAL_QUAT_SKINNED); return (*this); }
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); }
Builder& withoutDepthOnly() { _flags.reset(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); }
Builder& withDepthBias() { _flags.set(DEPTH_BIAS); _mask.set(DEPTH_BIAS); return (*this); }
Builder& withoutDepthBias() { _flags.reset(DEPTH_BIAS); _mask.set(DEPTH_BIAS); return (*this); }
@ -171,7 +166,6 @@ public:
bool isTranslucent() const { return _flags[TRANSLUCENT]; }
bool isDeformed() const { return _flags[DEFORMED]; }
bool isDualQuatSkinned() const { return _flags[DUAL_QUAT_SKINNED]; }
bool isDepthOnly() const { return _flags[DEPTH_ONLY]; }
bool isDepthBiased() const { return _flags[DEPTH_BIAS]; }
bool isWireframe() const { return _flags[WIREFRAME]; }
bool isCullFace() const { return !_flags[NO_CULL_FACE]; }
@ -211,7 +205,6 @@ inline QDebug operator<<(QDebug debug, const ShapeKey& key) {
<< "isTranslucent:" << key.isTranslucent()
<< "isDeformed:" << key.isDeformed()
<< "isDualQuatSkinned:" << key.isDualQuatSkinned()
<< "isDepthOnly:" << key.isDepthOnly()
<< "isDepthBiased:" << key.isDepthBiased()
<< "isWireframe:" << key.isWireframe()
<< "isCullFace:" << key.isCullFace()
@ -239,7 +232,6 @@ public:
bool lightingModelBufferUnit{ false };
bool skinClusterBufferUnit{ false };
bool materialBufferUnit{ false };
bool texMapArrayBufferUnit{ false };
bool keyLightBufferUnit{ false };
bool lightBufferUnit{ false };
bool lightAmbientBufferUnit{ false };

View file

@ -86,22 +86,23 @@
type: "sphere",
dimensions: END_DIMENSIONS,
color: COLOR1,
ignoreRayIntersection: true
ignorePickIntersection: true
}
var end2 = {
type: "sphere",
dimensions: END_DIMENSIONS,
color: COLOR2,
ignoreRayIntersection: true
ignorePickIntersection: true
}
var laser = Pointers.createPointer(PickType.Ray, {
joint: "Mouse",
filter: Picks.PICK_ENTITIES,
filter: Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS | Picks.PICK_AVATARS,
renderStates: [{name: "one", end: end1}],
defaultRenderStates: [{name: "one", end: end2, distance: 2.0}],
enabled: true
});
Pointers.setRenderState(laser, "one");
var hoveredObject = undefined;
var HoveringList = "Hovering"
var hoveringStyle = {
@ -140,21 +141,41 @@
time = 0
}
}
Entities.hoverEnterEntity.connect(function (id, event) {
// print("hoverEnterEntity");
if (isSelectionEnabled) Selection.addToSelectedItemsList(HoveringList, "entity", id)
})
Entities.hoverOverEntity.connect(function (id, event) {
// print("hoverOverEntity");
})
Entities.hoverLeaveEntity.connect(function (id, event) {
if (isSelectionEnabled) Selection.removeFromSelectedItemsList(HoveringList, "entity", id)
// print("hoverLeaveEntity");
})
function getIntersectionTypeString(type) {
if (type === Picks.INTERSECTED_ENTITY) {
return "entity";
} else if (type === Picks.INTERSECTED_OVERLAY) {
return "overlay";
} else if (type === Picks.INTERSECTED_AVATAR) {
return "avatar";
}
}
function update() {
var result = Pointers.getPrevPickResult(laser);
if (result.intersects) {
// Hovering on something different
if (hoveredObject !== undefined && result.objectID !== hoveredObject.objectID) {
if (isSelectionEnabled) {
Selection.removeFromSelectedItemsList(HoveringList, getIntersectionTypeString(hoveredObject.type), hoveredObject.objectID)
}
}
// Hovering over something new
if (isSelectionEnabled) {
Selection.addToSelectedItemsList(HoveringList, getIntersectionTypeString(result.type), result.objectID);
hoveredObject = result;
}
} else if (hoveredObject !== undefined) {
// Stopped hovering
if (isSelectionEnabled) {
Selection.removeFromSelectedItemsList(HoveringList, getIntersectionTypeString(hoveredObject.type), hoveredObject.objectID)
hoveredObject = undefined;
}
}
}
Script.update.connect(update);
function cleanup() {
Pointers.removePointer(laser);