Adding support for emissive and occlusion maps, on to pr land

This commit is contained in:
samcake 2016-02-24 17:30:29 -08:00
parent 2f5800a4cc
commit a0d7ce145e
35 changed files with 241 additions and 117 deletions

View file

@ -28,12 +28,13 @@ Column {
model: [ model: [
"Off", "Off",
"Depth", "Depth",
"Diffuse", "Albedo",
"Normal", "Normal",
"Roughness", "Roughness",
"Metallic", "Metallic",
"Fresnel", "Fresnel",
"Emissive", "Emissive",
"Occlusion",
"Lightmap", "Lightmap",
"Lighting", "Lighting",
"Shadow", "Shadow",

View file

@ -149,6 +149,14 @@ void FBXReader::consolidateFBXMaterials() {
material.emissiveTexture = emissiveTexture; material.emissiveTexture = emissiveTexture;
} }
FBXTexture occlusionTexture;
QString occlusionTextureID = occlusionTextures.value(material.materialID);
if (!occlusionTextureID.isNull()) {
occlusionTexture = getTexture(occlusionTextureID);
detectDifferentUVs |= (occlusionTexture.texcoordSet != 0) || (!emissiveTexture.transform.isIdentity());
material.occlusionTexture = occlusionTexture;
}
glm::vec2 lightmapParams(0.f, 1.f); glm::vec2 lightmapParams(0.f, 1.f);
lightmapParams.x = _lightmapOffset; lightmapParams.x = _lightmapOffset;
lightmapParams.y = _lightmapLevel; lightmapParams.y = _lightmapLevel;

View file

@ -363,6 +363,7 @@ static NetworkMaterial* buildNetworkMaterial(NetworkGeometry* geometry, const FB
material._material->setTextureMap(model::MaterialKey::METALLIC_MAP, metallicMap); material._material->setTextureMap(model::MaterialKey::METALLIC_MAP, metallicMap);
} }
if (!material.roughnessTexture.filename.isEmpty()) { if (!material.roughnessTexture.filename.isEmpty()) {
material.roughnessTexture.isGlossmap;
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;
@ -392,7 +393,15 @@ static NetworkMaterial* buildNetworkMaterial(NetworkGeometry* geometry, const FB
material._material->setTextureMap(model::MaterialKey::LIGHTMAP_MAP, lightmapMap); material._material->setTextureMap(model::MaterialKey::LIGHTMAP_MAP, lightmapMap);
} }
if (!material.occlusionTexture.filename.isEmpty()) {
networkMaterial->occlusionTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.occlusionTexture.filename)), OCCLUSION_TEXTURE, material.occlusionTexture.content);
networkMaterial->occlusionTextureName = material.occlusionTexture.name;
auto occlusionMap = model::TextureMapPointer(new model::TextureMap());
occlusionMap->setTextureSource(networkMaterial->occlusionTexture->_textureSource);
material._material->setTextureMap(model::MaterialKey::OCCLUSION_MAP, occlusionMap);
}
return networkMaterial; return networkMaterial;
} }

View file

@ -190,6 +190,8 @@ public:
QSharedPointer<NetworkTexture> roughnessTexture; QSharedPointer<NetworkTexture> roughnessTexture;
QString emissiveTextureName; QString emissiveTextureName;
QSharedPointer<NetworkTexture> emissiveTexture; QSharedPointer<NetworkTexture> emissiveTexture;
QString occlusionTextureName;
QSharedPointer<NetworkTexture> occlusionTexture;
QString lightmapTextureName; QString lightmapTextureName;
QSharedPointer<NetworkTexture> lightmapTexture; QSharedPointer<NetworkTexture> lightmapTexture;

View file

