improving the forward rendering pass, removing the specular variation and making it defautl

This commit is contained in:
samcake 2018-02-08 17:59:07 -08:00
parent caacd3e5cf
commit b66da1897d
18 changed files with 78 additions and 209 deletions

View file

@ -64,6 +64,7 @@ vec3 colorToLinearRGB(vec3 srgb) {
void main(void) { void main(void) {
outFragColor.a = 1.0; outFragColor.a = 1.0;
outFragColor.rgb = colorToLinearRGB(texture(colorMap, varTexCoord0).rgb); outFragColor.rgb = colorToLinearRGB(texture(colorMap, varTexCoord0).rgb);
// outFragColor.rgb = texture(colorMap, varTexCoord0).rgb;
} }
)SCRIBE"; )SCRIBE";

View file

@ -139,8 +139,9 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
// color = computeHazeColorKeyLightAttenuation(color, lightDirection, position); // color = computeHazeColorKeyLightAttenuation(color, lightDirection, position);
// } // }
return normal; // return normal;
// return color; // return pow(color, vec3(1.0/2.2));
return color;
} }
<@endfunc@> <@endfunc@>
@ -228,7 +229,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
color += directionalSpecular / opacity; color += directionalSpecular / opacity;
// Haze // Haze
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { /* if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 colorV4 = computeHazeColor( vec4 colorV4 = computeHazeColor(
vec4(color, 1.0), // fragment original color vec4(color, 1.0), // fragment original color
position, // fragment position in eye coordinates position, // fragment position in eye coordinates
@ -238,7 +239,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
); );
color = colorV4.rgb; color = colorV4.rgb;
} }*/
return color; return color;
} }

View file

@ -311,4 +311,14 @@ void evalFragShadingGloss(out vec3 diffuse, out vec3 specular,
specular = shading.xyz; specular = shading.xyz;
} }
<@if not GETFRESNEL0@>
<@def GETFRESNEL0@>
vec3 getFresnelF0(float metallic, vec3 metalF0) {
// Enable continuous metallness value by lerping between dielectric
// and metal fresnel F0 value based on the "metallic" parameter
return mix(vec3(0.03), metalF0, metallic);
}
<@endif@>
<@endif@> <@endif@>

View file

@ -155,7 +155,7 @@ vec3 fetchLightmapMap(vec2 uv) {
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent)); vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = <$fetchedNormal$>; vec3 localNormal = <$fetchedNormal$>;
<$normal$> = vec3(normalizedTangent * localNormal.x + normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z); <$normal$> = vec3(normalizedTangent * localNormal.x + normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z);
<$normal$> = normalizedNormal; // <$normal$> = fetchedNormal;
} }
<@endfunc@> <@endfunc@>

View file

