fixing review comments

This commit is contained in:
samcake 2015-09-21 22:42:24 -07:00
parent 91b9940fe9
commit 4513b64b00
6 changed files with 60 additions and 135 deletions

View file

@ -340,7 +340,7 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename
void ModelPackager::listTextures() {
_textures.clear();
foreach (FBXMaterial mat, _geometry->materials) {
foreach (const FBXMaterial mat, _geometry->materials) {
if (!mat.diffuseTexture.filename.isEmpty() && mat.diffuseTexture.content.isEmpty() &&
!_textures.contains(mat.diffuseTexture.filename)) {
_textures << mat.diffuseTexture.filename;

View file

@ -246,19 +246,19 @@ public:
glm::mat4 transformLink;
};
void appendModelIDs(const QString& parentID, const QMultiHash<QString, QString>& _connectionChildMap,
void appendModelIDs(const QString& parentID, const QMultiHash<QString, QString>& connectionChildMap,
QHash<QString, FBXModel>& models, QSet<QString>& remainingModels, QVector<QString>& modelIDs) {
if (remainingModels.contains(parentID)) {
modelIDs.append(parentID);
remainingModels.remove(parentID);
}
int parentIndex = modelIDs.size() - 1;
foreach (const QString& childID, _connectionChildMap.values(parentID)) {
foreach (const QString& childID, connectionChildMap.values(parentID)) {
if (remainingModels.contains(childID)) {
FBXModel& model = models[childID];
if (model.parentIndex == -1) {
model.parentIndex = parentIndex;
appendModelIDs(childID, _connectionChildMap, models, remainingModels, modelIDs);
appendModelIDs(childID, connectionChildMap, models, remainingModels, modelIDs);
}
}
}
@ -403,11 +403,11 @@ void addBlendshapes(const ExtractedBlendshape& extracted, const QList<WeightedIn
}
}
QString getTopModelID(const QMultiHash<QString, QString>& _connectionParentMap,
QString getTopModelID(const QMultiHash<QString, QString>& connectionParentMap,
const QHash<QString, FBXModel>& models, const QString& modelID) {
QString topID = modelID;
forever {
foreach (const QString& parentID, _connectionParentMap.values(topID)) {
foreach (const QString& parentID, connectionParentMap.values(topID)) {
if (models.contains(parentID)) {
topID = parentID;
goto outerContinue;

View file

@ -1,40 +1,40 @@
//
// Shader.cpp
// libraries/gpu/src/gpu
//
// Created by Sam Gateau on 2/27/2015.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Shader.h"
#include <math.h>
#include <QDebug>
#include "Context.h"
using namespace gpu;
Shader::Shader(Type type, const Source& source):
_source(source),
_type(type)
{
}
Shader::Shader(Type type, Pointer& vertex, Pointer& pixel):
_type(type)
{
_shaders.resize(2);
_shaders[VERTEX] = vertex;
_shaders[PIXEL] = pixel;
}
Shader::~Shader()
{
}
//
// Shader.cpp
// libraries/gpu/src/gpu
//
// Created by Sam Gateau on 2/27/2015.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Shader.h"
#include <math.h>
#include <QDebug>
#include "Context.h"
using namespace gpu;
Shader::Shader(Type type, const Source& source):
_source(source),
_type(type)
{
}
Shader::Shader(Type type, Pointer& vertex, Pointer& pixel):
_type(type)
{
_shaders.resize(2);
_shaders[VERTEX] = vertex;
_shaders[PIXEL] = pixel;
}
Shader::~Shader()
{
}
Shader* Shader::createVertex(const Source& source) {
Shader* shader = new Shader(VERTEX, source);
@ -71,28 +71,3 @@ bool Shader::makeProgram(Shader& shader, const Shader::BindingSet& bindings) {
}
return false;
}
// ShaderSource
ShaderSource::ShaderSource() {
}
ShaderSource::~ShaderSource() {
}
void ShaderSource::reset(const QUrl& url) {
_shaderUrl = url;
_gpuShader.reset();
}
void ShaderSource::resetShader(gpu::Shader* shader) {
_gpuShader.reset(shader);
}
bool ShaderSource::isDefined() const {
if (_gpuShader) {
return true;
} else {
return false;
}
}

View file

@ -189,27 +189,6 @@ protected:
typedef Shader::Pointer ShaderPointer;
typedef std::vector< ShaderPointer > Shaders;
// ShaderSource is the bridge between a URL or a a way to produce the final gpu::Shader that will be used to render it.
class ShaderSource {
public:
ShaderSource();
~ShaderSource();
const QUrl& getUrl() const { return _shaderUrl; }
const gpu::ShaderPointer getGPUShader() const { return _gpuShader; }
void reset(const QUrl& url);
void resetShader(gpu::Shader* texture);
bool isDefined() const;
protected:
gpu::ShaderPointer _gpuShader;
QUrl _shaderUrl;
};
typedef std::shared_ptr< ShaderSource > ShaderSourcePointer;
};

View file

@ -25,6 +25,8 @@ uniform materialBuffer {
Material getMaterial() {
return _mat;
}
<! // TODO: use this code for correct gamma correction
/*
float componentSRGBToLinear(float cs) {
// sRGB to linear conversion
@ -35,26 +37,27 @@ float componentSRGBToLinear(float cs) {
// T = 0.04045
// A = 1 / 1.055 = 0.94786729857
// B = 0.055 * A = 0.05213270142
// C = 1 / 12.92 = 0.0773993808
// G = 2.4
const float T = 0.04045;
const float A = 0.947867;
const float B = 0.052132;
const float C = 0.077399;
const float G = 2.4;
if (cs > T) {
return pow((cs * A + B), G);
} else {
return cs * C;
// C = 1 / 12.92 = 0.0773993808
// G = 2.4
const float T = 0.04045;
const float A = 0.947867;
const float B = 0.052132;
const float C = 0.077399;
const float G = 2.4;
if (cs > T) {
return pow((cs * A + B), G);
} else {
return cs * C;
}
}
vec3 SRGBToLinear(vec3 srgb) {
vec3 SRGBToLinear(vec3 srgb) {
return vec3(componentSRGBToLinear(srgb.x),componentSRGBToLinear(srgb.y),componentSRGBToLinear(srgb.z));
}
vec3 getMaterialDiffuse(Material m) { return (gl_FragCoord.x < 800 ? SRGBToLinear(m._diffuse.rgb) : m._diffuse.rgb); }
*/
*/!>
float getMaterialOpacity(Material m) { return m._diffuse.a; }
vec3 getMaterialDiffuse(Material m) { return m._diffuse.rgb; }
vec3 getMaterialSpecular(Material m) { return m._specular.rgb; }

View file

@ -17,36 +17,6 @@
<$declareStandardTransform()$>
/*
float componentSRGBToLinear(float cs) {
// sRGB to linear conversion
// { cs / 12.92, cs <= 0.04045
// cl = {
// { ((cs + 0.055)/1.055)^2.4, cs > 0.04045
// constants:
// T = 0.04045
// A = 1 / 1.055 = 0.94786729857
// B = 0.055 * A = 0.05213270142
// C = 1 / 12.92 = 0.0773993808
// G = 2.4
const float T = 0.04045;
const float A = 0.947867;
const float B = 0.052132;
const float C = 0.077399;
const float G = 2.4;
if (cs > T) {
return pow((cs * A + B), G);
} else {
return cs * C;
}
}
vec3 SRGBToLinear(vec3 srgb) {
return vec3(componentSRGBToLinear(srgb.x),componentSRGBToLinear(srgb.y),componentSRGBToLinear(srgb.z));
}
*/
const int MAX_TEXCOORDS = 2;
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
@ -60,8 +30,6 @@ void main(void) {
// pass along the diffuse color
_color = inColor.xyz;
// _color = SRGBToLinear(inColor.xyz);
// and the texture coordinates
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;