@ -29,7 +29,9 @@ class NetworkTexture;
typedef QSharedPointer<NetworkTexture> NetworkTexturePointer; typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, BUMP_TEXTURE, SPECULAR_TEXTURE, ROUGHNESS_TEXTURE, EMISSIVE_TEXTURE, CUBE_TEXTURE, LIGHTMAP_TEXTURE, CUSTOM_TEXTURE }; enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, BUMP_TEXTURE, SPECULAR_TEXTURE, ROUGHNESS_TEXTURE, EMISSIVE_TEXTURE,
CUBE_TEXTURE, OCCLUSION_TEXTURE, LIGHTMAP_TEXTURE, CUSTOM_TEXTURE
};
/// Stores cached textures, including render-to-texture targets. /// Stores cached textures, including render-to-texture targets.
class TextureCache : public ResourceCache, public Dependency { class TextureCache : public ResourceCache, public Dependency {

View file

@ -58,6 +58,7 @@ void Material::setOpacity(float opacity) {
void Material::setAlbedo(const Color& albedo, bool isSRGB) { void Material::setAlbedo(const Color& albedo, bool isSRGB) {
_key.setAlbedo(glm::any(glm::greaterThan(albedo, Color(0.0f)))); _key.setAlbedo(glm::any(glm::greaterThan(albedo, Color(0.0f))));
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
_schemaBuffer.edit<Schema>()._albedo = (isSRGB ? ColorUtils::toLinearVec3(albedo) : albedo); _schemaBuffer.edit<Schema>()._albedo = (isSRGB ? ColorUtils::toLinearVec3(albedo) : albedo);
} }

View file

@ -39,6 +39,7 @@ public:
ROUGHNESS_MAP_BIT, ROUGHNESS_MAP_BIT,
TRANSPARENT_MAP_BIT, TRANSPARENT_MAP_BIT,
NORMAL_MAP_BIT, NORMAL_MAP_BIT,
OCCLUSION_MAP_BIT,
LIGHTMAP_MAP_BIT, LIGHTMAP_MAP_BIT,
NUM_FLAGS, NUM_FLAGS,
@ -52,6 +53,7 @@ public:
ROUGHNESS_MAP, ROUGHNESS_MAP,
TRANSPARENT_MAP, TRANSPARENT_MAP,
NORMAL_MAP, NORMAL_MAP,
OCCLUSION_MAP,
LIGHTMAP_MAP, LIGHTMAP_MAP,
NUM_MAP_CHANNELS, NUM_MAP_CHANNELS,
@ -83,6 +85,7 @@ public:
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); }
Builder& withOcclusionMap() { _flags.set(OCCLUSION_MAP_BIT); return (*this); }
Builder& withLightmapMap() { _flags.set(LIGHTMAP_MAP_BIT); return (*this); } Builder& withLightmapMap() { _flags.set(LIGHTMAP_MAP_BIT); return (*this); }
// Convenient standard keys that we will keep on using all over the place // Convenient standard keys that we will keep on using all over the place
@ -124,6 +127,9 @@ public:
void setNormalMap(bool value) { _flags.set(NORMAL_MAP_BIT, value); } void setNormalMap(bool value) { _flags.set(NORMAL_MAP_BIT, value); }
bool isNormalMap() const { return _flags[NORMAL_MAP_BIT]; } bool isNormalMap() const { return _flags[NORMAL_MAP_BIT]; }
void setOcclusionMap(bool value) { _flags.set(OCCLUSION_MAP_BIT, value); }
bool isOcclusionMap() const { return _flags[OCCLUSION_MAP_BIT]; }
void setLightmapMap(bool value) { _flags.set(LIGHTMAP_MAP_BIT, value); } void setLightmapMap(bool value) { _flags.set(LIGHTMAP_MAP_BIT, value); }
bool isLightmapMap() const { return _flags[LIGHTMAP_MAP_BIT]; } bool isLightmapMap() const { return _flags[LIGHTMAP_MAP_BIT]; }
@ -182,6 +188,9 @@ public:
Builder& withoutNormalMap() { _value.reset(MaterialKey::NORMAL_MAP_BIT); _mask.set(MaterialKey::NORMAL_MAP_BIT); return (*this); } Builder& withoutNormalMap() { _value.reset(MaterialKey::NORMAL_MAP_BIT); _mask.set(MaterialKey::NORMAL_MAP_BIT); return (*this); }
Builder& withNormalMap() { _value.set(MaterialKey::NORMAL_MAP_BIT); _mask.set(MaterialKey::NORMAL_MAP_BIT); return (*this); } Builder& withNormalMap() { _value.set(MaterialKey::NORMAL_MAP_BIT); _mask.set(MaterialKey::NORMAL_MAP_BIT); return (*this); }
Builder& withoutOcclusionMap() { _value.reset(MaterialKey::OCCLUSION_MAP_BIT); _mask.set(MaterialKey::OCCLUSION_MAP_BIT); return (*this); }
Builder& withOcclusionMap() { _value.set(MaterialKey::OCCLUSION_MAP_BIT); _mask.set(MaterialKey::OCCLUSION_MAP_BIT); return (*this); }
Builder& withoutLightmapMap() { _value.reset(MaterialKey::LIGHTMAP_MAP_BIT); _mask.set(MaterialKey::LIGHTMAP_MAP_BIT); return (*this); } Builder& withoutLightmapMap() { _value.reset(MaterialKey::LIGHTMAP_MAP_BIT); _mask.set(MaterialKey::LIGHTMAP_MAP_BIT); return (*this); }
Builder& withLightmapMap() { _value.set(MaterialKey::LIGHTMAP_MAP_BIT); _mask.set(MaterialKey::LIGHTMAP_MAP_BIT); return (*this); } Builder& withLightmapMap() { _value.set(MaterialKey::LIGHTMAP_MAP_BIT); _mask.set(MaterialKey::LIGHTMAP_MAP_BIT); return (*this); }

View file

@ -52,8 +52,9 @@ const int METALLIC_MAP_BIT = 0x00000080;
const int ROUGHNESS_MAP_BIT = 0x00000100; const int ROUGHNESS_MAP_BIT = 0x00000100;
const int TRANSPARENT_MAP_BIT = 0x00000200; const int TRANSPARENT_MAP_BIT = 0x00000200;
const int NORMAL_MAP_BIT = 0x00000400; const int NORMAL_MAP_BIT = 0x00000400;
const int OCCLUSION_MAP_BIT = 0x00000800;
const int LIGHTMAP_MAP_BIT = 0x00000800; const int LIGHTMAP_MAP_BIT = 0x00001000;

View file

@ -85,6 +85,13 @@ static const std::string DEFAULT_NORMAL_SHADER {
" }" " }"
}; };
static const std::string DEFAULT_OCCLUSION_SHADER{
"vec4 getFragmentColor() {"
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
" return vec4(vec3(frag.obscurance), 1.0);"
" }"
};
static const std::string DEFAULT_EMISSIVE_SHADER{ static const std::string DEFAULT_EMISSIVE_SHADER{
"vec4 getFragmentColor() {" "vec4 getFragmentColor() {"
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);" " DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
@ -184,6 +191,8 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string cust
return DEFAULT_DEPTH_SHADER; return DEFAULT_DEPTH_SHADER;
case EmissiveMode: case EmissiveMode:
return DEFAULT_EMISSIVE_SHADER; return DEFAULT_EMISSIVE_SHADER;
case OcclusionMode:
return DEFAULT_OCCLUSION_SHADER;
case LightmapMode: case LightmapMode:
return DEFAULT_LIGHTMAP_SHADER; return DEFAULT_LIGHTMAP_SHADER;
case LightingMode: case LightingMode:

View file

@ -54,6 +54,7 @@ protected:
MetallicMode, MetallicMode,
FresnelMode, FresnelMode,
EmissiveMode, EmissiveMode,
OcclusionMode,
LightmapMode, LightmapMode,
LightingMode, LightingMode,
ShadowMode, ShadowMode,

View file

@ -104,43 +104,20 @@ DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
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); frag.emissive = frag.specularVal.xyz;
if (frag.normalVal.a < 0.5) { if (frag.normalVal.a < 0.5) {
frag.mode = 0; frag.mode = 0;
frag.roughness = 2.0 * frag.normalVal.a; frag.roughness = 2.0 * frag.normalVal.a;
} else { } else {
frag.mode = LIGHT_MAPPED; frag.mode = LIGHT_MAPPED;
frag.roughness = 2.0 * frag.normalVal.a - 1.0; frag.roughness = 2.0 * frag.normalVal.a - 1.0;
frag.emissive = frag.specularVal.xyz;
} }
// if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
// frag.mode = LIGHT_MAPPED;
// frag.emissive = frag.specularVal.xyz;
// }
frag.metallic = frag.diffuseVal.a; frag.metallic = frag.diffuseVal.a;
frag.diffuse = frag.diffuseVal.xyz; frag.diffuse = frag.diffuseVal.xyz;
frag.specular = vec3(frag.metallic); frag.specular = vec3(frag.metallic);
/* if (frag.metallic > 0.5) { frag.obscurance = min(frag.specularVal.w, frag.obscurance);
frag.diffuse = vec3(0);
//frag.metallic = length(frag.specularVal);
frag.specular = frag.diffuseVal.xyz;
} else {
frag.diffuse = frag.diffuseVal.xyz;
//frag.metallic = length(frag.specularVal);
frag.specular = vec3(0.03);
}
*/
// frag.diffuse = frag.diffuseVal.xyz;
//frag.metallic = length(frag.specularVal);
//frag.specular = frag.specularVal.xyz;
//frag.roughness = frag.specularVal.w;
return frag; return frag;
} }

