mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
MOving forward with PBR rendering, cleaning up the lighting shaders and the packi/unpack deferredBuffer shaders
This commit is contained in:
parent
d7b3945c4a
commit
39a7852979
38 changed files with 248 additions and 114 deletions
|
@ -26,8 +26,20 @@ Column {
|
||||||
ExclusiveGroup { id: bufferGroup }
|
ExclusiveGroup { id: bufferGroup }
|
||||||
Repeater {
|
Repeater {
|
||||||
model: [
|
model: [
|
||||||
"Off", "Diffuse", "Metallic", "Roughness", "Normal", "Depth",
|
"Off",
|
||||||
"Lighting", "Shadow", "Pyramid Depth", "Ambient Occlusion", "Custom Shader"
|
"Depth",
|
||||||
|
"Diffuse",
|
||||||
|
"Normal",
|
||||||
|
"Roughness",
|
||||||
|
"Metallic",
|
||||||
|
"Fresnel",
|
||||||
|
"Emissive",
|
||||||
|
"Lightmap",
|
||||||
|
"Lighting",
|
||||||
|
"Shadow",
|
||||||
|
"Pyramid Depth",
|
||||||
|
"Ambient Occlusion",
|
||||||
|
"Custom Shader"
|
||||||
]
|
]
|
||||||
RadioButton {
|
RadioButton {
|
||||||
text: qsTr(modelData)
|
text: qsTr(modelData)
|
||||||
|
|
|
@ -28,9 +28,6 @@ void main(void) {
|
||||||
vec3 worldNormal = cross(dFdy(_worldPosition.xyz), dFdx(_worldPosition.xyz));
|
vec3 worldNormal = cross(dFdy(_worldPosition.xyz), dFdx(_worldPosition.xyz));
|
||||||
worldNormal = normalize(worldNormal);
|
worldNormal = normalize(worldNormal);
|
||||||
|
|
||||||
vec3 specular = DEFAULT_SPECULAR;
|
|
||||||
float shininess = DEFAULT_SHININESS;
|
|
||||||
|
|
||||||
float inPositionX = (_worldPosition.x - 0.5) / voxelVolumeSize.x;
|
float inPositionX = (_worldPosition.x - 0.5) / voxelVolumeSize.x;
|
||||||
float inPositionY = (_worldPosition.y - 0.5) / voxelVolumeSize.y;
|
float inPositionY = (_worldPosition.y - 0.5) / voxelVolumeSize.y;
|
||||||
float inPositionZ = (_worldPosition.z - 0.5) / voxelVolumeSize.z;
|
float inPositionZ = (_worldPosition.z - 0.5) / voxelVolumeSize.z;
|
||||||
|
@ -44,5 +41,5 @@ void main(void) {
|
||||||
vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(worldNormal.x);
|
vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(worldNormal.x);
|
||||||
vec4 diffuse = vec4(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled, 1.0);
|
vec4 diffuse = vec4(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled, 1.0);
|
||||||
|
|
||||||
packDeferredFragment(_normal, 1.0, vec3(diffuse), specular, shininess);
|
packDeferredFragment(_normal, 1.0, vec3(diffuse), DEFAULT_ROUGHNESS, DEFAULT_METALLIC, DEFAULT_SPECULAR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,8 +162,6 @@ GLBackend::GLShader* compileShader(const Shader& shader) {
|
||||||
char* temp = new char[infoLength] ;
|
char* temp = new char[infoLength] ;
|
||||||
glGetShaderInfoLog(glshader, infoLength, NULL, temp);
|
glGetShaderInfoLog(glshader, infoLength, NULL, temp);
|
||||||
|
|
||||||
qCWarning(gpulogging) << "GLShader::compileShader - failed to compile the gl shader object:";
|
|
||||||
qCWarning(gpulogging) << temp;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
filestream.open("debugshader.glsl.info.txt");
|
filestream.open("debugshader.glsl.info.txt");
|
||||||
|
@ -173,7 +171,10 @@ GLBackend::GLShader* compileShader(const Shader& shader) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
qCWarning(gpulogging) << "GLShader::compileShader - failed to compile the gl shader object:";
|
||||||
qCWarning(gpulogging) << srcstr;
|
qCWarning(gpulogging) << srcstr;
|
||||||
|
qCWarning(gpulogging) << "GLShader::compileShader - errors:";
|
||||||
|
qCWarning(gpulogging) << temp;
|
||||||
delete[] temp;
|
delete[] temp;
|
||||||
|
|
||||||
glDeleteShader(glshader);
|
glDeleteShader(glshader);
|
||||||
|
|
|
@ -177,7 +177,7 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
|
||||||
auto glossMap = model::TextureMapPointer(new model::TextureMap());
|
auto glossMap = model::TextureMapPointer(new model::TextureMap());
|
||||||
glossMap->setTextureSource(material->specularTexture->_textureSource);
|
glossMap->setTextureSource(material->specularTexture->_textureSource);
|
||||||
|
|
||||||
networkMaterial->setTextureMap(model::MaterialKey::GLOSS_MAP, glossMap);
|
networkMaterial->setTextureMap(model::MaterialKey::ROUGHNESS_MAP, glossMap);
|
||||||
} else if (material->emissiveTextureName == name) {
|
} else if (material->emissiveTextureName == name) {
|
||||||
material->emissiveTexture = textureCache->getTexture(url);
|
material->emissiveTexture = textureCache->getTexture(url);
|
||||||
|
|
||||||
|
@ -350,6 +350,15 @@ static NetworkMaterial* buildNetworkMaterial(const FBXMaterial& material, const
|
||||||
|
|
||||||
material._material->setTextureMap(model::MaterialKey::METALLIC_MAP, specularMap);
|
material._material->setTextureMap(model::MaterialKey::METALLIC_MAP, specularMap);
|
||||||
}
|
}
|
||||||
|
if (!material.metallicTexture.filename.isEmpty()) {
|
||||||
|
networkMaterial->specularTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.metallicTexture.filename)), SPECULAR_TEXTURE, material.metallicTexture.content);
|
||||||
|
networkMaterial->specularTextureName = material.metallicTexture.name;
|
||||||
|
|
||||||
|
auto metallicMap = model::TextureMapPointer(new model::TextureMap());
|
||||||
|
metallicMap->setTextureSource(networkMaterial->specularTexture->_textureSource);
|
||||||
|
|
||||||
|
material._material->setTextureMap(model::MaterialKey::METALLIC_MAP, metallicMap);
|
||||||
|
}
|
||||||
if (!material.roughnessTexture.filename.isEmpty()) {
|
if (!material.roughnessTexture.filename.isEmpty()) {
|
||||||
networkMaterial->roughnessTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.roughnessTexture.filename)), ROUGHNESS_TEXTURE, material.roughnessTexture.content);
|
networkMaterial->roughnessTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.roughnessTexture.filename)), ROUGHNESS_TEXTURE, material.roughnessTexture.content);
|
||||||
networkMaterial->roughnessTextureName = material.roughnessTexture.name;
|
networkMaterial->roughnessTextureName = material.roughnessTexture.name;
|
||||||
|
@ -357,7 +366,7 @@ static NetworkMaterial* buildNetworkMaterial(const FBXMaterial& material, const
|
||||||
auto roughnessMap = model::TextureMapPointer(new model::TextureMap());
|
auto roughnessMap = model::TextureMapPointer(new model::TextureMap());
|
||||||
roughnessMap->setTextureSource(networkMaterial->roughnessTexture->_textureSource);
|
roughnessMap->setTextureSource(networkMaterial->roughnessTexture->_textureSource);
|
||||||
|
|
||||||
material._material->setTextureMap(model::MaterialKey::GLOSS_MAP, roughnessMap);
|
material._material->setTextureMap(model::MaterialKey::ROUGHNESS_MAP, roughnessMap);
|
||||||
}
|
}
|
||||||
if (!material.emissiveTexture.filename.isEmpty()) {
|
if (!material.emissiveTexture.filename.isEmpty()) {
|
||||||
networkMaterial->emissiveTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.emissiveTexture.filename)), EMISSIVE_TEXTURE, material.emissiveTexture.content);
|
networkMaterial->emissiveTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.emissiveTexture.filename)), EMISSIVE_TEXTURE, material.emissiveTexture.content);
|
||||||
|
|
|
@ -61,7 +61,7 @@ void Material::setAlbedo(const Color& albedo, bool isSRGB) {
|
||||||
|
|
||||||
void Material::setRoughness(float roughness) {
|
void Material::setRoughness(float roughness) {
|
||||||
roughness = std::min(1.0f, std::max(roughness, 0.0f));
|
roughness = std::min(1.0f, std::max(roughness, 0.0f));
|
||||||
_key.setGloss((roughness < 1.0f));
|
_key.setGlossy((roughness < 1.0f));
|
||||||
_schemaBuffer.edit<Schema>()._roughness = roughness;
|
_schemaBuffer.edit<Schema>()._roughness = roughness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,13 @@ public:
|
||||||
EMISSIVE_VAL_BIT = 0,
|
EMISSIVE_VAL_BIT = 0,
|
||||||
ALBEDO_VAL_BIT,
|
ALBEDO_VAL_BIT,
|
||||||
METALLIC_VAL_BIT,
|
METALLIC_VAL_BIT,
|
||||||
GLOSS_VAL_BIT,
|
GLOSSY_VAL_BIT,
|
||||||
TRANSPARENT_VAL_BIT,
|
TRANSPARENT_VAL_BIT,
|
||||||
|
|
||||||
EMISSIVE_MAP_BIT,
|
EMISSIVE_MAP_BIT,
|
||||||
ALBEDO_MAP_BIT,
|
ALBEDO_MAP_BIT,
|
||||||
METALLIC_MAP_BIT,
|
METALLIC_MAP_BIT,
|
||||||
GLOSS_MAP_BIT,
|
ROUGHNESS_MAP_BIT,
|
||||||
TRANSPARENT_MAP_BIT,
|
TRANSPARENT_MAP_BIT,
|
||||||
NORMAL_MAP_BIT,
|
NORMAL_MAP_BIT,
|
||||||
LIGHTMAP_MAP_BIT,
|
LIGHTMAP_MAP_BIT,
|
||||||
|
@ -49,7 +49,7 @@ public:
|
||||||
EMISSIVE_MAP = 0,
|
EMISSIVE_MAP = 0,
|
||||||
ALBEDO_MAP,
|
ALBEDO_MAP,
|
||||||
METALLIC_MAP,
|
METALLIC_MAP,
|
||||||
GLOSS_MAP,
|
ROUGHNESS_MAP,
|
||||||
TRANSPARENT_MAP,
|
TRANSPARENT_MAP,
|
||||||
NORMAL_MAP,
|
NORMAL_MAP,
|
||||||
LIGHTMAP_MAP,
|
LIGHTMAP_MAP,
|
||||||
|
@ -73,13 +73,13 @@ public:
|
||||||
Builder& withEmissive() { _flags.set(EMISSIVE_VAL_BIT); return (*this); }
|
Builder& withEmissive() { _flags.set(EMISSIVE_VAL_BIT); return (*this); }
|
||||||
Builder& withAlbedo() { _flags.set(ALBEDO_VAL_BIT); return (*this); }
|
Builder& withAlbedo() { _flags.set(ALBEDO_VAL_BIT); return (*this); }
|
||||||
Builder& withMetallic() { _flags.set(METALLIC_VAL_BIT); return (*this); }
|
Builder& withMetallic() { _flags.set(METALLIC_VAL_BIT); return (*this); }
|
||||||
Builder& withGloss() { _flags.set(GLOSS_VAL_BIT); return (*this); }
|
Builder& withGlossy() { _flags.set(GLOSSY_VAL_BIT); return (*this); }
|
||||||
Builder& withTransparent() { _flags.set(TRANSPARENT_VAL_BIT); return (*this); }
|
Builder& withTransparent() { _flags.set(TRANSPARENT_VAL_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withEmissiveMap() { _flags.set(EMISSIVE_MAP_BIT); return (*this); }
|
Builder& withEmissiveMap() { _flags.set(EMISSIVE_MAP_BIT); return (*this); }
|
||||||
Builder& withAlbedoMap() { _flags.set(ALBEDO_MAP_BIT); return (*this); }
|
Builder& withAlbedoMap() { _flags.set(ALBEDO_MAP_BIT); return (*this); }
|
||||||
Builder& withMetallicMap() { _flags.set(METALLIC_MAP_BIT); return (*this); }
|
Builder& withMetallicMap() { _flags.set(METALLIC_MAP_BIT); return (*this); }
|
||||||
Builder& withGlossMap() { _flags.set(GLOSS_MAP_BIT); return (*this); }
|
Builder& withRoughnessMap() { _flags.set(ROUGHNESS_MAP_BIT); return (*this); }
|
||||||
Builder& withTransparentMap() { _flags.set(TRANSPARENT_MAP_BIT); return (*this); }
|
Builder& withTransparentMap() { _flags.set(TRANSPARENT_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withNormalMap() { _flags.set(NORMAL_MAP_BIT); return (*this); }
|
Builder& withNormalMap() { _flags.set(NORMAL_MAP_BIT); return (*this); }
|
||||||
|
@ -107,11 +107,12 @@ public:
|
||||||
void setMetallicMap(bool value) { _flags.set(METALLIC_MAP_BIT, value); }
|
void setMetallicMap(bool value) { _flags.set(METALLIC_MAP_BIT, value); }
|
||||||
bool isMetallicMap() const { return _flags[METALLIC_MAP_BIT]; }
|
bool isMetallicMap() const { return _flags[METALLIC_MAP_BIT]; }
|
||||||
|
|
||||||
void setGloss(bool value) { _flags.set(GLOSS_VAL_BIT, value); }
|
void setGlossy(bool value) { _flags.set(GLOSSY_VAL_BIT, value); }
|
||||||
bool isGloss() const { return _flags[GLOSS_VAL_BIT]; }
|
bool isGlossy() const { return _flags[GLOSSY_VAL_BIT]; }
|
||||||
|
bool isRough() const { return !_flags[GLOSSY_VAL_BIT]; }
|
||||||
|
|
||||||
void setGlossMap(bool value) { _flags.set(GLOSS_MAP_BIT, value); }
|
void setRoughnessMap(bool value) { _flags.set(ROUGHNESS_MAP_BIT, value); }
|
||||||
bool isGlossMap() const { return _flags[GLOSS_MAP_BIT]; }
|
bool isRoughnessMap() const { return _flags[ROUGHNESS_MAP_BIT]; }
|
||||||
|
|
||||||
void setTransparent(bool value) { _flags.set(TRANSPARENT_VAL_BIT, value); }
|
void setTransparent(bool value) { _flags.set(TRANSPARENT_VAL_BIT, value); }
|
||||||
bool isTransparent() const { return _flags[TRANSPARENT_VAL_BIT]; }
|
bool isTransparent() const { return _flags[TRANSPARENT_VAL_BIT]; }
|
||||||
|
@ -166,11 +167,11 @@ public:
|
||||||
Builder& withoutMetallicMap() { _value.reset(MaterialKey::METALLIC_MAP_BIT); _mask.set(MaterialKey::METALLIC_MAP_BIT); return (*this); }
|
Builder& withoutMetallicMap() { _value.reset(MaterialKey::METALLIC_MAP_BIT); _mask.set(MaterialKey::METALLIC_MAP_BIT); return (*this); }
|
||||||
Builder& withMetallicMap() { _value.set(MaterialKey::METALLIC_MAP_BIT); _mask.set(MaterialKey::METALLIC_MAP_BIT); return (*this); }
|
Builder& withMetallicMap() { _value.set(MaterialKey::METALLIC_MAP_BIT); _mask.set(MaterialKey::METALLIC_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withoutGloss() { _value.reset(MaterialKey::GLOSS_VAL_BIT); _mask.set(MaterialKey::GLOSS_VAL_BIT); return (*this); }
|
Builder& withoutGlossy() { _value.reset(MaterialKey::GLOSSY_VAL_BIT); _mask.set(MaterialKey::GLOSSY_VAL_BIT); return (*this); }
|
||||||
Builder& withGloss() { _value.set(MaterialKey::GLOSS_VAL_BIT); _mask.set(MaterialKey::GLOSS_VAL_BIT); return (*this); }
|
Builder& withGlossy() { _value.set(MaterialKey::GLOSSY_VAL_BIT); _mask.set(MaterialKey::GLOSSY_VAL_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withoutGlossMap() { _value.reset(MaterialKey::GLOSS_MAP_BIT); _mask.set(MaterialKey::GLOSS_MAP_BIT); return (*this); }
|
Builder& withoutRoughnessMap() { _value.reset(MaterialKey::ROUGHNESS_MAP_BIT); _mask.set(MaterialKey::ROUGHNESS_MAP_BIT); return (*this); }
|
||||||
Builder& withGlossMap() { _value.set(MaterialKey::GLOSS_MAP_BIT); _mask.set(MaterialKey::GLOSS_MAP_BIT); return (*this); }
|
Builder& withRoughnessMap() { _value.set(MaterialKey::ROUGHNESS_MAP_BIT); _mask.set(MaterialKey::ROUGHNESS_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withoutTransparent() { _value.reset(MaterialKey::TRANSPARENT_VAL_BIT); _mask.set(MaterialKey::TRANSPARENT_VAL_BIT); return (*this); }
|
Builder& withoutTransparent() { _value.reset(MaterialKey::TRANSPARENT_VAL_BIT); _mask.set(MaterialKey::TRANSPARENT_VAL_BIT); return (*this); }
|
||||||
Builder& withTransparent() { _value.set(MaterialKey::TRANSPARENT_VAL_BIT); _mask.set(MaterialKey::TRANSPARENT_VAL_BIT); return (*this); }
|
Builder& withTransparent() { _value.set(MaterialKey::TRANSPARENT_VAL_BIT); _mask.set(MaterialKey::TRANSPARENT_VAL_BIT); return (*this); }
|
||||||
|
@ -241,14 +242,14 @@ public:
|
||||||
// Schema to access the attribute values of the material
|
// Schema to access the attribute values of the material
|
||||||
class Schema {
|
class Schema {
|
||||||
public:
|
public:
|
||||||
glm::vec3 _emissive{ 0.0f };
|
glm::vec3 _emissive{ 0.0f }; // No Emissive
|
||||||
float _opacity{ 1.f };
|
float _opacity{ 1.f }; // Opacity = 1 => Not Transparent
|
||||||
|
|
||||||
glm::vec3 _albedo{ 0.5f };
|
glm::vec3 _albedo{ 0.5f }; // Grey albedo => isAlbedo
|
||||||
float _roughness{ 0.9f };
|
float _roughness{ 1.0f }; // Roughness = 1 => Not Glossy
|
||||||
|
|
||||||
glm::vec3 _fresnel{ 0.03f };
|
glm::vec3 _fresnel{ 0.03f }; // Fresnel value for a default non metallic
|
||||||
float _metallic{ 0.0f };
|
float _metallic{ 0.0f }; // Not Metallic
|
||||||
|
|
||||||
|
|
||||||
glm::vec4 _spare0{ 0.0f };
|
glm::vec4 _spare0{ 0.0f };
|
||||||
|
|
|
@ -54,25 +54,51 @@ enum Slot {
|
||||||
|
|
||||||
static const std::string DEFAULT_ALBEDO_SHADER {
|
static const std::string DEFAULT_ALBEDO_SHADER {
|
||||||
"vec4 getFragmentColor() {"
|
"vec4 getFragmentColor() {"
|
||||||
" return vec4(pow(texture(albedoMap, uv).xyz, vec3(1.0 / 2.2)), 1.0);"
|
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||||
|
" return vec4(pow(frag.diffuse, vec3(1.0 / 2.2)), 1.0);"
|
||||||
" }"
|
" }"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::string DEFAULT_SPECULAR_SHADER {
|
static const std::string DEFAULT_FRESNEL_SHADER{
|
||||||
"vec4 getFragmentColor() {"
|
"vec4 getFragmentColor() {"
|
||||||
" return vec4(texture(specularMap, uv).xyz, 1.0);"
|
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||||
|
" return vec4(pow(frag.specular, vec3(1.0 / 2.2)), 1.0);"
|
||||||
|
" }"
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::string DEFAULT_METALLIC_SHADER {
|
||||||
|
"vec4 getFragmentColor() {"
|
||||||
|
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||||
|
" return vec4(vec3(frag.metallic), 1.0);"
|
||||||
" }"
|
" }"
|
||||||
};
|
};
|
||||||
static const std::string DEFAULT_ROUGHNESS_SHADER {
|
static const std::string DEFAULT_ROUGHNESS_SHADER {
|
||||||
"vec4 getFragmentColor() {"
|
"vec4 getFragmentColor() {"
|
||||||
" return vec4(vec3(texture(specularMap, uv).a), 1.0);"
|
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||||
|
" return vec4(vec3(frag.roughness), 1.0);"
|
||||||
" }"
|
" }"
|
||||||
};
|
};
|
||||||
static const std::string DEFAULT_NORMAL_SHADER {
|
static const std::string DEFAULT_NORMAL_SHADER {
|
||||||
"vec4 getFragmentColor() {"
|
"vec4 getFragmentColor() {"
|
||||||
" return vec4(normalize(texture(normalMap, uv).xyz * 2.0 - vec3(1.0)), 1.0);"
|
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||||
|
" return vec4(normalize(frag.normal), 1.0);"
|
||||||
" }"
|
" }"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const std::string DEFAULT_EMISSIVE_SHADER{
|
||||||
|
"vec4 getFragmentColor() {"
|
||||||
|
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||||
|
" return (frag.mode != LIGHT_MAPPED ? vec4(pow(frag.emissive, vec3(1.0 / 2.2)), 1.0) : vec4(vec3(0.0), 1.0));"
|
||||||
|
" }"
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::string DEFAULT_LIGHTMAP_SHADER{
|
||||||
|
"vec4 getFragmentColor() {"
|
||||||
|
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||||
|
" return (frag.mode == LIGHT_MAPPED ? vec4(frag.emissive, 1.0) : vec4(vec3(0.0), 1.0));"
|
||||||
|
" }"
|
||||||
|
};
|
||||||
|
|
||||||
static const std::string DEFAULT_DEPTH_SHADER {
|
static const std::string DEFAULT_DEPTH_SHADER {
|
||||||
"vec4 getFragmentColor() {"
|
"vec4 getFragmentColor() {"
|
||||||
" return vec4(vec3(texture(depthMap, uv).x), 1.0);"
|
" return vec4(vec3(texture(depthMap, uv).x), 1.0);"
|
||||||
|
@ -146,14 +172,20 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string cust
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case AlbedoMode:
|
case AlbedoMode:
|
||||||
return DEFAULT_ALBEDO_SHADER;
|
return DEFAULT_ALBEDO_SHADER;
|
||||||
case SpecularMode:
|
case FresnelMode:
|
||||||
return DEFAULT_SPECULAR_SHADER;
|
return DEFAULT_FRESNEL_SHADER;
|
||||||
|
case MetallicMode:
|
||||||
|
return DEFAULT_METALLIC_SHADER;
|
||||||
case RoughnessMode:
|
case RoughnessMode:
|
||||||
return DEFAULT_ROUGHNESS_SHADER;
|
return DEFAULT_ROUGHNESS_SHADER;
|
||||||
case NormalMode:
|
case NormalMode:
|
||||||
return DEFAULT_NORMAL_SHADER;
|
return DEFAULT_NORMAL_SHADER;
|
||||||
case DepthMode:
|
case DepthMode:
|
||||||
return DEFAULT_DEPTH_SHADER;
|
return DEFAULT_DEPTH_SHADER;
|
||||||
|
case EmissiveMode:
|
||||||
|
return DEFAULT_EMISSIVE_SHADER;
|
||||||
|
case LightmapMode:
|
||||||
|
return DEFAULT_LIGHTMAP_SHADER;
|
||||||
case LightingMode:
|
case LightingMode:
|
||||||
return DEFAULT_LIGHTING_SHADER;
|
return DEFAULT_LIGHTING_SHADER;
|
||||||
case ShadowMode:
|
case ShadowMode:
|
||||||
|
|
|
@ -47,11 +47,14 @@ protected:
|
||||||
|
|
||||||
enum Mode : uint8_t {
|
enum Mode : uint8_t {
|
||||||
// Use Mode suffix to avoid collisions
|
// Use Mode suffix to avoid collisions
|
||||||
AlbedoMode = 0,
|
DepthMode = 0,
|
||||||
SpecularMode,
|
AlbedoMode,
|
||||||
RoughnessMode,
|
|
||||||
NormalMode,
|
NormalMode,
|
||||||
DepthMode,
|
RoughnessMode,
|
||||||
|
MetallicMode,
|
||||||
|
FresnelMode,
|
||||||
|
EmissiveMode,
|
||||||
|
LightmapMode,
|
||||||
LightingMode,
|
LightingMode,
|
||||||
ShadowMode,
|
ShadowMode,
|
||||||
PyramidDepthMode,
|
PyramidDepthMode,
|
||||||
|
|
|
@ -64,52 +64,73 @@ vec4 evalEyePositionFromZ(DeferredTransform deferredTransform, float depthVal, v
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DeferredFragment {
|
struct DeferredFragment {
|
||||||
float depthVal;
|
|
||||||
vec4 normalVal;
|
vec4 normalVal;
|
||||||
vec4 diffuseVal;
|
vec4 diffuseVal;
|
||||||
vec4 specularVal;
|
vec4 specularVal;
|
||||||
vec4 position;
|
vec4 position;
|
||||||
vec3 normal;
|
vec3 normal;
|
||||||
|
float metallic;
|
||||||
vec3 diffuse;
|
vec3 diffuse;
|
||||||
float obscurance;
|
float obscurance;
|
||||||
vec3 specular;
|
vec3 specular;
|
||||||
float gloss;
|
float roughness;
|
||||||
|
vec3 emissive;
|
||||||
int mode;
|
int mode;
|
||||||
|
float depthVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
const int LIGHT_MAPPED = 1;
|
const int LIGHT_MAPPED = 1;
|
||||||
|
|
||||||
DeferredFragment unpackDeferredFragment(DeferredTransform deferredTransform, vec2 texcoord) {
|
vec4 unpackDeferredPosition(DeferredTransform deferredTransform, float depthValue, vec2 texcoord) {
|
||||||
DeferredFragment frag;
|
|
||||||
frag.depthVal = texture(depthMap, texcoord).r;
|
|
||||||
frag.normalVal = texture(normalMap, texcoord);
|
|
||||||
frag.diffuseVal = texture(albedoMap, texcoord);
|
|
||||||
frag.specularVal = texture(specularMap, texcoord);
|
|
||||||
frag.obscurance = texture(obscuranceMap, texcoord).x;
|
|
||||||
|
|
||||||
if (getStereoMode(deferredTransform)) {
|
if (getStereoMode(deferredTransform)) {
|
||||||
if (texcoord.x > 0.5) {
|
if (texcoord.x > 0.5) {
|
||||||
texcoord.x -= 0.5;
|
texcoord.x -= 0.5;
|
||||||
}
|
}
|
||||||
texcoord.x *= 2.0;
|
texcoord.x *= 2.0;
|
||||||
}
|
}
|
||||||
frag.position = evalEyePositionFromZ(deferredTransform, frag.depthVal, texcoord);
|
return evalEyePositionFromZ(deferredTransform, depthValue, texcoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
|
||||||
|
|
||||||
|
DeferredFragment frag;
|
||||||
|
frag.depthVal = -1;
|
||||||
|
frag.normalVal = texture(normalMap, texcoord);
|
||||||
|
frag.diffuseVal = texture(albedoMap, texcoord);
|
||||||
|
frag.specularVal = texture(specularMap, texcoord);
|
||||||
|
frag.obscurance = texture(obscuranceMap, texcoord).x;
|
||||||
|
|
||||||
// Unpack the normal from the map
|
// Unpack the normal from the map
|
||||||
frag.normal = normalize(frag.normalVal.xyz * 2.0 - vec3(1.0));
|
frag.normal = normalize(frag.normalVal.xyz * 2.0 - vec3(1.0));
|
||||||
|
|
||||||
frag.mode = 0;
|
frag.mode = 0;
|
||||||
|
frag.emissive = vec3(0.0);
|
||||||
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
||||||
frag.mode = LIGHT_MAPPED;
|
frag.mode = LIGHT_MAPPED;
|
||||||
|
frag.emissive = frag.specularVal.xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
frag.diffuse = frag.diffuseVal.xyz;
|
frag.diffuse = frag.diffuseVal.xyz;
|
||||||
frag.specular = frag.specularVal.xyz;
|
frag.specular = frag.specularVal.xyz;
|
||||||
frag.gloss = (frag.specularVal.w * 125)*(frag.specularVal.w * 125);
|
frag.metallic = length(frag.specularVal);
|
||||||
|
frag.roughness = frag.specularVal.w;
|
||||||
|
|
||||||
|
return frag;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeferredFragment unpackDeferredFragment(DeferredTransform deferredTransform, vec2 texcoord) {
|
||||||
|
|
||||||
|
float depthValue = texture(depthMap, texcoord).r;
|
||||||
|
|
||||||
|
DeferredFragment frag = unpackDeferredFragmentNoPosition(texcoord);
|
||||||
|
|
||||||
|
frag.depthVal = depthValue;
|
||||||
|
frag.position = unpackDeferredPosition(deferredTransform, frag.depthVal, texcoord);
|
||||||
|
|
||||||
return frag;
|
return frag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -40,37 +40,40 @@ float evalOpaqueFinalAlpha(float alpha, float mapAlpha) {
|
||||||
return mix(alpha, 1.0 - alpha, step(mapAlpha, alphaThreshold));
|
return mix(alpha, 1.0 - alpha, step(mapAlpha, alphaThreshold));
|
||||||
}
|
}
|
||||||
|
|
||||||
const vec3 DEFAULT_SPECULAR = vec3(0.1);
|
const float DEFAULT_ROUGHNESS = 0.9;
|
||||||
const float DEFAULT_SHININESS = 10;
|
const float DEFAULT_SHININESS = 10;
|
||||||
|
const float DEFAULT_METALLIC = 0;
|
||||||
|
const vec3 DEFAULT_SPECULAR = vec3(0.1);
|
||||||
|
|
||||||
void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float shininess) {
|
|
||||||
|
void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 fresnel) {
|
||||||
if (alpha != 1.0) {
|
if (alpha != 1.0) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
_fragColor0 = vec4(albedo.rgb, 1.0); // Opaque
|
_fragColor0 = vec4(albedo.rgb, 1.0); // Opaque
|
||||||
_fragColor1 = vec4(bestFitNormal(normal), 1.0);
|
_fragColor1 = vec4(bestFitNormal(normal), 1.0);
|
||||||
_fragColor2 = vec4(fresnel, shininess);
|
_fragColor2 = vec4(fresnel, roughness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float shininess, vec3 emissive) {
|
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 fresnel, vec3 emissive) {
|
||||||
if (alpha != 1.0) {
|
if (alpha != 1.0) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
_fragColor0 = vec4(albedo.rgb, 0.5);
|
_fragColor0 = vec4(albedo.rgb, 0.5);
|
||||||
_fragColor1 = vec4(bestFitNormal(normal), 0.5);
|
_fragColor1 = vec4(bestFitNormal(normal), 0.5);
|
||||||
_fragColor2 = vec4(emissive, shininess);
|
_fragColor2 = vec4(emissive, roughness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float shininess) {
|
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness) {
|
||||||
if (alpha <= 0.0) {
|
if (alpha <= 0.0) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
_fragColor0 = vec4(albedo.rgb, alpha);
|
_fragColor0 = vec4(albedo.rgb, alpha);
|
||||||
// _fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
// _fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
// _fragColor2 = vec4(fresnel, shininess);
|
// _fragColor2 = vec4(fresnel, roughness);
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -30,7 +30,7 @@ vec4 evalSkyboxLight(vec3 direction, float lod) {
|
||||||
<@include model/Light.slh@>
|
<@include model/Light.slh@>
|
||||||
|
|
||||||
<@func declareEvalAmbientGlobalColor()@>
|
<@func declareEvalAmbientGlobalColor()@>
|
||||||
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float gloss) {
|
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 fresnel, float roughness) {
|
||||||
|
|
||||||
// Need the light now
|
// Need the light now
|
||||||
Light light = getLight();
|
Light light = getLight();
|
||||||
|
@ -41,7 +41,7 @@ vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obsc
|
||||||
|
|
||||||
vec3 color = albedo * getLightColor(light) * obscurance * getLightAmbientIntensity(light);
|
vec3 color = albedo * getLightColor(light) * obscurance * getLightAmbientIntensity(light);
|
||||||
|
|
||||||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, fresnel, gloss);
|
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, fresnel, roughness);
|
||||||
|
|
||||||
color += vec3(albedo * shading.w + shading.rgb) * min(shadowAttenuation, obscurance) * getLightColor(light) * getLightIntensity(light);
|
color += vec3(albedo * shading.w + shading.rgb) * min(shadowAttenuation, obscurance) * getLightColor(light) * getLightIntensity(light);
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obsc
|
||||||
<@func declareEvalAmbientSphereGlobalColor()@>
|
<@func declareEvalAmbientSphereGlobalColor()@>
|
||||||
|
|
||||||
|
|
||||||
vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float gloss) {
|
vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 fresnel, float roughness) {
|
||||||
// Need the light now
|
// Need the light now
|
||||||
Light light = getLight();
|
Light light = getLight();
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa
|
||||||
|
|
||||||
vec3 color = albedo * evalSphericalLight(getLightAmbientSphere(light), ambientNormal).xyz * obscurance * getLightAmbientIntensity(light);
|
vec3 color = albedo * evalSphericalLight(getLightAmbientSphere(light), ambientNormal).xyz * obscurance * getLightAmbientIntensity(light);
|
||||||
|
|
||||||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, fresnel, gloss);
|
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, fresnel, roughness);
|
||||||
|
|
||||||
color += vec3(albedo * shading.w + shading.rgb) * min(shadowAttenuation, obscurance) * getLightColor(light) * getLightIntensity(light);
|
color += vec3(albedo * shading.w + shading.rgb) * min(shadowAttenuation, obscurance) * getLightColor(light) * getLightIntensity(light);
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa
|
||||||
|
|
||||||
<$declareSkyboxMap()$>
|
<$declareSkyboxMap()$>
|
||||||
|
|
||||||
vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float gloss) {
|
vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 fresnel, float roughness) {
|
||||||
// Need the light now
|
// Need the light now
|
||||||
Light light = getLight();
|
Light light = getLight();
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
|
|
||||||
vec3 color = albedo * evalSphericalLight(getLightAmbientSphere(light), fragNormal).xyz * obscurance * getLightAmbientIntensity(light);
|
vec3 color = albedo * evalSphericalLight(getLightAmbientSphere(light), fragNormal).xyz * obscurance * getLightAmbientIntensity(light);
|
||||||
|
|
||||||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, fresnel, gloss);
|
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, fresnel, roughness);
|
||||||
|
|
||||||
color += vec3(albedo * shading.w + shading.rgb) * min(shadowAttenuation, obscurance) * getLightColor(light) * getLightIntensity(light);
|
color += vec3(albedo * shading.w + shading.rgb) * min(shadowAttenuation, obscurance) * getLightColor(light) * getLightIntensity(light);
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,17 @@
|
||||||
|
|
||||||
<@func declareEvalPBRShading()@>
|
<@func declareEvalPBRShading()@>
|
||||||
// Frag Shading returns the diffuse amount as W and the specular rgb as xyz
|
// Frag Shading returns the diffuse amount as W and the specular rgb as xyz
|
||||||
vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 specular, float gloss) {
|
vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float metallic, vec3 specular, float roughness) {
|
||||||
// Diffuse Lighting
|
// Diffuse Lighting
|
||||||
float diffuseDot = dot(fragNormal, fragLightDir);
|
float diffuseDot = dot(fragNormal, fragLightDir);
|
||||||
float facingLight = step(0.0, diffuseDot);
|
float facingLight = step(0.0, diffuseDot);
|
||||||
float diffuse = diffuseDot * facingLight;
|
float diffuse = diffuseDot * facingLight;
|
||||||
|
|
||||||
// Specular Lighting depends on the half vector and the gloss
|
// Specular Lighting depends on the half vector and the roughness
|
||||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
||||||
|
|
||||||
|
float gloss = (1.0 - roughness) * 128.0;
|
||||||
|
gloss *= gloss;
|
||||||
float specularPower = pow(max(0.0, dot(halfDir, fragNormal)), gloss);
|
float specularPower = pow(max(0.0, dot(halfDir, fragNormal)), gloss);
|
||||||
specularPower *= (gloss * 0.125 + 0.25);
|
specularPower *= (gloss * 0.125 + 0.25);
|
||||||
|
|
||||||
|
@ -38,15 +40,17 @@ vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 sp
|
||||||
|
|
||||||
<@func declareEvalBlinnRShading()@>
|
<@func declareEvalBlinnRShading()@>
|
||||||
|
|
||||||
vec4 evalBlinnShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 specular, float gloss) {
|
vec4 evalBlinnShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 specular, float roughness) {
|
||||||
// Diffuse Lighting
|
// Diffuse Lighting
|
||||||
float diffuseDot = dot(fragNormal, fragLightDir);
|
float diffuseDot = dot(fragNormal, fragLightDir);
|
||||||
float facingLight = step(0.0, diffuseDot);
|
float facingLight = step(0.0, diffuseDot);
|
||||||
float diffuse = diffuseDot * facingLight;
|
float diffuse = diffuseDot * facingLight;
|
||||||
|
|
||||||
// Specular Lighting depends on the half vector and the gloss
|
// Specular Lighting depends on the half vector and the roughness
|
||||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
||||||
|
|
||||||
|
float gloss = (1.0 - roughness) * 128.0;
|
||||||
|
glos *= gloss;
|
||||||
float specularPower = pow(facingLight * max(0.0, dot(halfDir, fragNormal)), gloss);
|
float specularPower = pow(facingLight * max(0.0, dot(halfDir, fragNormal)), gloss);
|
||||||
vec3 reflect = specularPower * specular * diffuse;
|
vec3 reflect = specularPower * specular * diffuse;
|
||||||
|
|
||||||
|
@ -59,8 +63,8 @@ vec4 evalBlinnShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3
|
||||||
<$declareEvalPBRShading()$>
|
<$declareEvalPBRShading()$>
|
||||||
|
|
||||||
// Return xyz the specular/reflection component and w the diffuse component
|
// Return xyz the specular/reflection component and w the diffuse component
|
||||||
vec4 evalFragShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 specular, float gloss) {
|
vec4 evalFragShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float metallic, vec3 specular, float roughness) {
|
||||||
return evalPBRShading(fragNormal, fragLightDir, fragEyeDir, specular, gloss);
|
return evalPBRShading(fragNormal, fragLightDir, fragEyeDir, metallic, specular, roughness);
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -106,7 +106,7 @@ ShapeKey MeshPartPayload::getShapeKey() const {
|
||||||
if (drawMaterialKey.isNormalMap()) {
|
if (drawMaterialKey.isNormalMap()) {
|
||||||
builder.withTangents();
|
builder.withTangents();
|
||||||
}
|
}
|
||||||
if (drawMaterialKey.isGlossMap()) {
|
if (drawMaterialKey.isMetallicMap()) {
|
||||||
builder.withSpecular();
|
builder.withSpecular();
|
||||||
}
|
}
|
||||||
if (drawMaterialKey.isLightmapMap()) {
|
if (drawMaterialKey.isLightmapMap()) {
|
||||||
|
@ -175,6 +175,20 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
|
||||||
batch.setResourceTexture(ShapePipeline::Slot::NORMAL_MAP, nullptr);
|
batch.setResourceTexture(ShapePipeline::Slot::NORMAL_MAP, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Roughness map
|
||||||
|
/* if (materialKey.isRoughnessMap()) {
|
||||||
|
auto roughnessMap = textureMaps[model::MaterialKey::ROUGHNESS_MAP];
|
||||||
|
if (roughnessMap && roughnessMap->isDefined()) {
|
||||||
|
batch.setResourceTexture(ShapePipeline::Slot::ROUGHNESS_MAP, roughnessMap->getTextureView());
|
||||||
|
|
||||||
|
// texcoord are assumed to be the same has albedo
|
||||||
|
} else {
|
||||||
|
batch.setResourceTexture(ShapePipeline::Slot::ROUGHNESS_MAP, textureCache->getBlackTexture());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
batch.setResourceTexture(ShapePipeline::Slot::ROUGHNESS_MAP, nullptr);
|
||||||
|
}*/
|
||||||
|
|
||||||
// Metallic map
|
// Metallic map
|
||||||
if (materialKey.isMetallicMap()) {
|
if (materialKey.isMetallicMap()) {
|
||||||
auto specularMap = textureMaps[model::MaterialKey::METALLIC_MAP];
|
auto specularMap = textureMaps[model::MaterialKey::METALLIC_MAP];
|
||||||
|
|
|
@ -44,8 +44,9 @@ void main(void) {
|
||||||
frag.position.xyz,
|
frag.position.xyz,
|
||||||
frag.normal,
|
frag.normal,
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
|
frag.metallic,
|
||||||
frag.specular,
|
frag.specular,
|
||||||
frag.gloss);
|
frag.roughness);
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,9 @@ void main(void) {
|
||||||
frag.position.xyz,
|
frag.position.xyz,
|
||||||
frag.normal,
|
frag.normal,
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
|
frag.metallic,
|
||||||
frag.specular,
|
frag.specular,
|
||||||
frag.gloss);
|
frag.roughness);
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,9 @@ void main(void) {
|
||||||
frag.position.xyz,
|
frag.position.xyz,
|
||||||
frag.normal,
|
frag.normal,
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
|
frag.metallic,
|
||||||
frag.specular,
|
frag.specular,
|
||||||
frag.gloss);
|
frag.roughness);
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,9 @@ void main(void) {
|
||||||
frag.position.xyz,
|
frag.position.xyz,
|
||||||
frag.normal,
|
frag.normal,
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
|
frag.metallic,
|
||||||
frag.specular,
|
frag.specular,
|
||||||
frag.gloss);
|
frag.roughness);
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,9 @@ void main(void) {
|
||||||
frag.position.xyz,
|
frag.position.xyz,
|
||||||
frag.normal,
|
frag.normal,
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
|
frag.metallic,
|
||||||
frag.specular,
|
frag.specular,
|
||||||
frag.gloss);
|
frag.roughness);
|
||||||
|
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,9 @@ void main(void) {
|
||||||
frag.position.xyz,
|
frag.position.xyz,
|
||||||
frag.normal,
|
frag.normal,
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
|
frag.metallic,
|
||||||
frag.specular,
|
frag.specular,
|
||||||
frag.gloss);
|
frag.roughness);
|
||||||
|
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ void main(void) {
|
||||||
normalize(_normal.xyz),
|
normalize(_normal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
getMaterialFresnel(mat),
|
getMaterialRoughness(mat),
|
||||||
getMaterialShininess(mat));
|
getMaterialMetallic(mat),
|
||||||
|
getMaterialFresnel(mat));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ void main(void) {
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
texel.a,
|
texel.a,
|
||||||
vec3(1.0),
|
vec3(1.0),
|
||||||
|
getMaterialRoughness(mat),
|
||||||
|
getMaterialMetallic(mat),
|
||||||
getMaterialFresnel(mat),
|
getMaterialFresnel(mat),
|
||||||
getMaterialShininess(mat),
|
|
||||||
fragColor);
|
fragColor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ void main(void) {
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
|
getMaterialRoughness(mat),
|
||||||
|
getMaterialMetallic(mat),
|
||||||
getMaterialFresnel(mat),
|
getMaterialFresnel(mat),
|
||||||
getMaterialShininess(mat),
|
|
||||||
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,8 @@ void main(void) {
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
|
getMaterialRoughness(mat),
|
||||||
|
getMaterialMetallic(mat),
|
||||||
getMaterialFresnel(mat),
|
getMaterialFresnel(mat),
|
||||||
getMaterialShininess(mat),
|
|
||||||
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,8 @@ void main(void) {
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
|
getMaterialRoughness(mat),
|
||||||
|
getMaterialMetallic(mat),
|
||||||
specular, // no use of getMaterialFresnel(mat)
|
specular, // no use of getMaterialFresnel(mat)
|
||||||
getMaterialShininess(mat),
|
|
||||||
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ void main(void) {
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
|
getMaterialRoughness(mat),
|
||||||
|
getMaterialMetallic(mat),
|
||||||
specular, // no use of getMaterialFresnel(mat)
|
specular, // no use of getMaterialFresnel(mat)
|
||||||
getMaterialShininess(mat),
|
|
||||||
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ void main(void) {
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
getMaterialFresnel(mat),
|
getMaterialRoughness(mat),
|
||||||
getMaterialShininess(mat));
|
getMaterialMetallic(mat),
|
||||||
|
getMaterialFresnel(mat));
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ void main(void) {
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
specular, //getMaterialFresnel(mat),
|
getMaterialRoughness(mat),
|
||||||
getMaterialShininess(mat));
|
getMaterialMetallic(mat),
|
||||||
|
specular //getMaterialFresnel(mat)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ void main(void) {
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
specular, //getMaterialFresnel(mat),
|
getMaterialRoughness(mat),
|
||||||
getMaterialShininess(mat));
|
getMaterialMetallic(mat),
|
||||||
|
specular //getMaterialFresnel(mat)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,9 @@ void main(void) {
|
||||||
vec3 fragPosition = _position.xyz;
|
vec3 fragPosition = _position.xyz;
|
||||||
vec3 fragNormal = normalize(_normal);
|
vec3 fragNormal = normalize(_normal);
|
||||||
vec3 fragAlbedo = getMaterialAlbedo(mat) * albedo.rgb * _color;
|
vec3 fragAlbedo = getMaterialAlbedo(mat) * albedo.rgb * _color;
|
||||||
|
float fragMetallic = getMaterialMetallic(mat);
|
||||||
vec3 fragFresnel = getMaterialFresnel(mat);
|
vec3 fragFresnel = getMaterialFresnel(mat);
|
||||||
float fragGloss = getMaterialShininess(mat) / 128;
|
float fragRoughness = getMaterialRoughness(mat);
|
||||||
float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha;
|
float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha;
|
||||||
|
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
@ -50,7 +51,8 @@ void main(void) {
|
||||||
fragPosition,
|
fragPosition,
|
||||||
fragNormal,
|
fragNormal,
|
||||||
fragAlbedo,
|
fragAlbedo,
|
||||||
|
fragMetallic,
|
||||||
fragFresnel,
|
fragFresnel,
|
||||||
fragGloss),
|
fragRoughness),
|
||||||
fragOpacity);
|
fragOpacity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
<$declareStandardCameraTransform()$>
|
<$declareStandardCameraTransform()$>
|
||||||
|
|
||||||
vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 albedo, vec3 specular, float gloss, float opacity) {
|
vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 specular, float roughness, float opacity) {
|
||||||
|
|
||||||
// Need the light now
|
// Need the light now
|
||||||
Light light = getLight();
|
Light light = getLight();
|
||||||
|
@ -30,7 +30,7 @@ vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 a
|
||||||
|
|
||||||
vec3 color = opacity * albedo * getLightColor(light) * getLightAmbientIntensity(light);
|
vec3 color = opacity * albedo * getLightColor(light) * getLightAmbientIntensity(light);
|
||||||
|
|
||||||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, specular, gloss);
|
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, specular, roughness);
|
||||||
|
|
||||||
color += vec3(albedo * shading.w * opacity + shading.rgb) * shadowAttenuation * getLightColor(light) * getLightIntensity(light);
|
color += vec3(albedo * shading.w * opacity + shading.rgb) * shadowAttenuation * getLightColor(light) * getLightIntensity(light);
|
||||||
|
|
||||||
|
@ -53,8 +53,9 @@ void main(void) {
|
||||||
vec3 fragPosition = _position.xyz;
|
vec3 fragPosition = _position.xyz;
|
||||||
vec3 fragNormal = normalize(_normal);
|
vec3 fragNormal = normalize(_normal);
|
||||||
vec3 fragAlbedo = albedo.rgb * _color;
|
vec3 fragAlbedo = albedo.rgb * _color;
|
||||||
|
float fragMetallic = 0.0;
|
||||||
vec3 fragSpecular = vec3(0.1);
|
vec3 fragSpecular = vec3(0.1);
|
||||||
float fragGloss = 10.0 / 128.0;
|
float fragRoughness = 0.9;
|
||||||
float fragOpacity = albedo.a;
|
float fragOpacity = albedo.a;
|
||||||
|
|
||||||
if (fragOpacity <= 0.1) {
|
if (fragOpacity <= 0.1) {
|
||||||
|
@ -65,8 +66,9 @@ void main(void) {
|
||||||
fragPosition,
|
fragPosition,
|
||||||
fragNormal,
|
fragNormal,
|
||||||
fragAlbedo,
|
fragAlbedo,
|
||||||
|
fragMetallic,
|
||||||
fragSpecular,
|
fragSpecular,
|
||||||
fragGloss,
|
fragRoughness,
|
||||||
fragOpacity);
|
fragOpacity);
|
||||||
|
|
||||||
// Apply standard tone mapping
|
// Apply standard tone mapping
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
<$declareStandardCameraTransform()$>
|
<$declareStandardCameraTransform()$>
|
||||||
|
|
||||||
vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 albedo, vec3 specular, float gloss, float opacity) {
|
vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 specular, float roughness, float opacity) {
|
||||||
|
|
||||||
// Need the light now
|
// Need the light now
|
||||||
Light light = getLight();
|
Light light = getLight();
|
||||||
|
@ -31,7 +31,7 @@ vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 a
|
||||||
|
|
||||||
vec3 color = opacity * albedo * getLightColor(light) * getLightAmbientIntensity(light);
|
vec3 color = opacity * albedo * getLightColor(light) * getLightAmbientIntensity(light);
|
||||||
|
|
||||||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, specular, gloss);
|
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, specular, roughness);
|
||||||
|
|
||||||
color += vec3(albedo * shading.w * opacity + shading.rgb) * shadowAttenuation * getLightColor(light) * getLightIntensity(light);
|
color += vec3(albedo * shading.w * opacity + shading.rgb) * shadowAttenuation * getLightColor(light) * getLightIntensity(light);
|
||||||
|
|
||||||
|
@ -54,16 +54,18 @@ void main(void) {
|
||||||
vec3 fragPosition = _position.xyz;
|
vec3 fragPosition = _position.xyz;
|
||||||
vec3 fragNormal = normalize(_normal);
|
vec3 fragNormal = normalize(_normal);
|
||||||
vec3 fragAlbedo = albedo.rgb * _color;
|
vec3 fragAlbedo = albedo.rgb * _color;
|
||||||
|
float fragMetallic = 0.0;
|
||||||
vec3 fragSpecular = vec3(0.1);
|
vec3 fragSpecular = vec3(0.1);
|
||||||
float fragGloss = 10.0 / 128.0;
|
float fragRoughness = 0.9;
|
||||||
float fragOpacity = albedo.a * _alpha;
|
float fragOpacity = albedo.a * _alpha;
|
||||||
|
|
||||||
vec4 color = evalGlobalColor(1.0,
|
vec4 color = evalGlobalColor(1.0,
|
||||||
fragPosition,
|
fragPosition,
|
||||||
fragNormal,
|
fragNormal,
|
||||||
fragAlbedo,
|
fragAlbedo,
|
||||||
|
fragMetallic,
|
||||||
fragSpecular,
|
fragSpecular,
|
||||||
fragGloss,
|
fragRoughness,
|
||||||
fragOpacity);
|
fragOpacity);
|
||||||
|
|
||||||
// Apply standard tone mapping
|
// Apply standard tone mapping
|
||||||
|
|
|
@ -60,7 +60,7 @@ void main(void) {
|
||||||
vec3 fragNormal = vec3(invViewMat * vec4(frag.normal, 0.0));
|
vec3 fragNormal = vec3(invViewMat * vec4(frag.normal, 0.0));
|
||||||
vec4 fragEyeVector = invViewMat * vec4(-frag.position.xyz, 0.0);
|
vec4 fragEyeVector = invViewMat * vec4(-frag.position.xyz, 0.0);
|
||||||
vec3 fragEyeDir = normalize(fragEyeVector.xyz);
|
vec3 fragEyeDir = normalize(fragEyeVector.xyz);
|
||||||
vec4 shading = evalFragShading(fragNormal, fragLightDir, fragEyeDir, frag.specular, frag.gloss);
|
vec4 shading = evalFragShading(fragNormal, fragLightDir, fragEyeDir, frag.metallic, frag.specular, frag.roughness);
|
||||||
|
|
||||||
// Eval attenuation
|
// Eval attenuation
|
||||||
float radialAttenuation = evalLightAttenuation(light, fragLightDistance);
|
float radialAttenuation = evalLightAttenuation(light, fragLightDistance);
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// 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 DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
uniform sampler2D Font;
|
uniform sampler2D Font;
|
||||||
uniform bool Outline;
|
uniform bool Outline;
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
|
@ -17,12 +19,11 @@ uniform vec4 Color;
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
/*
|
||||||
layout(location = 0) out vec4 _fragColor0;
|
layout(location = 0) out vec4 _fragColor0;
|
||||||
layout(location = 1) out vec4 _fragColor1;
|
layout(location = 1) out vec4 _fragColor1;
|
||||||
layout(location = 2) out vec4 _fragColor2;
|
layout(location = 2) out vec4 _fragColor2;
|
||||||
|
*/
|
||||||
const float DEFAULT_SHININESS = 10;
|
|
||||||
|
|
||||||
const float gamma = 2.2;
|
const float gamma = 2.2;
|
||||||
const float smoothing = 256.0;
|
const float smoothing = 256.0;
|
||||||
|
@ -53,7 +54,16 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// final color
|
// final color
|
||||||
_fragColor0 = vec4(Color.rgb, Color.a * a);
|
/* _fragColor0 = vec4(Color.rgb, Color.a * a);
|
||||||
_fragColor1 = vec4(normalize(_normal.xyz), 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5);
|
_fragColor1 = vec4(normalize(_normal.xyz), 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5);
|
||||||
_fragColor2 = vec4(Color.rgb, DEFAULT_SHININESS / 128.0);
|
_fragColor2 = vec4(Color.rgb, 10 / 128.0);
|
||||||
|
*/
|
||||||
|
packDeferredFragmentLightmap(
|
||||||
|
normalize(_normal),
|
||||||
|
Color.a * a,
|
||||||
|
Color.rgb,
|
||||||
|
DEFAULT_ROUGHNESS,
|
||||||
|
DEFAULT_METALLIC,
|
||||||
|
DEFAULT_SPECULAR,
|
||||||
|
Color.rgb);
|
||||||
}
|
}
|
|
@ -51,9 +51,9 @@ void main(void) {
|
||||||
|
|
||||||
if (emissiveAmount > 0.0) {
|
if (emissiveAmount > 0.0) {
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normal, 1.0, diffuse, specular, shininess, specular);
|
normal, 1.0, diffuse, max(0, 1.0 - shininess / 128.0), DEFAULT_METALLIC, specular, specular);
|
||||||
} else {
|
} else {
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normal, 1.0, diffuse, specular, shininess);
|
normal, 1.0, diffuse, max(0, 1.0 - shininess / 128.0), DEFAULT_METALLIC, specular);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,5 +31,7 @@ void main(void) {
|
||||||
normalize(_normal.xyz),
|
normalize(_normal.xyz),
|
||||||
texel.a,
|
texel.a,
|
||||||
_color.rgb * texel.rgb,
|
_color.rgb * texel.rgb,
|
||||||
DEFAULT_SPECULAR, DEFAULT_SHININESS);
|
DEFAULT_ROUGHNESS,
|
||||||
|
DEFAULT_METALLIC,
|
||||||
|
DEFAULT_SPECULAR);
|
||||||
}
|
}
|
|
@ -29,6 +29,8 @@ void main(void) {
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
texel.a,
|
texel.a,
|
||||||
_color.rgb,
|
_color.rgb,
|
||||||
DEFAULT_SPECULAR, DEFAULT_SHININESS,
|
DEFAULT_ROUGHNESS,
|
||||||
|
DEFAULT_METALLIC,
|
||||||
|
DEFAULT_SPECULAR,
|
||||||
texel.rgb);
|
texel.rgb);
|
||||||
}
|
}
|
|
@ -66,7 +66,7 @@ void main(void) {
|
||||||
vec3 fragNormal = vec3(invViewMat * vec4(frag.normal, 0.0));
|
vec3 fragNormal = vec3(invViewMat * vec4(frag.normal, 0.0));
|
||||||
vec4 fragEyeVector = invViewMat * vec4(-frag.position.xyz, 0.0);
|
vec4 fragEyeVector = invViewMat * vec4(-frag.position.xyz, 0.0);
|
||||||
vec3 fragEyeDir = normalize(fragEyeVector.xyz);
|
vec3 fragEyeDir = normalize(fragEyeVector.xyz);
|
||||||
vec4 shading = evalFragShading(fragNormal, fragLightDir, fragEyeDir, frag.specular, frag.gloss);
|
vec4 shading = evalFragShading(fragNormal, fragLightDir, fragEyeDir, frag.metallic, frag.specular, frag.roughness);
|
||||||
|
|
||||||
// Eval attenuation
|
// Eval attenuation
|
||||||
float radialAttenuation = evalLightAttenuation(light, fragLightDistance);
|
float radialAttenuation = evalLightAttenuation(light, fragLightDistance);
|
||||||
|
|
|
@ -24,5 +24,5 @@ void main(void) {
|
||||||
normalize(_normal.xyz),
|
normalize(_normal.xyz),
|
||||||
1.0,
|
1.0,
|
||||||
_color.rgb,
|
_color.rgb,
|
||||||
DEFAULT_SPECULAR, DEFAULT_SHININESS);
|
DEFAULT_ROUGHNESS, DEFAULT_METALLIC, DEFAULT_SPECULAR);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue