From 2d573963bbe9c9d49e21e17adee6264e06890341 Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 4 May 2016 18:50:52 -0700 Subject: [PATCH] Introducing the unlit material --- libraries/fbx/src/FBXReader.cpp | 1 - libraries/fbx/src/FBXReader_Material.cpp | 7 + libraries/model/src/model/Material.cpp | 5 + libraries/model/src/model/Material.h | 17 +- libraries/model/src/model/Material.slh | 27 ++-- .../render-utils/src/DebugDeferredBuffer.cpp | 4 +- libraries/render-utils/src/DeferredBuffer.slh | 145 +++--------------- .../render-utils/src/DeferredBufferWrite.slh | 25 +-- .../src/debug_deferred_buffer.slf | 2 +- .../src/directional_ambient_light.slf | 4 +- .../src/directional_ambient_light_shadow.slf | 4 +- .../render-utils/src/directional_light.slf | 4 +- .../src/directional_light_shadow.slf | 4 +- .../src/directional_skybox_light.slf | 4 +- .../src/directional_skybox_light_shadow.slf | 4 +- libraries/render-utils/src/point_light.slf | 2 +- libraries/render-utils/src/spot_light.slf | 2 +- tools/scribe/src/main.cpp | 11 +- 18 files changed, 109 insertions(+), 163 deletions(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 3b705ec0b2..b7a4d4ec85 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -991,7 +991,6 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS QString propname = subobject.name.data(); int unknown = 0; if ( (propname == "Version") - ||(propname == "ShadingModel") ||(propname == "Multilayer")) { } else { unknown++; diff --git a/libraries/fbx/src/FBXReader_Material.cpp b/libraries/fbx/src/FBXReader_Material.cpp index 11c6dad2f2..9861fe1d68 100644 --- a/libraries/fbx/src/FBXReader_Material.cpp +++ b/libraries/fbx/src/FBXReader_Material.cpp @@ -212,6 +212,13 @@ void FBXReader::consolidateFBXMaterials() { material._material->setRoughness(model::Material::shininessToRoughness(material.shininess)); float metallic = std::max(material.specularColor.x, std::max(material.specularColor.y, material.specularColor.z)); material._material->setMetallic(metallic); + + if (material.shadingModel == "lambert") { + if (!material._material->getKey().isAlbedo()) { + material._material->setUnlit(true); + std::cout << emissive; + } + } } if (material.opacity <= 0.0f) { diff --git a/libraries/model/src/model/Material.cpp b/libraries/model/src/model/Material.cpp index d700a191c4..ba61732237 100755 --- a/libraries/model/src/model/Material.cpp +++ b/libraries/model/src/model/Material.cpp @@ -74,6 +74,11 @@ void Material::setOpacity(float opacity) { _schemaBuffer.edit()._opacity = opacity; } +void Material::setUnlit(bool value) { + _key.setUnlit(value); + _schemaBuffer.edit()._key = (uint32)_key._flags.to_ulong(); +} + void Material::setAlbedo(const Color& albedo, bool isSRGB) { _key.setAlbedo(glm::any(glm::greaterThan(albedo, Color(0.0f)))); _schemaBuffer.edit()._key = (uint32)_key._flags.to_ulong(); diff --git a/libraries/model/src/model/Material.h b/libraries/model/src/model/Material.h index cf6b48f257..8dd9dd7960 100755 --- a/libraries/model/src/model/Material.h +++ b/libraries/model/src/model/Material.h @@ -28,14 +28,15 @@ class MaterialKey { public: enum FlagBit { EMISSIVE_VAL_BIT = 0, + UNLIT_VAL_BIT, ALBEDO_VAL_BIT, METALLIC_VAL_BIT, GLOSSY_VAL_BIT, OPACITY_VAL_BIT, - OPACITY_MASK_MAP_BIT, // OPacity Map and Opacity MASK map are mutually exclusive + OPACITY_MASK_MAP_BIT, // Opacity Map and Opacity MASK map are mutually exclusive OPACITY_TRANSLUCENT_MAP_BIT, - // THe map bits must be in the smae sequence as the enum names for the map channels + // THe map bits must be in the same sequence as the enum names for the map channels EMISSIVE_MAP_BIT, ALBEDO_MAP_BIT, METALLIC_MAP_BIT, @@ -74,9 +75,12 @@ public: MaterialKey build() const { return MaterialKey(_flags); } Builder& withEmissive() { _flags.set(EMISSIVE_VAL_BIT); return (*this); } + Builder& withUnlit() { _flags.set(UNLIT_VAL_BIT); return (*this); } + Builder& withAlbedo() { _flags.set(ALBEDO_VAL_BIT); return (*this); } Builder& withMetallic() { _flags.set(METALLIC_VAL_BIT); return (*this); } Builder& withGlossy() { _flags.set(GLOSSY_VAL_BIT); return (*this); } + Builder& withTranslucentFactor() { _flags.set(OPACITY_VAL_BIT); return (*this); } Builder& withEmissiveMap() { _flags.set(EMISSIVE_MAP_BIT); return (*this); } @@ -98,6 +102,9 @@ public: void setEmissive(bool value) { _flags.set(EMISSIVE_VAL_BIT, value); } bool isEmissive() const { return _flags[EMISSIVE_VAL_BIT]; } + void setUnlit(bool value) { _flags.set(UNLIT_VAL_BIT, value); } + bool isUnlit() const { return _flags[UNLIT_VAL_BIT]; } + void setEmissiveMap(bool value) { _flags.set(EMISSIVE_MAP_BIT, value); } bool isEmissiveMap() const { return _flags[EMISSIVE_MAP_BIT]; } @@ -172,6 +179,9 @@ public: Builder& withoutEmissiveMap() { _value.reset(MaterialKey::EMISSIVE_MAP_BIT); _mask.set(MaterialKey::EMISSIVE_MAP_BIT); return (*this); } Builder& withEmissiveMap() { _value.set(MaterialKey::EMISSIVE_MAP_BIT); _mask.set(MaterialKey::EMISSIVE_MAP_BIT); return (*this); } + Builder& withoutUnlit() { _value.reset(MaterialKey::UNLIT_VAL_BIT); _mask.set(MaterialKey::UNLIT_VAL_BIT); return (*this); } + Builder& withUnlit() { _value.set(MaterialKey::UNLIT_VAL_BIT); _mask.set(MaterialKey::UNLIT_VAL_BIT); return (*this); } + Builder& withoutAlbedo() { _value.reset(MaterialKey::ALBEDO_VAL_BIT); _mask.set(MaterialKey::ALBEDO_VAL_BIT); return (*this); } Builder& withAlbedo() { _value.set(MaterialKey::ALBEDO_VAL_BIT); _mask.set(MaterialKey::ALBEDO_VAL_BIT); return (*this); } @@ -250,6 +260,9 @@ public: void setOpacity(float opacity); float getOpacity() const { return _schemaBuffer.get()._opacity; } + void setUnlit(bool value); + bool isUnlit() const { return _key.isUnlit(); } + void setAlbedo(const Color& albedo, bool isSRGB = true); Color getAlbedo(bool SRGB = true) const { return (SRGB ? ColorUtils::tosRGBVec3(_schemaBuffer.get()._albedo) : _schemaBuffer.get()._albedo); } diff --git a/libraries/model/src/model/Material.slh b/libraries/model/src/model/Material.slh index 28f9769a8b..4a6139c664 100644 --- a/libraries/model/src/model/Material.slh +++ b/libraries/model/src/model/Material.slh @@ -40,20 +40,21 @@ float getMaterialShininess(Material m) { return 1.0 - getMaterialRoughness(m); } int getMaterialKey(Material m) { return floatBitsToInt(m._spareKey.w); } const int EMISSIVE_VAL_BIT = 0x00000001; -const int ALBEDO_VAL_BIT = 0x00000002; -const int METALLIC_VAL_BIT = 0x00000004; -const int GLOSSY_VAL_BIT = 0x00000008; -const int OPACITY_VAL_BIT = 0x00000010; -const int OPACITY_MASK_MAP_BIT = 0x00000020; -const int OPACITY_TRANSLUCENT_MAP_BIT = 0x00000040; +const int UNLIT_VAL_BIT = 0x00000002; +const int ALBEDO_VAL_BIT = 0x00000004; +const int METALLIC_VAL_BIT = 0x00000008; +const int GLOSSY_VAL_BIT = 0x00000010; +const int OPACITY_VAL_BIT = 0x00000020; +const int OPACITY_MASK_MAP_BIT = 0x00000040; +const int OPACITY_TRANSLUCENT_MAP_BIT = 0x00000080; -const int EMISSIVE_MAP_BIT = 0x00000080; -const int ALBEDO_MAP_BIT = 0x00000100; -const int METALLIC_MAP_BIT = 0x00000200; -const int ROUGHNESS_MAP_BIT = 0x00000400; -const int NORMAL_MAP_BIT = 0x00000800; -const int OCCLUSION_MAP_BIT = 0x00001000; -const int LIGHTMAP_MAP_BIT = 0x00002000; +const int EMISSIVE_MAP_BIT = 0x00000100; +const int ALBEDO_MAP_BIT = 0x00000200; +const int METALLIC_MAP_BIT = 0x00000400; +const int ROUGHNESS_MAP_BIT = 0x00000800; +const int NORMAL_MAP_BIT = 0x00001000; +const int OCCLUSION_MAP_BIT = 0x00002000; +const int LIGHTMAP_MAP_BIT = 0x00004000; <@endif@> diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index c9ea223b3f..a95d0e2f91 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -90,14 +90,14 @@ static const std::string DEFAULT_OCCLUSION_SHADER{ 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));" + " return (frag.mode != FRAG_MODE_LIGHTMAPPED ? 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));" + " return (frag.mode == FRAG_MODE_LIGHTMAPPED ? vec4(frag.emissive, 1.0) : vec4(vec3(0.0), 1.0));" " }" }; diff --git a/libraries/render-utils/src/DeferredBuffer.slh b/libraries/render-utils/src/DeferredBuffer.slh index 5a3c941ce3..9cf91002ef 100755 --- a/libraries/render-utils/src/DeferredBuffer.slh +++ b/libraries/render-utils/src/DeferredBuffer.slh @@ -11,135 +11,40 @@ <@if not DEFERRED_BUFFER_SLH@> <@def DEFERRED_BUFFER_SLH@> +// Unpack the metallic-mode value +const float FRAG_TYPE_UNLIT = 0.0; +const float FRAG_TYPE_SHADED_NON_METALLIC = 0.1; +const float FRAG_TYPE_SHADED_METALLIC = 0.2; +const float FRAG_TYPE_SHADED_RANGE_INV = 1.0 / (FRAG_TYPE_SHADED_METALLIC - FRAG_TYPE_SHADED_NON_METALLIC); -// the albedo texture -uniform sampler2D albedoMap; +const float FRAG_TYPE_LIGHTMAPPED_NON_METALLIC = 0.3; +const float FRAG_TYPE_LIGHTMAPPED_METALLIC = 0.4; +const float FRAG_TYPE_LIGHTMAPPED_RANGE_INV = 1.0 / (FRAG_TYPE_LIGHTMAPPED_METALLIC - FRAG_TYPE_LIGHTMAPPED_NON_METALLIC); -// the normal texture -uniform sampler2D normalMap; +const int FRAG_MODE_UNLIT = 0; +const int FRAG_MODE_SHADED = 1; +const int FRAG_MODE_LIGHTMAPPED = 2; -// the specular texture -uniform sampler2D specularMap; - -// the depth texture -uniform sampler2D depthMap; - -// the obscurance texture -uniform sampler2D obscuranceMap; - -// the lighting texture -uniform sampler2D lightingMap; - - -struct DeferredTransform { - mat4 projection; - mat4 viewInverse; - float stereoSide; - vec3 _spareABC; -}; - -layout(std140) uniform deferredTransformBuffer { - DeferredTransform _deferredTransform; -}; -DeferredTransform getDeferredTransform() { - return _deferredTransform; -} - -bool getStereoMode(DeferredTransform deferredTransform) { - return (deferredTransform.stereoSide != 0.0); -} -float getStereoSide(DeferredTransform deferredTransform) { - return (deferredTransform.stereoSide); -} - -vec4 evalEyePositionFromZ(DeferredTransform deferredTransform, float depthVal, vec2 texcoord) { - vec3 nPos = vec3(texcoord.xy * 2.0f - 1.0f, depthVal * 2.0f - 1.0f); - - // compute the view space position using the depth - // basically manually pick the proj matrix components to do the inverse - float Ze = -deferredTransform.projection[3][2] / (nPos.z + deferredTransform.projection[2][2]); - float Xe = (-Ze * nPos.x - Ze * deferredTransform.projection[2][0] - deferredTransform.projection[3][0]) / deferredTransform.projection[0][0]; - float Ye = (-Ze * nPos.y - Ze * deferredTransform.projection[2][1] - deferredTransform.projection[3][1]) / deferredTransform.projection[1][1]; - return vec4(Xe, Ye, Ze, 1.0f); -} - -struct DeferredFragment { - vec4 normalVal; - vec4 diffuseVal; - vec4 specularVal; - vec4 position; - vec3 normal; - float metallic; - vec3 diffuse; - float obscurance; - vec3 specular; - float roughness; - vec3 emissive; - int mode; - float depthVal; -}; - -const int LIGHT_MAPPED = 1; - -vec4 unpackDeferredPosition(DeferredTransform deferredTransform, float depthValue, vec2 texcoord) { - if (getStereoMode(deferredTransform)) { - if (texcoord.x > 0.5) { - texcoord.x -= 0.5; - } - texcoord.x *= 2.0; +void unpackModeMetallic(float rawValue, out int mode, out float metallic) { + if (rawValue < FRAG_TYPE_SHADED_NON_METALLIC) { + mode = FRAG_MODE_UNLIT; + metallic = 0.0; + } else if (rawValue <= FRAG_TYPE_SHADED_METALLIC) { + mode = FRAG_MODE_SHADED; + metallic = clamp((rawValue - FRAG_TYPE_SHADED_NON_METALLIC) * FRAG_TYPE_SHADED_RANGE_INV, 0.0, 1.0); + } else if (rawValue <= FRAG_TYPE_LIGHTMAPPED_METALLIC) { + mode = FRAG_MODE_LIGHTMAPPED; + metallic = clamp((rawValue - FRAG_TYPE_LIGHTMAPPED_NON_METALLIC) * FRAG_TYPE_SHADED_RANGE_INV, 0.0, 1.0); } - 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 - frag.normal = normalize(frag.normalVal.xyz * 2.0 - vec3(1.0)); - - frag.mode = 0; - frag.emissive = frag.specularVal.xyz; - if (frag.normalVal.a < 0.5) { - frag.mode = 0; - frag.roughness = 2.0 * frag.normalVal.a; - } else { - frag.mode = LIGHT_MAPPED; - frag.roughness = 2.0 * frag.normalVal.a - 1.0; - } - - frag.metallic = frag.diffuseVal.a; - frag.diffuse = frag.diffuseVal.xyz; - if (frag.metallic <= 0.5) { - frag.metallic = 0.0; - frag.specular = vec3(0.03); // Default Di-electric fresnel value - } else { - frag.specular = vec3(frag.diffuseVal.xyz); - frag.metallic = 1.0; - } - frag.obscurance = min(frag.specularVal.w, frag.obscurance); - - return frag; +float packShadedMetallic(float metallic) { + return mix(FRAG_TYPE_SHADED_NON_METALLIC, FRAG_TYPE_SHADED_METALLIC, metallic); } -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; +float packLightmappedMetallic(float metallic) { + return mix(FRAG_TYPE_LIGHTMAPPED_NON_METALLIC, FRAG_TYPE_LIGHTMAPPED_METALLIC, metallic); } - - <@endif@> diff --git a/libraries/render-utils/src/DeferredBufferWrite.slh b/libraries/render-utils/src/DeferredBufferWrite.slh index 24a2f0d8a5..6fc3b75b58 100755 --- a/libraries/render-utils/src/DeferredBufferWrite.slh +++ b/libraries/render-utils/src/DeferredBufferWrite.slh @@ -11,6 +11,8 @@ <@if not DEFERRED_BUFFER_WRITE_SLH@> <@def DEFERRED_BUFFER_WRITE_SLH@> +<@include DeferredBuffer.slh@> + layout(location = 0) out vec4 _fragColor0; layout(location = 1) out vec4 _fragColor1; layout(location = 2) out vec4 _fragColor2; @@ -48,13 +50,12 @@ const vec3 DEFAULT_EMISSIVE = vec3(0.0); const float DEFAULT_OCCLUSION = 1.0; const vec3 DEFAULT_FRESNEL = DEFAULT_EMISSIVE; - void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 emissive, float occlusion) { if (alpha != 1.0) { discard; } - _fragColor0 = vec4(albedo, metallic); - _fragColor1 = vec4(bestFitNormal(normal), 0.5 * clamp(roughness, 0.0, 1.0)); + _fragColor0 = vec4(albedo, packShadedMetallic(metallic)); + _fragColor1 = vec4(bestFitNormal(normal), clamp(roughness, 0.0, 1.0)); _fragColor2 = vec4(emissive, occlusion); } @@ -63,19 +64,25 @@ void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float r if (alpha != 1.0) { discard; } - _fragColor0 = vec4(albedo, metallic); - _fragColor1 = vec4(bestFitNormal(normal), 0.5 + 0.5 * clamp(roughness, 0.0, 1.0)); + _fragColor0 = vec4(albedo, packLightmappedMetallic(metallic)); + _fragColor1 = vec4(bestFitNormal(normal), clamp(roughness, 0.0, 1.0)); _fragColor2 = vec4(emissive, 1.0); } +void packDeferredFragmentUnlit(vec3 normal, float alpha, vec3 color) { + if (alpha != 1.0) { + discard; + } + _fragColor0 = vec4(color, FRAG_TYPE_UNLIT); + _fragColor1 = vec4(bestFitNormal(normal), 1.0); + //_fragColor2 = vec4(vec3(0.0), 1.0); // If unlit, do not worry about the emissive color target +} + void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness) { if (alpha <= 0.0) { discard; - } - + } _fragColor0 = vec4(albedo.rgb, alpha); - // _fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0); - // _fragColor2 = vec4(fresnel, roughness); } <@endif@> diff --git a/libraries/render-utils/src/debug_deferred_buffer.slf b/libraries/render-utils/src/debug_deferred_buffer.slf index bbc50fa97a..b323836657 100644 --- a/libraries/render-utils/src/debug_deferred_buffer.slf +++ b/libraries/render-utils/src/debug_deferred_buffer.slf @@ -12,7 +12,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> uniform sampler2D pyramidMap; uniform sampler2D occlusionMap; diff --git a/libraries/render-utils/src/directional_ambient_light.slf b/libraries/render-utils/src/directional_ambient_light.slf index e1ec0d3ef0..b770c7a086 100755 --- a/libraries/render-utils/src/directional_ambient_light.slf +++ b/libraries/render-utils/src/directional_ambient_light.slf @@ -12,7 +12,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> <@include DeferredGlobalLight.slh@> <$declareEvalLightmappedColor()$> @@ -27,7 +27,7 @@ void main(void) { float shadowAttenuation = 1.0; - if (frag.mode == LIGHT_MAPPED) { + if (frag.mode == FRAG_MODE_LIGHTMAPPED) { vec3 color = evalLightmappedColor( deferredTransform.viewInverse, shadowAttenuation, diff --git a/libraries/render-utils/src/directional_ambient_light_shadow.slf b/libraries/render-utils/src/directional_ambient_light_shadow.slf index 963a10d579..3ce17953ba 100644 --- a/libraries/render-utils/src/directional_ambient_light_shadow.slf +++ b/libraries/render-utils/src/directional_ambient_light_shadow.slf @@ -13,7 +13,7 @@ // <@include Shadow.slh@> -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> <@include DeferredGlobalLight.slh@> <$declareEvalLightmappedColor()$> @@ -29,7 +29,7 @@ void main(void) { vec4 worldPos = deferredTransform.viewInverse * vec4(frag.position.xyz, 1.0); float shadowAttenuation = evalShadowAttenuation(worldPos); - if (frag.mode == LIGHT_MAPPED) { + if (frag.mode == FRAG_MODE_LIGHTMAPPED) { vec3 color = evalLightmappedColor( deferredTransform.viewInverse, shadowAttenuation, diff --git a/libraries/render-utils/src/directional_light.slf b/libraries/render-utils/src/directional_light.slf index 1a739f9389..f04ca73204 100644 --- a/libraries/render-utils/src/directional_light.slf +++ b/libraries/render-utils/src/directional_light.slf @@ -12,7 +12,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> <@include DeferredGlobalLight.slh@> <$declareEvalLightmappedColor()$> @@ -28,7 +28,7 @@ void main(void) { float shadowAttenuation = 1.0; // Light mapped or not ? - if (frag.mode == LIGHT_MAPPED) { + if (frag.mode == FRAG_MODE_LIGHTMAPPED) { vec3 color = evalLightmappedColor( deferredTransform.viewInverse, shadowAttenuation, diff --git a/libraries/render-utils/src/directional_light_shadow.slf b/libraries/render-utils/src/directional_light_shadow.slf index 3b9b4d22c6..901655ad5d 100644 --- a/libraries/render-utils/src/directional_light_shadow.slf +++ b/libraries/render-utils/src/directional_light_shadow.slf @@ -13,7 +13,7 @@ // <@include Shadow.slh@> -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> <@include DeferredGlobalLight.slh@> <$declareEvalLightmappedColor()$> @@ -30,7 +30,7 @@ void main(void) { float shadowAttenuation = evalShadowAttenuation(worldPos); // Light mapped or not ? - if (frag.mode == LIGHT_MAPPED) { + if (frag.mode == FRAG_MODE_LIGHTMAPPED) { vec3 color = evalLightmappedColor( deferredTransform.viewInverse, shadowAttenuation, diff --git a/libraries/render-utils/src/directional_skybox_light.slf b/libraries/render-utils/src/directional_skybox_light.slf index 9e24a5f585..d05e12d614 100755 --- a/libraries/render-utils/src/directional_skybox_light.slf +++ b/libraries/render-utils/src/directional_skybox_light.slf @@ -12,7 +12,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> <@include DeferredGlobalLight.slh@> <$declareEvalLightmappedColor()$> @@ -28,7 +28,7 @@ void main(void) { float shadowAttenuation = 1.0; // Light mapped or not ? - if (frag.mode == LIGHT_MAPPED) { + if (frag.mode == FRAG_MODE_LIGHTMAPPED) { vec3 color = evalLightmappedColor( deferredTransform.viewInverse, shadowAttenuation, diff --git a/libraries/render-utils/src/directional_skybox_light_shadow.slf b/libraries/render-utils/src/directional_skybox_light_shadow.slf index c3008b5509..b848e1f288 100644 --- a/libraries/render-utils/src/directional_skybox_light_shadow.slf +++ b/libraries/render-utils/src/directional_skybox_light_shadow.slf @@ -13,7 +13,7 @@ //!> <@include Shadow.slh@> -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> <@include DeferredGlobalLight.slh@> <$declareEvalLightmappedColor()$> @@ -30,7 +30,7 @@ void main(void) { float shadowAttenuation = evalShadowAttenuation(worldPos); // Light mapped or not ? - if (frag.mode == LIGHT_MAPPED) { + if (frag.mode == FRAG_MODE_LIGHTMAPPED) { vec3 color = evalLightmappedColor( deferredTransform.viewInverse, shadowAttenuation, diff --git a/libraries/render-utils/src/point_light.slf b/libraries/render-utils/src/point_light.slf index 0cadf3a760..bab8b26f98 100644 --- a/libraries/render-utils/src/point_light.slf +++ b/libraries/render-utils/src/point_light.slf @@ -13,7 +13,7 @@ // // Everything about deferred buffer -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> //Everything about deferred lighting <@include DeferredLighting.slh@> diff --git a/libraries/render-utils/src/spot_light.slf b/libraries/render-utils/src/spot_light.slf index 8355dcf91b..a81408b293 100644 --- a/libraries/render-utils/src/spot_light.slf +++ b/libraries/render-utils/src/spot_light.slf @@ -13,7 +13,7 @@ // // Everything about deferred buffer -<@include DeferredBuffer.slh@> +<@include DeferredBufferRead.slh@> //Everything about deferred lighting <@include DeferredLighting.slh@> diff --git a/tools/scribe/src/main.cpp b/tools/scribe/src/main.cpp index 13003f05cf..50a2165647 100755 --- a/tools/scribe/src/main.cpp +++ b/tools/scribe/src/main.cpp @@ -191,10 +191,19 @@ int main (int argc, char** argv) { targetStringStream << "#ifndef scribe_" << targetName << "_h" << std::endl; targetStringStream << "#define scribe_" << targetName << "_h" << std::endl << std::endl; - // targetStringStream << "const char " << targetName << "[] = R\"XXXX(" << destStringStream.str() << ")XXXX\";"; + std::istringstream destStringStreamAgain(destStringStream.str()); + targetStringStream << "const char " << targetName << "[] = \n"; + while (!destStringStreamAgain.eof()) { + std::string lineToken; + std::getline(destStringStreamAgain, lineToken); + targetStringStream << "R\"XXX(" << lineToken << ")XXX\"\"\\n\"\n"; + } + targetStringStream << ";\n" << std::endl << std::endl; + /* targetStringStream << "const char " << targetName << "[] = R\"SCRIBE("; targetStringStream << destStringStream.str(); targetStringStream << "\n)SCRIBE\";\n\n"; + */ targetStringStream << "#endif" << std::endl; } else { targetStringStream << destStringStream.str();