View file

@ -44,25 +44,27 @@ const float DEFAULT_ROUGHNESS = 0.9;
const float DEFAULT_SHININESS = 10; const float DEFAULT_SHININESS = 10;
const float DEFAULT_METALLIC = 0; const float DEFAULT_METALLIC = 0;
const vec3 DEFAULT_SPECULAR = vec3(0.1); const vec3 DEFAULT_SPECULAR = vec3(0.1);
const vec3 DEFAULT_EMISSIVE = vec3(0.0);
const float DEFAULT_OCCLUSION = 1.0;
void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 fresnel) { void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 emissive, float occlusion) {
if (alpha != 1.0) { if (alpha != 1.0) {
discard; discard;
} }
// vec3 baseColor = ((metallic < 0.5) ? albedo : fresnel);
_fragColor0 = vec4(albedo, metallic); _fragColor0 = vec4(albedo, metallic);
_fragColor1 = vec4(bestFitNormal(normal), 0.5 * clamp(roughness, 0.0, 1.0)); _fragColor1 = vec4(bestFitNormal(normal), 0.5 * clamp(roughness, 0.0, 1.0));
_fragColor2 = vec4(fresnel, roughness); _fragColor2 = vec4(emissive, occlusion);
} }
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 fresnel, 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, metallic); _fragColor0 = vec4(albedo, metallic);
_fragColor1 = vec4(bestFitNormal(normal), 0.5 + 0.5 * clamp(roughness, 0.0, 1.0)); _fragColor1 = vec4(bestFitNormal(normal), 0.5 + 0.5 * clamp(roughness, 0.0, 1.0));
_fragColor2 = vec4(emissive, roughness); _fragColor2 = vec4(emissive, 1.0);
} }
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness) { void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness) {

View file

@ -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, float metallic, vec3 fresnel, float roughness) { vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness) {
// Need the light now // Need the light now
Light light = getLight(); Light light = getLight();
@ -41,9 +41,11 @@ 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, metallic, fresnel, roughness);
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, vec3(metallic), 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);
color += emissive;
return color; return color;
} }
@ -52,7 +54,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, float metallic, vec3 fresnel, float roughness) { vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness) {
// Need the light now // Need the light now
Light light = getLight(); Light light = getLight();
@ -64,10 +66,10 @@ 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, metallic, fresnel, roughness); vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, vec3(metallic), 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);
color += emissive;
return color; return color;
} }
<@endfunc@> <@endfunc@>
@ -76,7 +78,7 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa
<$declareSkyboxMap()$> <$declareSkyboxMap()$>
vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 fresnel, float roughness) { vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness) {
// Need the light now // Need the light now
Light light = getLight(); Light light = getLight();
@ -87,9 +89,10 @@ 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, metallic, fresnel, roughness); vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, vec3(metallic), 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);
color += emissive;
return color; return color;
} }