@ -104,9 +104,9 @@ ShapeKey MeshPartPayload::getShapeKey() const {
if (drawMaterialKey.isNormalMap()) { if (drawMaterialKey.isNormalMap()) {
builder.withTangents(); builder.withTangents();
} }
if (drawMaterialKey.isMetallicMap()) { /* if (drawMaterialKey.isMetallicMap()) {
builder.withSpecular(); builder.withSpecular();
} }*/
if (drawMaterialKey.isLightmapMap()) { if (drawMaterialKey.isLightmapMap()) {
builder.withLightmap(); builder.withLightmap();
} }
@ -446,14 +446,13 @@ void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, bool isWireframe
bool isTranslucent = drawMaterialKey.isTranslucent(); bool isTranslucent = drawMaterialKey.isTranslucent();
bool hasTangents = drawMaterialKey.isNormalMap() && _hasTangents; bool hasTangents = drawMaterialKey.isNormalMap() && _hasTangents;
bool hasSpecular = drawMaterialKey.isMetallicMap();
bool hasLightmap = drawMaterialKey.isLightmapMap(); bool hasLightmap = drawMaterialKey.isLightmapMap();
bool isUnlit = drawMaterialKey.isUnlit(); bool isUnlit = drawMaterialKey.isUnlit();
bool isSkinned = _isSkinned; bool isSkinned = _isSkinned;
if (isWireframe) { if (isWireframe) {
isTranslucent = hasTangents = hasSpecular = hasLightmap = isSkinned = false; isTranslucent = hasTangents = hasLightmap = isSkinned = false;
} }
ShapeKey::Builder builder; ShapeKey::Builder builder;
@ -465,9 +464,6 @@ void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, bool isWireframe
if (hasTangents) { if (hasTangents) {
builder.withTangents(); builder.withTangents();
} }
if (hasSpecular) {
builder.withSpecular();
}
if (hasLightmap) { if (hasLightmap) {
builder.withLightmap(); builder.withLightmap();
} }

View file

@ -19,6 +19,8 @@
#include <gpu/Texture.h> #include <gpu/Texture.h>
#include <gpu/StandardShaderLib.h> #include <gpu/StandardShaderLib.h>
#include <render/ShapePipeline.h>
#include "StencilMaskPass.h" #include "StencilMaskPass.h"
#include "ZoneRenderer.h" #include "ZoneRenderer.h"
#include "FadeEffect.h" #include "FadeEffect.h"
@ -56,6 +58,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
fadeEffect->build(task, opaques); fadeEffect->build(task, opaques);
// Prepare objects shared by several jobs // Prepare objects shared by several jobs
const auto deferredFrameTransform = task.addJob<GenerateDeferredFrameTransform>("DeferredFrameTransform");
const auto lightingModel = task.addJob<MakeLightingModel>("LightingModel"); const auto lightingModel = task.addJob<MakeLightingModel>("LightingModel");
// Filter zones from the general metas bucket // Filter zones from the general metas bucket
@ -87,6 +90,8 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
task.addJob<DrawBounds>("DrawTransparentBounds", transparents); task.addJob<DrawBounds>("DrawTransparentBounds", transparents);
task.addJob<DrawBounds>("DrawZones", zones); task.addJob<DrawBounds>("DrawZones", zones);
task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform);
} }
// Layered Overlays // Layered Overlays
@ -136,34 +141,6 @@ void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::Fra
framebuffer = _framebuffer; framebuffer = _framebuffer;
} }
enum ForwardShader_MapSlot {
DEFERRED_BUFFER_COLOR_UNIT = 0,
DEFERRED_BUFFER_NORMAL_UNIT = 1,
DEFERRED_BUFFER_EMISSIVE_UNIT = 2,
DEFERRED_BUFFER_DEPTH_UNIT = 3,
DEFERRED_BUFFER_OBSCURANCE_UNIT = 4,
SHADOW_MAP_UNIT = 5,
SKYBOX_MAP_UNIT = SHADOW_MAP_UNIT + 4,
DEFERRED_BUFFER_LINEAR_DEPTH_UNIT,
DEFERRED_BUFFER_CURVATURE_UNIT,
DEFERRED_BUFFER_DIFFUSED_CURVATURE_UNIT,
SCATTERING_LUT_UNIT,
SCATTERING_SPECULAR_UNIT,
};
enum ForwardShader_BufferSlot {
DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT = 0,
CAMERA_CORRECTION_BUFFER_SLOT,
SCATTERING_PARAMETERS_BUFFER_SLOT,
LIGHTING_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::LIGHTING_MODEL,
LIGHT_GPU_SLOT = render::ShapePipeline::Slot::LIGHT,
LIGHT_AMBIENT_SLOT = render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER,
HAZE_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::HAZE_MODEL,
LIGHT_INDEX_GPU_SLOT,
LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT,
LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT,
LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
};
void PrepareForward::run(const RenderContextPointer& renderContext, const Inputs& inputs) { void PrepareForward::run(const RenderContextPointer& renderContext, const Inputs& inputs) {
RenderArgs* args = renderContext->args; RenderArgs* args = renderContext->args;
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
@ -181,18 +158,14 @@ void PrepareForward::run(const RenderContextPointer& renderContext, const Inputs
} }
if (keySunLight) { if (keySunLight) {
if (LIGHT_GPU_SLOT >= 0) { batch.setUniformBuffer(render::ShapePipeline::Slot::KEY_LIGHT, keySunLight->getLightSchemaBuffer());
batch.setUniformBuffer(LIGHT_GPU_SLOT, keySunLight->getLightSchemaBuffer());
}
} }
if (keyAmbiLight) { if (keyAmbiLight) {
if (LIGHT_AMBIENT_SLOT >= 0) { batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER, keyAmbiLight->getAmbientSchemaBuffer());
batch.setUniformBuffer(LIGHT_AMBIENT_SLOT, keyAmbiLight->getAmbientSchemaBuffer());
}
if (keyAmbiLight->getAmbientMap() && (SKYBOX_MAP_UNIT >= 0)) { if (keyAmbiLight->getAmbientMap()) {
batch.setResourceTexture(SKYBOX_MAP_UNIT, keyAmbiLight->getAmbientMap()); batch.setResourceTexture(render::ShapePipeline::Slot::LIGHT_AMBIENT, keyAmbiLight->getAmbientMap());
} }
} }
}); });