View file

@ -11,7 +11,7 @@
<@if not MODEL_MATERIAL_TEXTURES_SLH@> <@if not MODEL_MATERIAL_TEXTURES_SLH@>
<@def MODEL_MATERIAL_TEXTURES_SLH@> <@def MODEL_MATERIAL_TEXTURES_SLH@>
<@func declareMaterialTextures(withAlbedo, withRoughness, withNormal, withMetallic)@> <@func declareMaterialTextures(withAlbedo, withRoughness, withNormal, withMetallic, withEmissive, withOcclusion)@>
<@if withAlbedo@> <@if withAlbedo@>
uniform sampler2D albedoMap; uniform sampler2D albedoMap;
@ -41,21 +41,40 @@ float fetchMetallicMap(vec2 uv) {
} }
<@endif@> <@endif@>
<@if withEmissive@>
uniform sampler2D emissiveMap;
vec3 fetchEmissiveMap(vec2 uv) {
return texture(emissiveMap, uv).rgb;
}
<@endif@>
<@if withOcclusion@>
uniform sampler2D occlusionMap;
float fetchOcclusionMap(vec2 uv) {
return texture(occlusionMap, uv).r;
}
<@endif@>
<@endfunc@> <@endfunc@>
<@func fetchMaterialTextures(texcoord0, albedo, roughness, normal, metallic)@> <@func fetchMaterialTextures(matKey, texcoord0, albedo, roughness, normal, metallic, emissive, occlusion)@>
<@if albedo@> <@if albedo@>
vec4 <$albedo$> = fetchAlbedoMap(<$texcoord0$>); vec4 <$albedo$> = (((<$matKey$> & ALBEDO_MAP_BIT) != 0) ? fetchAlbedoMap(<$texcoord0$>) : vec4(1.0));
<@endif@> <@endif@>
<@if roughness@> <@if roughness@>
float <$roughness$> = fetchRoughnessMap(<$texcoord0$>); float <$roughness$> = (((<$matKey$> & ROUGHNESS_MAP_BIT) != 0) ? fetchRoughnessMap(<$texcoord0$>) : 1.0);
<@endif@> <@endif@>
<@if normal@> <@if normal@>
vec3 <$normal$> = fetchNormalMap(<$texcoord0$>); vec3 <$normal$> = (((<$matKey$> & NORMAL_MAP_BIT) != 0) ? fetchNormalMap(<$texcoord0$>) : vec3(0.0, 1.0, 0.0));
<@endif@> <@endif@>
<@if metallic@> <@if metallic@>
float <$metallic$> = fetchMetallicMap(<$texcoord0$>); float <$metallic$> = (((<$matKey$> & METALLIC_MAP_BIT) != 0) ? fetchMetallicMap(<$texcoord0$>) : 0.0);
<@endif@>
<@if emissive@>
vec3 <$emissive$> = (((<$matKey$> & EMISSIVE_MAP_BIT) != 0) ? fetchEmissiveMap(<$texcoord0$>) : vec3(0.0));
<@endif@>
<@if occlusion@>
float <$occlusion$> = (((<$matKey$> & OCCLUSION_MAP_BIT) != 0) ? fetchOcclusionMap(<$texcoord0$>) : 1.0);
<@endif@> <@endif@>
<@endfunc@> <@endfunc@>
@ -83,6 +102,15 @@ vec3 fetchLightmapMap(vec2 uv) {
} }
<@endfunc@> <@endfunc@>
<@func evalMaterialAlbedo(fetchedAlbedo, materialAlbedo, matKey, albedo)@>
{
<$albedo$>.xyz = (((<$matKey$> & ALBEDO_VAL_BIT) != 0) ? <$materialAlbedo$> : vec3(1.0));
if (((<$matKey$> & ALBEDO_MAP_BIT) != 0)) {
<$albedo$>.xyz *= <$fetchedAlbedo$>.xyz;
}
}
<@endfunc@>
<@func evalMaterialRoughness(fetchedRoughness, materialRoughness, matKey, roughness)@> <@func evalMaterialRoughness(fetchedRoughness, materialRoughness, matKey, roughness)@>
{ {
@ -96,5 +124,16 @@ vec3 fetchLightmapMap(vec2 uv) {
} }
<@endfunc@> <@endfunc@>
<@func evalMaterialEmissive(fetchedEmissive, materialEmissive, matKey, emissive)@>
{
<$emissive$> = (((<$matKey$> & EMISSIVE_MAP_BIT) != 0) ? <$fetchedEmissive$> : <$materialEmissive$>);
}
<@endfunc@>
<@func evalMaterialOcclusion(fetchedOcclusion, matKey, occlusion)@>
{
<$occlusion$> = <$fetchedOcclusion$>;
}
<@endfunc@>
<@endif@> <@endif@>

View file

@ -193,22 +193,36 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
if (materialKey.isMetallicMap()) { if (materialKey.isMetallicMap()) {
auto specularMap = textureMaps[model::MaterialKey::METALLIC_MAP]; auto specularMap = textureMaps[model::MaterialKey::METALLIC_MAP];
if (specularMap && specularMap->isDefined()) { if (specularMap && specularMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::SPECULAR_MAP, specularMap->getTextureView()); batch.setResourceTexture(ShapePipeline::Slot::METALLIC_MAP, specularMap->getTextureView());
// texcoord are assumed to be the same has albedo // texcoord are assumed to be the same has albedo
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::SPECULAR_MAP, textureCache->getBlackTexture()); batch.setResourceTexture(ShapePipeline::Slot::METALLIC_MAP, textureCache->getBlackTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::SPECULAR_MAP, nullptr); batch.setResourceTexture(ShapePipeline::Slot::METALLIC_MAP, nullptr);
} }
// TODO: For now lightmaop is piped into the emissive map unit, we need to fix that and support for real emissive too // Occlusion map
if (materialKey.isOcclusionMap()) {
auto specularMap = textureMaps[model::MaterialKey::OCCLUSION_MAP];
if (specularMap && specularMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::OCCLUSION_MAP, specularMap->getTextureView());
// texcoord are assumed to be the same has albedo
} else {
batch.setResourceTexture(ShapePipeline::Slot::OCCLUSION_MAP, textureCache->getWhiteTexture());
}
} else {
batch.setResourceTexture(ShapePipeline::Slot::OCCLUSION_MAP, nullptr);
}
// Emissive / Lightmap
if (materialKey.isLightmapMap()) { if (materialKey.isLightmapMap()) {
auto lightmapMap = textureMaps[model::MaterialKey::LIGHTMAP_MAP]; auto lightmapMap = textureMaps[model::MaterialKey::LIGHTMAP_MAP];
if (lightmapMap && lightmapMap->isDefined()) { if (lightmapMap && lightmapMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::LIGHTMAP_MAP, lightmapMap->getTextureView()); batch.setResourceTexture(ShapePipeline::Slot::EMISSIVE_LIGHTMAP_MAP, lightmapMap->getTextureView());
auto lightmapOffsetScale = lightmapMap->getLightmapOffsetScale(); auto lightmapOffsetScale = lightmapMap->getLightmapOffsetScale();
batch._glUniform2f(locations->emissiveParams, lightmapOffsetScale.x, lightmapOffsetScale.y); batch._glUniform2f(locations->emissiveParams, lightmapOffsetScale.x, lightmapOffsetScale.y);
@ -217,10 +231,18 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
lightmapMap->getTextureTransform().getMatrix(texcoordTransform[1]); lightmapMap->getTextureTransform().getMatrix(texcoordTransform[1]);
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::LIGHTMAP_MAP, textureCache->getGrayTexture()); batch.setResourceTexture(ShapePipeline::Slot::EMISSIVE_LIGHTMAP_MAP, textureCache->getGrayTexture());
}
} else if (materialKey.isEmissiveMap()) {
auto emissiveMap = textureMaps[model::MaterialKey::EMISSIVE_MAP];
if (emissiveMap && emissiveMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::EMISSIVE_LIGHTMAP_MAP, emissiveMap->getTextureView());
} else {
batch.setResourceTexture(ShapePipeline::Slot::EMISSIVE_LIGHTMAP_MAP, textureCache->getBlackTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::LIGHTMAP_MAP, nullptr); batch.setResourceTexture(ShapePipeline::Slot::EMISSIVE_LIGHTMAP_MAP, nullptr);
} }
// Texcoord transforms ? // Texcoord transforms ?

View file

@ -45,7 +45,7 @@ void main(void) {
frag.normal, frag.normal,
frag.diffuse, frag.diffuse,
frag.metallic, frag.metallic,
frag.specular, frag.emissive,
frag.roughness); frag.roughness);
_fragColor = vec4(color, frag.normalVal.a); _fragColor = vec4(color, frag.normalVal.a);
} }

View file

@ -47,7 +47,7 @@ void main(void) {
frag.normal, frag.normal,
frag.diffuse, frag.diffuse,
frag.metallic, frag.metallic,
frag.specular, frag.emissive,
frag.roughness); frag.roughness);
_fragColor = vec4(color, frag.normalVal.a); _fragColor = vec4(color, frag.normalVal.a);
} }

View file

@ -46,7 +46,7 @@ void main(void) {
frag.normal, frag.normal,
frag.diffuse, frag.diffuse,
frag.metallic, frag.metallic,
frag.specular, frag.emissive,
frag.roughness); frag.roughness);
_fragColor = vec4(color, frag.normalVal.a); _fragColor = vec4(color, frag.normalVal.a);
} }

View file

@ -48,7 +48,7 @@ void main(void) {
frag.normal, frag.normal,
frag.diffuse, frag.diffuse,
frag.metallic, frag.metallic,
frag.specular, frag.emissive,
frag.roughness); frag.roughness);
_fragColor = vec4(color, frag.normalVal.a); _fragColor = vec4(color, frag.normalVal.a);
} }