View file

@ -216,28 +216,20 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
auto simpleUnlitPixel = simple_textured_unlit_frag::getShader(); auto simpleUnlitPixel = simple_textured_unlit_frag::getShader();
auto simpleTranslucentPixel = simple_transparent_textured_frag::getShader(); auto simpleTranslucentPixel = simple_transparent_textured_frag::getShader();
auto simpleTranslucentUnlitPixel = simple_transparent_textured_unlit_frag::getShader(); auto simpleTranslucentUnlitPixel = simple_transparent_textured_unlit_frag::getShader();
auto modelPixel = model_frag::getShader(); auto modelPixel = model_specular_map_frag::getShader(); //model_frag::getShader();
auto modelUnlitPixel = model_unlit_frag::getShader(); auto modelUnlitPixel = model_unlit_frag::getShader();
auto modelNormalMapPixel = model_normal_map_frag::getShader(); auto modelNormalMapPixel = model_normal_specular_map_frag::getShader(); //model_normal_map_frag::getShader();
auto modelSpecularMapPixel = model_specular_map_frag::getShader();
auto modelNormalSpecularMapPixel = model_normal_specular_map_frag::getShader();
auto modelTranslucentPixel = model_translucent_frag::getShader(); auto modelTranslucentPixel = model_translucent_frag::getShader();
auto modelTranslucentUnlitPixel = model_translucent_unlit_frag::getShader(); auto modelTranslucentUnlitPixel = model_translucent_unlit_frag::getShader();
auto modelShadowPixel = model_shadow_frag::getShader(); auto modelShadowPixel = model_shadow_frag::getShader();
auto modelLightmapPixel = model_lightmap_frag::getShader(); auto modelLightmapPixel = model_lightmap_specular_map_frag::getShader(); // model_lightmap_frag::getShader();
auto modelLightmapNormalMapPixel = model_lightmap_normal_map_frag::getShader(); auto modelLightmapNormalMapPixel = model_lightmap_normal_specular_map_frag::getShader(); //model_lightmap_normal_map_frag::getShader();
auto modelLightmapSpecularMapPixel = model_lightmap_specular_map_frag::getShader(); auto modelLightmapFadePixel = model_lightmap_specular_map_fade_frag::getShader(); //model_lightmap_fade_frag::getShader();
auto modelLightmapNormalSpecularMapPixel = model_lightmap_normal_specular_map_frag::getShader(); auto modelLightmapNormalMapFadePixel = model_lightmap_normal_specular_map_fade_frag::getShader(); //model_lightmap_normal_map_fade_frag::getShader();
auto modelLightmapFadePixel = model_lightmap_fade_frag::getShader();
auto modelLightmapNormalMapFadePixel = model_lightmap_normal_map_fade_frag::getShader();
auto modelLightmapSpecularMapFadePixel = model_lightmap_specular_map_fade_frag::getShader();
auto modelLightmapNormalSpecularMapFadePixel = model_lightmap_normal_specular_map_fade_frag::getShader();
auto modelFadePixel = model_fade_frag::getShader(); auto modelFadePixel = model_specular_map_fade_frag::getShader(); //model_fade_frag::getShader();
auto modelUnlitFadePixel = model_unlit_fade_frag::getShader(); auto modelUnlitFadePixel = model_unlit_fade_frag::getShader();
auto modelNormalMapFadePixel = model_normal_map_fade_frag::getShader(); auto modelNormalMapFadePixel = model_normal_specular_map_fade_frag::getShader(); //model_normal_map_fade_frag::getShader();
auto modelSpecularMapFadePixel = model_specular_map_fade_frag::getShader();
auto modelNormalSpecularMapFadePixel = model_normal_specular_map_fade_frag::getShader();
auto modelShadowFadePixel = model_shadow_fade_frag::getShader(); auto modelShadowFadePixel = model_shadow_fade_frag::getShader();
auto modelTranslucentFadePixel = model_translucent_fade_frag::getShader(); auto modelTranslucentFadePixel = model_translucent_fade_frag::getShader();
auto modelTranslucentUnlitFadePixel = model_translucent_unlit_fade_frag::getShader(); auto modelTranslucentUnlitFadePixel = model_translucent_unlit_fade_frag::getShader();
@ -265,12 +257,7 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withTangents(), Key::Builder().withMaterial().withTangents(),
modelNormalMapVertex, modelNormalMapPixel, nullptr, nullptr); modelNormalMapVertex, modelNormalMapPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withSpecular(),
modelVertex, modelSpecularMapPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withTangents().withSpecular(),
modelNormalMapVertex, modelNormalSpecularMapPixel, nullptr, nullptr);
// Same thing but with Fade on // Same thing but with Fade on
addPipeline( addPipeline(
Key::Builder().withMaterial().withFade(), Key::Builder().withMaterial().withFade(),
@ -287,12 +274,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withTangents().withFade(), Key::Builder().withMaterial().withTangents().withFade(),
modelNormalMapFadeVertex, modelNormalMapFadePixel, batchSetter, itemSetter); modelNormalMapFadeVertex, modelNormalMapFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withSpecular().withFade(),
modelFadeVertex, modelSpecularMapFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withTangents().withSpecular().withFade(),
modelNormalMapFadeVertex, modelNormalSpecularMapFadePixel, batchSetter, itemSetter);
// Translucents // Translucents
addPipeline( addPipeline(
@ -310,12 +291,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withTranslucent().withTangents(), Key::Builder().withMaterial().withTranslucent().withTangents(),
modelTranslucentVertex, modelTranslucentPixel, nullptr, nullptr); modelTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withTranslucent().withSpecular(),
modelTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withTranslucent().withTangents().withSpecular(),
modelTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
addPipeline( addPipeline(
// FIXME: Ignore lightmap for translucents meshpart // FIXME: Ignore lightmap for translucents meshpart
Key::Builder().withMaterial().withTranslucent().withLightmap(), Key::Builder().withMaterial().withTranslucent().withLightmap(),
@ -336,12 +311,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withTranslucent().withTangents().withFade(), Key::Builder().withMaterial().withTranslucent().withTangents().withFade(),
modelNormalMapFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter); modelNormalMapFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withTranslucent().withSpecular().withFade(),
modelFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withTranslucent().withTangents().withSpecular().withFade(),
modelNormalMapFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
addPipeline( addPipeline(
// FIXME: Ignore lightmap for translucents meshpart // FIXME: Ignore lightmap for translucents meshpart
Key::Builder().withMaterial().withTranslucent().withLightmap().withFade(), Key::Builder().withMaterial().withTranslucent().withLightmap().withFade(),
@ -354,12 +323,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withLightmap().withTangents(), Key::Builder().withMaterial().withLightmap().withTangents(),
modelLightmapNormalMapVertex, modelLightmapNormalMapPixel, nullptr, nullptr); modelLightmapNormalMapVertex, modelLightmapNormalMapPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withLightmap().withSpecular(),
modelLightmapVertex, modelLightmapSpecularMapPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withLightmap().withTangents().withSpecular(),
modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel, nullptr, nullptr);
// Same thing but with Fade on // Same thing but with Fade on
addPipeline( addPipeline(
Key::Builder().withMaterial().withLightmap().withFade(), Key::Builder().withMaterial().withLightmap().withFade(),
@ -367,12 +330,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withLightmap().withTangents().withFade(), Key::Builder().withMaterial().withLightmap().withTangents().withFade(),
modelLightmapNormalMapFadeVertex, modelLightmapNormalMapFadePixel, batchSetter, itemSetter); modelLightmapNormalMapFadeVertex, modelLightmapNormalMapFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withLightmap().withSpecular().withFade(),
modelLightmapFadeVertex, modelLightmapSpecularMapFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withLightmap().withTangents().withSpecular().withFade(),
modelLightmapNormalMapFadeVertex, modelLightmapNormalSpecularMapFadePixel, batchSetter, itemSetter);
// Skinned // Skinned
addPipeline( addPipeline(
@ -381,12 +338,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withSkinned().withTangents(), Key::Builder().withMaterial().withSkinned().withTangents(),
skinModelNormalMapVertex, modelNormalMapPixel, nullptr, nullptr); skinModelNormalMapVertex, modelNormalMapPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withSkinned().withSpecular(),
skinModelVertex, modelSpecularMapPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withSkinned().withTangents().withSpecular(),
skinModelNormalMapVertex, modelNormalSpecularMapPixel, nullptr, nullptr);
// Same thing but with Fade on // Same thing but with Fade on
addPipeline( addPipeline(
Key::Builder().withMaterial().withSkinned().withFade(), Key::Builder().withMaterial().withSkinned().withFade(),
@ -394,12 +345,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withSkinned().withTangents().withFade(), Key::Builder().withMaterial().withSkinned().withTangents().withFade(),
skinModelNormalMapFadeVertex, modelNormalMapFadePixel, batchSetter, itemSetter); skinModelNormalMapFadeVertex, modelNormalMapFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withSkinned().withSpecular().withFade(),
skinModelFadeVertex, modelSpecularMapFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withSkinned().withTangents().withSpecular().withFade(),
skinModelNormalMapFadeVertex, modelNormalSpecularMapFadePixel, batchSetter, itemSetter);
// Skinned and Translucent // Skinned and Translucent
addPipeline( addPipeline(
@ -408,12 +353,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(), Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(),
skinModelNormalMapTranslucentVertex, modelTranslucentPixel, nullptr, nullptr); skinModelNormalMapTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withSkinned().withTranslucent().withSpecular(),
skinModelTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withSpecular(),
skinModelNormalMapTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
// Same thing but with Fade on // Same thing but with Fade on
addPipeline( addPipeline(
Key::Builder().withMaterial().withSkinned().withTranslucent().withFade(), Key::Builder().withMaterial().withSkinned().withTranslucent().withFade(),
@ -421,12 +360,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withFade(), Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withFade(),
skinModelNormalMapFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter); skinModelNormalMapFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withSkinned().withTranslucent().withSpecular().withFade(),
skinModelFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withSpecular().withFade(),
skinModelNormalMapFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
// Depth-only // Depth-only
addPipeline( addPipeline(
@ -450,15 +383,11 @@ void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::Ba
auto modelNormalMapVertex = model_normal_map_vert::getShader(); auto modelNormalMapVertex = model_normal_map_vert::getShader();
auto skinModelVertex = skin_model_vert::getShader(); auto skinModelVertex = skin_model_vert::getShader();
auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader(); auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader();
auto skinModelNormalMapFadeVertex = skin_model_normal_map_fade_vert::getShader();
// Pixel shaders // Pixel shaders
auto modelPixel = forward_model_frag::getShader(); auto modelPixel = forward_model_specular_map_frag::getShader(); //forward_model_frag::getShader();
auto modelUnlitPixel = forward_model_unlit_frag::getShader(); auto modelUnlitPixel = forward_model_unlit_frag::getShader();
auto modelNormalMapPixel = forward_model_normal_map_frag::getShader(); auto modelNormalMapPixel = forward_model_normal_specular_map_frag::getShader(); //forward_model_normal_map_frag::getShader();
auto modelSpecularMapPixel = forward_model_specular_map_frag::getShader();
auto modelNormalSpecularMapPixel = forward_model_normal_specular_map_frag::getShader();
auto modelNormalMapFadePixel = model_normal_map_fade_frag::getShader();
auto modelTranslucentPixel = forward_model_translucent_frag::getShader(); auto modelTranslucentPixel = forward_model_translucent_frag::getShader();
using Key = render::ShapeKey; using Key = render::ShapeKey;
@ -472,31 +401,24 @@ void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::Ba
// Forward pipelines need the lightBatchSetter for opaques and transparents // Forward pipelines need the lightBatchSetter for opaques and transparents
forceLightBatchSetter = true; forceLightBatchSetter = true;
// forceLightBatchSetter = false;
// Opaques // Opaques
addPipeline(Key::Builder().withMaterial(), modelVertex, modelPixel); addPipeline(Key::Builder().withMaterial(), modelVertex, modelPixel);
addPipeline(Key::Builder().withMaterial().withUnlit(), modelVertex, modelUnlitPixel); addPipeline(Key::Builder().withMaterial().withUnlit(), modelVertex, modelUnlitPixel);
addPipeline(Key::Builder().withMaterial().withTangents(), modelNormalMapVertex, modelNormalMapPixel); addPipeline(Key::Builder().withMaterial().withTangents(), modelNormalMapVertex, modelNormalMapPixel);
addPipeline(Key::Builder().withMaterial().withSpecular(), modelVertex, modelSpecularMapPixel);
addPipeline(Key::Builder().withMaterial().withTangents().withSpecular(), modelNormalMapVertex, modelNormalSpecularMapPixel);
// Skinned Opaques // Skinned Opaques
addPipeline(Key::Builder().withMaterial().withSkinned(), skinModelVertex, modelPixel); addPipeline(Key::Builder().withMaterial().withSkinned(), skinModelVertex, modelPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTangents(), skinModelNormalMapVertex, modelNormalMapPixel); addPipeline(Key::Builder().withMaterial().withSkinned().withTangents(), skinModelNormalMapVertex, modelNormalMapPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withSpecular(), skinModelVertex, modelSpecularMapPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTangents().withSpecular(), skinModelNormalMapVertex, modelNormalSpecularMapPixel);
// Translucents // Translucents
addPipeline(Key::Builder().withMaterial().withTranslucent(), modelVertex, modelTranslucentPixel); addPipeline(Key::Builder().withMaterial().withTranslucent(), modelVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withTranslucent().withTangents(), modelNormalMapVertex, modelTranslucentPixel); addPipeline(Key::Builder().withMaterial().withTranslucent().withTangents(), modelNormalMapVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withTranslucent().withSpecular(), modelVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withTranslucent().withTangents().withSpecular(), modelNormalMapVertex, modelTranslucentPixel);
// Skinned Translucents // Skinned Translucents
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent(), skinModelVertex, modelTranslucentPixel); addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent(), skinModelVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(), skinModelNormalMapVertex, modelTranslucentPixel); addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(), skinModelNormalMapVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withSpecular(), skinModelVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withSpecular(), skinModelNormalMapVertex, modelTranslucentPixel);
forceLightBatchSetter = false; forceLightBatchSetter = false;
} }

View file

@ -52,25 +52,25 @@ void ZoneRendererTask::build(JobModel& task, const Varying& input, Varying& oupu
} }
void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) { void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) {
// Grab light, background and haze stages and clear them
auto lightStage = context->_scene->getStage<LightStage>();
assert(lightStage);
lightStage->_currentFrame.clear();
auto backgroundStage = context->_scene->getStage<BackgroundStage>(); auto backgroundStage = context->_scene->getStage<BackgroundStage>();
assert(backgroundStage); assert(backgroundStage);
backgroundStage->_currentFrame.clear(); backgroundStage->_currentFrame.clear();
// Haze
auto hazeStage = context->_scene->getStage<HazeStage>(); auto hazeStage = context->_scene->getStage<HazeStage>();
assert(hazeStage); assert(hazeStage);
hazeStage->_currentFrame.clear(); hazeStage->_currentFrame.clear();
// call render in the correct order first... // call render over the zones to grab their components in the correct order first...
render::renderItems(context, inputs); render::renderItems(context, inputs);
// Finally add the default lights and background: // Finally add the default lights and background:
auto lightStage = context->_scene->getStage<LightStage>();
assert(lightStage);
lightStage->_currentFrame.pushSunLight(lightStage->getDefaultLight()); lightStage->_currentFrame.pushSunLight(lightStage->getDefaultLight());
lightStage->_currentFrame.pushAmbientLight(lightStage->getDefaultLight()); lightStage->_currentFrame.pushAmbientLight(lightStage->getDefaultLight());
backgroundStage->_currentFrame.pushBackground(0); backgroundStage->_currentFrame.pushBackground(0);
hazeStage->_currentFrame.pushHaze(0); hazeStage->_currentFrame.pushHaze(0);
} }