View file

@ -46,7 +46,7 @@ void main(void) {
frag.normal, frag.normal,
frag.diffuse, frag.diffuse,
frag.metallic, frag.metallic,
frag.specular, frag.emissive,
frag.roughness); frag.roughness);
_fragColor = vec4(color, frag.normalVal.a); _fragColor = vec4(color, frag.normalVal.a);

View file

@ -48,7 +48,7 @@ void main(void) {
frag.normal, frag.normal,
frag.diffuse, frag.diffuse,
frag.metallic, frag.metallic,
frag.specular, frag.emissive,
frag.roughness); frag.roughness);
_fragColor = vec4(color, frag.normalVal.a); _fragColor = vec4(color, frag.normalVal.a);

View file

@ -16,7 +16,7 @@
<@include model/Material.slh@> <@include model/Material.slh@>
<@include MaterialTextures.slh@> <@include MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS)$> <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
in vec4 _position; in vec4 _position;
in vec3 _normal; in vec3 _normal;
@ -25,15 +25,26 @@ in vec2 _texCoord0;
void main(void) { void main(void) {
<$fetchMaterialTextures(_texCoord0, albedo, roughness)$>
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
packDeferredFragment( packDeferredFragment(
normalize(_normal.xyz), normalize(_normal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
getMaterialAlbedo(mat) * albedo.rgb * _color, albedo,
getMaterialRoughness(mat) * roughness, roughness,
getMaterialMetallic(mat), getMaterialMetallic(mat),
getMaterialFresnel(mat)); emissive,
occlusionTex);
} }

View file

@ -27,11 +27,11 @@ in vec3 _normal;
in vec3 _color; in vec3 _color;
void main(void) { void main(void) {
Material mat = getMaterial();
<$fetchMaterialTextures(_texCoord0, albedo, roughness)$> int matKey = getMaterialKey(mat);
<$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness)$>
<$fetchMaterialLightmap(_texCoord1, emissive)$> <$fetchMaterialLightmap(_texCoord1, emissive)$>
Material mat = getMaterial();
packDeferredFragmentLightmap( packDeferredFragmentLightmap(
normalize(_normal), normalize(_normal),

View file

@ -28,11 +28,10 @@ in vec3 _tangent;
in vec3 _color; in vec3 _color;
void main(void) { void main(void) {
<$fetchMaterialTextures(_texCoord0, albedo, roughness, normalTexel)$>
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness, normalTexel)$>
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
vec3 viewNormal; vec3 viewNormal;
<$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$> <$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$>

View file

@ -28,10 +28,10 @@ in vec3 _tangent;
in vec3 _color; in vec3 _color;
void main(void) { void main(void) {
<$fetchMaterialTextures(_texCoord0, albedo, roughness, normalTexel, metalllicTex)$>
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
vec3 viewNormal; vec3 viewNormal;
<$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$> <$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$>
@ -41,7 +41,7 @@ void main(void) {
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
getMaterialAlbedo(mat) * albedo.rgb * _color, getMaterialAlbedo(mat) * albedo.rgb * _color,
getMaterialRoughness(mat) * roughness, getMaterialRoughness(mat) * roughness,
getMaterialMetallic(mat) * metalllicTex, getMaterialMetallic(mat) * metallicTex,
/*specular, // no use of */ getMaterialFresnel(mat), /*specular, // no use of */ getMaterialFresnel(mat),
lightmapVal); lightmapVal);
} }

View file

@ -27,17 +27,17 @@ in vec3 _normal;
in vec3 _color; in vec3 _color;
void main(void) { void main(void) {
<$fetchMaterialTextures(_texCoord0, albedo, roughness, _SCRIBE_NULL, specular)$>
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
packDeferredFragmentLightmap( packDeferredFragmentLightmap(
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) * roughness, getMaterialRoughness(mat) * roughness,
getMaterialMetallic(mat), getMaterialMetallic(mat) * metallicTex,
/*specular, // no use of */getMaterialFresnel(mat), /*metallicTex, // no use of */getMaterialFresnel(mat),
lightmapVal); lightmapVal);
} }

View file

@ -17,7 +17,7 @@
<@include model/Material.slh@> <@include model/Material.slh@>
<@include MaterialTextures.slh@> <@include MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL)$> <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
in vec4 _position; in vec4 _position;
in vec2 _texCoord0; in vec2 _texCoord0;
@ -26,18 +26,29 @@ in vec3 _tangent;
in vec3 _color; in vec3 _color;
void main(void) { void main(void) {
<$fetchMaterialTextures(_texCoord0, albedo, roughness, normalTexel)$>
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
vec3 viewNormal; vec3 viewNormal;
<$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$> <$tangentToViewSpace(normalTex, _normal, _tangent, viewNormal)$>
packDeferredFragment( packDeferredFragment(
viewNormal, viewNormal,
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
getMaterialAlbedo(mat) * albedo.rgb * _color, albedo,
getMaterialRoughness(mat) * roughness, roughness,
getMaterialMetallic(mat), getMaterialMetallic(mat),
getMaterialFresnel(mat)); emissive,
occlusionTex);
} }

View file

@ -17,7 +17,7 @@
<@include model/Material.slh@> <@include model/Material.slh@>
<@include MaterialTextures.slh@> <@include MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$> <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
in vec4 _position; in vec4 _position;
in vec2 _texCoord0; in vec2 _texCoord0;
@ -26,18 +26,22 @@ in vec3 _tangent;
in vec3 _color; in vec3 _color;
void main(void) { void main(void) {
<$fetchMaterialTextures(_texCoord0, albedo, roughnessTex, normalTexel, metallicTex)$>
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat); int matKey = getMaterialKey(mat);
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, occlusionTex)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color;
float roughness = getMaterialRoughness(mat); float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
vec3 viewNormal; vec3 viewNormal;
<$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$> <$tangentToViewSpace(normalTex, _normal, _tangent, viewNormal)$>
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
@ -45,10 +49,10 @@ void main(void) {
packDeferredFragment( packDeferredFragment(
normalize(viewNormal.xyz), normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
getMaterialAlbedo(mat) * albedo.rgb * _color, albedo,
roughness, roughness,
metallic, metallic,
/*vec3(specular) //*/getMaterialFresnel(mat) emissive,
); occlusionTex);
} }

View file

@ -17,7 +17,7 @@
<@include model/Material.slh@> <@include model/Material.slh@>
<@include MaterialTextures.slh@> <@include MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$> <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
in vec4 _position; in vec4 _position;
in vec2 _texCoord0; in vec2 _texCoord0;
@ -26,21 +26,29 @@ in vec3 _color;
void main(void) { void main(void) {
<$fetchMaterialTextures(_texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat); int matKey = getMaterialKey(mat);
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, occlusionTex)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
packDeferredFragment( packDeferredFragment(
normalize(_normal), normalize(_normal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
getMaterialAlbedo(mat) * albedo.rgb * _color, albedo,
getMaterialRoughness(mat) * roughness, roughness,
metallic, metallic,
/*vec3(specular) //*/ getMaterialFresnel(mat) emissive,
); occlusionTex);
} }

View file

@ -38,7 +38,7 @@ void main(void) {
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); float fragMetallic = getMaterialMetallic(mat);
vec3 fragFresnel = getMaterialFresnel(mat); vec3 fragEmissive = getMaterialEmissive(mat);
float fragRoughness = getMaterialRoughness(mat); float fragRoughness = getMaterialRoughness(mat);
float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha; float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha;
@ -52,7 +52,7 @@ void main(void) {
fragNormal, fragNormal,
fragAlbedo, fragAlbedo,
fragMetallic, fragMetallic,
fragFresnel, fragEmissive,
fragRoughness), fragRoughness),
fragOpacity); fragOpacity);
} }

View file

@ -54,6 +54,6 @@ void main(void) {
normal, 1.0, diffuse, max(0, 1.0 - shininess / 128.0), DEFAULT_METALLIC, specular, specular); normal, 1.0, diffuse, max(0, 1.0 - shininess / 128.0), DEFAULT_METALLIC, specular, specular);
} else { } else {
packDeferredFragment( packDeferredFragment(
normal, 1.0, diffuse, max(0, 1.0 - shininess / 128.0), DEFAULT_METALLIC, specular); normal, 1.0, diffuse, max(0, 1.0 - shininess / 128.0), length(specular), DEFAULT_EMISSIVE, DEFAULT_OCCLUSION);
} }
} }

View file

@ -2,7 +2,7 @@
<$VERSION_HEADER$> <$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$> // Generated on <$_SCRIBE_DATE$>
// //
// simple.frag // simple_textured.slf
// fragment shader // fragment shader
// //
// Created by Clément Brisset on 5/29/15. // Created by Clément Brisset on 5/29/15.
@ -33,5 +33,6 @@ void main(void) {
_color.rgb * texel.rgb, _color.rgb * texel.rgb,
DEFAULT_ROUGHNESS, DEFAULT_ROUGHNESS,
DEFAULT_METALLIC, DEFAULT_METALLIC,
DEFAULT_SPECULAR); DEFAULT_EMISSIVE,
DEFAULT_OCCLUSION);
} }