View file

@ -47,13 +47,7 @@ void main(void) {
albedo *= _color; albedo *= _color;
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value vec3 fresnel = getFresnelF0(metallic, albedo);
if (metallic <= 0.5) {
metallic = 0.0;
} else {
fresnel = albedo;
metallic = 1.0;
}
float roughness = getMaterialRoughness(mat); float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;

View file

@ -49,13 +49,7 @@ void main(void) {
albedo *= _color; albedo *= _color;
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value vec3 fresnel = getFresnelF0(metallic, albedo);
if (metallic <= 0.5) {
metallic = 0.0;
} else {
fresnel = albedo;
metallic = 1.0;
}
float roughness = getMaterialRoughness(mat); float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
@ -63,20 +57,19 @@ void main(void) {
vec3 emissive = getMaterialEmissive(mat); vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
vec3 fragNormal;
<$tangentToViewSpace(normalTex, _normal, _tangent, fragNormal)$>
float scattering = getMaterialScattering(mat); float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>; <$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
vec3 fragPosition = _position.xyz; vec3 fragPosition = _position.xyz;
vec3 fragNormal;
<$tangentToViewSpace(normalTex, _normal, _tangent, fragNormal)$>
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();
vec4 color = vec4(evalSkyboxGlobalColor( vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse, cam._viewInverse,
1.0, 1.0,
1.0, occlusionTex,
fragPosition, fragPosition,
fragNormal, fragNormal,
albedo, albedo,

View file

@ -12,9 +12,6 @@
// 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 ForwardBufferWrite.slh@> !>
<@include ForwardGlobalLight.slh@> <@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$> <$declareEvalSkyboxGlobalColor()$>
@ -55,29 +52,22 @@ void main(void) {
vec3 emissive = getMaterialEmissive(mat); vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
vec3 viewNormal;
<$tangentToViewSpace(normalTex, _normal, _tangent, viewNormal)$>
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value vec3 fresnel = getFresnelF0(metallic, albedo);
if (metallic <= 0.5) {
metallic = 0.0;
}
else {
fresnel = albedo;
metallic = 1.0;
}
vec3 fragPosition = _position.xyz; vec3 fragPosition = _position.xyz;
vec3 fragNormal;
<$tangentToViewSpace(normalTex, _normal, _tangent, fragNormal)$>
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();
vec4 color = vec4(evalSkyboxGlobalColor( vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse, cam._viewInverse,
1.0, 1.0,
1.0, occlusionTex,
fragPosition, fragPosition,
viewNormal, fragNormal,
albedo, albedo,
fresnel, fresnel,
metallic, metallic,

View file

@ -38,7 +38,7 @@ void main(void) {
Material mat = getMaterial(); Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat); BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$> <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
<! <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> !> <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = 1.0; float opacity = 1.0;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
@ -56,19 +56,12 @@ void main(void) {
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value vec3 fresnel = getFresnelF0(metallic, albedo);
if (metallic <= 0.5) {
metallic = 0.0;
}
else {
fresnel = albedo;
metallic = 1.0;
}
vec3 fragPosition = _position.xyz; vec3 fragPosition = _position.xyz;
vec3 fragNormal = normalize(_normal);
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();
vec3 fragNormal;
fragNormal = normalize(_normal);
vec4 color = vec4(evalSkyboxGlobalColor( vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse, cam._viewInverse,

View file

@ -50,13 +50,7 @@ void main(void) {
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value vec3 fresnel = getFresnelF0(metallic, albedo);
if (metallic <= 0.5) {
metallic = 0.0;
} else {
fresnel = albedo;
metallic = 1.0;
}
vec3 emissive = getMaterialEmissive(mat); vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;

View file

@ -16,7 +16,7 @@
<@include graphics/Material.slh@> <@include graphics/Material.slh@>
<@include MaterialTextures.slh@> <@include MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$> <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
in vec4 _position; in vec4 _position;
in vec3 _normal; in vec3 _normal;
@ -45,14 +45,18 @@ void main(void) {
vec3 emissive = getMaterialEmissive(mat); vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
float scattering = getMaterialScattering(mat); float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
packDeferredFragment( packDeferredFragment(
normalize(_normal.xyz), normalize(_normal.xyz),
opacity, opacity,
albedo, albedo,
roughness, roughness,
getMaterialMetallic(mat), metallic,
emissive, emissive,
occlusionTex, occlusionTex,
scattering); scattering);

View file

@ -17,7 +17,7 @@
<@include graphics/Material.slh@> <@include graphics/Material.slh@>
<@include MaterialTextures.slh@> <@include MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, _SCRIBE_NULL, EMISSIVE, OCCLUSION, SCATTERING)$> <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
in vec4 _position; in vec4 _position;
in vec2 _texCoord0; in vec2 _texCoord0;
@ -29,7 +29,7 @@ in vec3 _color;
void main(void) { void main(void) {
Material mat = getMaterial(); Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat); BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, scatteringTex)$> <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = 1.0; float opacity = 1.0;
@ -49,6 +49,9 @@ void main(void) {
vec3 viewNormal; vec3 viewNormal;
<$tangentToViewSpaceLOD(_position, normalTex, _normal, _tangent, viewNormal)$> <$tangentToViewSpaceLOD(_position, normalTex, _normal, _tangent, viewNormal)$>
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
float scattering = getMaterialScattering(mat); float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>; <$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
@ -57,7 +60,7 @@ void main(void) {
opacity, opacity,
albedo, albedo,
roughness, roughness,
getMaterialMetallic(mat), metallic,
emissive, emissive,
occlusionTex, occlusionTex,
scattering); scattering);

View file

@ -53,6 +53,7 @@ void main(void) {
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
float scattering = getMaterialScattering(mat); float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
packDeferredFragment( packDeferredFragment(
normalize(viewNormal.xyz), normalize(viewNormal.xyz),

View file

@ -50,6 +50,7 @@ void main(void) {
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
float scattering = getMaterialScattering(mat); float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
packDeferredFragment( packDeferredFragment(
normalize(_normal), normalize(_normal),

View file

@ -29,7 +29,6 @@ public:
TRANSLUCENT, TRANSLUCENT,
LIGHTMAP, LIGHTMAP,
TANGENTS, TANGENTS,
SPECULAR,
UNLIT, UNLIT,
SKINNED, SKINNED,
DEPTH_ONLY, DEPTH_ONLY,
@ -77,7 +76,6 @@ public:
Builder& withTranslucent() { _flags.set(TRANSLUCENT); return (*this); } Builder& withTranslucent() { _flags.set(TRANSLUCENT); return (*this); }
Builder& withLightmap() { _flags.set(LIGHTMAP); return (*this); } Builder& withLightmap() { _flags.set(LIGHTMAP); return (*this); }
Builder& withTangents() { _flags.set(TANGENTS); return (*this); } Builder& withTangents() { _flags.set(TANGENTS); return (*this); }
Builder& withSpecular() { _flags.set(SPECULAR); return (*this); }
Builder& withUnlit() { _flags.set(UNLIT); return (*this); } Builder& withUnlit() { _flags.set(UNLIT); return (*this); }
Builder& withSkinned() { _flags.set(SKINNED); return (*this); } Builder& withSkinned() { _flags.set(SKINNED); return (*this); }
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); return (*this); } Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); return (*this); }
@ -124,9 +122,6 @@ public:
Builder& withTangents() { _flags.set(TANGENTS); _mask.set(TANGENTS); return (*this); } Builder& withTangents() { _flags.set(TANGENTS); _mask.set(TANGENTS); return (*this); }
Builder& withoutTangents() { _flags.reset(TANGENTS); _mask.set(TANGENTS); return (*this); } Builder& withoutTangents() { _flags.reset(TANGENTS); _mask.set(TANGENTS); return (*this); }
Builder& withSpecular() { _flags.set(SPECULAR); _mask.set(SPECULAR); return (*this); }
Builder& withoutSpecular() { _flags.reset(SPECULAR); _mask.set(SPECULAR); return (*this); }
Builder& withUnlit() { _flags.set(UNLIT); _mask.set(UNLIT); return (*this); } Builder& withUnlit() { _flags.set(UNLIT); _mask.set(UNLIT); return (*this); }
Builder& withoutUnlit() { _flags.reset(UNLIT); _mask.set(UNLIT); return (*this); } Builder& withoutUnlit() { _flags.reset(UNLIT); _mask.set(UNLIT); return (*this); }
@ -167,7 +162,6 @@ public:
bool useMaterial() const { return _flags[MATERIAL]; } bool useMaterial() const { return _flags[MATERIAL]; }
bool hasLightmap() const { return _flags[LIGHTMAP]; } bool hasLightmap() const { return _flags[LIGHTMAP]; }
bool hasTangents() const { return _flags[TANGENTS]; } bool hasTangents() const { return _flags[TANGENTS]; }
bool hasSpecular() const { return _flags[SPECULAR]; }
bool isUnlit() const { return _flags[UNLIT]; } bool isUnlit() const { return _flags[UNLIT]; }
bool isTranslucent() const { return _flags[TRANSLUCENT]; } bool isTranslucent() const { return _flags[TRANSLUCENT]; }
bool isSkinned() const { return _flags[SKINNED]; } bool isSkinned() const { return _flags[SKINNED]; }
@ -207,7 +201,6 @@ inline QDebug operator<<(QDebug debug, const ShapeKey& key) {
<< "useMaterial:" << key.useMaterial() << "useMaterial:" << key.useMaterial()
<< "hasLightmap:" << key.hasLightmap() << "hasLightmap:" << key.hasLightmap()
<< "hasTangents:" << key.hasTangents() << "hasTangents:" << key.hasTangents()
<< "hasSpecular:" << key.hasSpecular()
<< "isUnlit:" << key.isUnlit() << "isUnlit:" << key.isUnlit()
<< "isTranslucent:" << key.isTranslucent() << "isTranslucent:" << key.isTranslucent()
<< "isSkinned:" << key.isSkinned() << "isSkinned:" << key.isSkinned()