View file

@ -56,8 +56,9 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
slotBindings.insert(gpu::Shader::Binding(std::string("albedoMap"), Slot::ALBEDO_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("albedoMap"), Slot::ALBEDO_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("roughnessMap"), Slot::ROUGHNESS_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("roughnessMap"), Slot::ROUGHNESS_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), Slot::NORMAL_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), Slot::NORMAL_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), Slot::SPECULAR_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), Slot::METALLIC_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), Slot::LIGHTMAP_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), Slot::EMISSIVE_LIGHTMAP_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("occlusionMap"), Slot::OCCLUSION_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::LIGHT_BUFFER)); slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::LIGHT_BUFFER));
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), Slot::NORMAL_FITTING_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), Slot::NORMAL_FITTING_MAP));
@ -72,6 +73,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
locations->normalTextureUnit = program->getTextures().findLocation("normalMap"); locations->normalTextureUnit = program->getTextures().findLocation("normalMap");
locations->specularTextureUnit = program->getTextures().findLocation("specularMap"); locations->specularTextureUnit = program->getTextures().findLocation("specularMap");
locations->emissiveTextureUnit = program->getTextures().findLocation("emissiveMap"); locations->emissiveTextureUnit = program->getTextures().findLocation("emissiveMap");
locations->occlusionTextureUnit = program->getTextures().findLocation("occlusionMap");
locations->skinClusterBufferUnit = program->getBuffers().findLocation("skinClusterBuffer"); locations->skinClusterBufferUnit = program->getBuffers().findLocation("skinClusterBuffer");
locations->materialBufferUnit = program->getBuffers().findLocation("materialBuffer"); locations->materialBufferUnit = program->getBuffers().findLocation("materialBuffer");
locations->lightBufferUnit = program->getBuffers().findLocation("lightBuffer"); locations->lightBufferUnit = program->getBuffers().findLocation("lightBuffer");

View file

@ -197,9 +197,10 @@ public:
static const int MATERIAL_GPU = 3; static const int MATERIAL_GPU = 3;
static const int ALBEDO_MAP = 0; static const int ALBEDO_MAP = 0;
static const int NORMAL_MAP = 1; static const int NORMAL_MAP = 1;
static const int SPECULAR_MAP = 2; static const int METALLIC_MAP = 2;
static const int LIGHTMAP_MAP = 3; static const int EMISSIVE_LIGHTMAP_MAP = 3;
static const int ROUGHNESS_MAP = 4; static const int ROUGHNESS_MAP = 4;
static const int OCCLUSION_MAP = 5;
static const int LIGHT_BUFFER = 4; static const int LIGHT_BUFFER = 4;
static const int NORMAL_FITTING_MAP = 10; static const int NORMAL_FITTING_MAP = 10;
@ -213,6 +214,7 @@ public:
int roughnessTextureUnit; int roughnessTextureUnit;
int specularTextureUnit; int specularTextureUnit;
int emissiveTextureUnit; int emissiveTextureUnit;
int occlusionTextureUnit;
int emissiveParams; int emissiveParams;
int normalFittingMapUnit; int normalFittingMapUnit;
int skinClusterBufferUnit; int skinClusterBufferUnit;

View file

@ -24,5 +24,5 @@ void main(void) {
normalize(_normal.xyz), normalize(_normal.xyz),
1.0, 1.0,
_color.rgb, _color.rgb,
DEFAULT_ROUGHNESS, DEFAULT_METALLIC, DEFAULT_SPECULAR); DEFAULT_ROUGHNESS, DEFAULT_METALLIC, DEFAULT_EMISSIVE, DEFAULT_OCCLUSION);
} }