Merge remote-tracking branch 'refs/remotes/origin/master' into vulkan

Former-commit-id: 12d5722252889558981b1e0b7e4a4538f6884e75 [formerly d4af159fa65c936f375e9e145bacba8ac38fdaa4] [formerly fee7f096c0bd0fb40fc03d663d74f2e847d06156 [formerly 6463645a926ad288de74646a470c3c4b7f8482c8]]
Former-commit-id: ad1e056ead3806ea657842b21d2a19d488ab52e1 [formerly 904fb40602ee4e6d936da58bbbca27acf6f89d82]
Former-commit-id: 7fe9d74b7100cf561c6cdd7445721e686da87f23
This commit is contained in:
Lynix
2016-08-16 13:02:07 +02:00
50 changed files with 653 additions and 140 deletions

View File

@@ -47,5 +47,7 @@ namespace Nz
if (line != 0 && file && function)
stream << " (" << file << ':' << line << ": " << function << ')';
Write(stream);
}
}

View File

@@ -23,7 +23,7 @@ namespace Nz
m_uniformUpdated(false),
m_brightLuminance(0.8f),
m_brightMiddleGrey(0.5f),
m_brightThreshold(0.8f),
m_brightThreshold(0.4f),
m_blurPassCount(5)
{
m_bilinearSampler.SetAnisotropyLevel(1);

View File

@@ -232,7 +232,7 @@ namespace Nz
unsigned int width = dimensions.x;
unsigned int height = dimensions.y;
m_depthStencilBuffer->Create(PixelFormatType_Depth24Stencil8, width, height);
m_depthStencilTexture->Create(ImageType_2D, PixelFormatType_Depth24Stencil8, width, height);
m_GBuffer[0]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); // Texture 0 : Diffuse Color + Specular
m_GBuffer[1]->Create(ImageType_2D, PixelFormatType_RG16F, width, height); // Texture 1 : Encoded normal
@@ -246,7 +246,7 @@ namespace Nz
// Texture 3 : Emission map ?
m_GBufferRTT->AttachBuffer(AttachmentPoint_DepthStencil, 0, m_depthStencilBuffer);
m_GBufferRTT->AttachTexture(AttachmentPoint_DepthStencil, 0, m_depthStencilTexture);
m_GBufferRTT->Unlock();
@@ -258,7 +258,7 @@ namespace Nz
m_workRTT->AttachTexture(AttachmentPoint_Color, i, m_workTextures[i]);
}
m_workRTT->AttachBuffer(AttachmentPoint_DepthStencil, 0, m_depthStencilBuffer);
m_workRTT->AttachTexture(AttachmentPoint_DepthStencil, 0, m_depthStencilTexture);
m_workRTT->Unlock();

View File

@@ -114,6 +114,9 @@ namespace Nz
Renderer::SetTexture(2, m_GBuffer[2]);
Renderer::SetTextureSampler(2, m_pointSampler);
Renderer::SetTexture(3, m_depthStencilTexture);
Renderer::SetTextureSampler(3, m_pointSampler);
Renderer::SetClearColor(Color::Black);
Renderer::Clear(RendererBuffer_Color);

View File

@@ -48,7 +48,7 @@ namespace Nz
m_deferredTechnique = technique;
m_renderQueue = static_cast<DeferredRenderQueue*>(technique->GetRenderQueue());
m_depthStencilBuffer = technique->GetDepthStencilBuffer();
m_depthStencilTexture = technique->GetDepthStencilTexture();
m_GBufferRTT = technique->GetGBufferRTT();
for (unsigned int i = 0; i < 3; ++i)

View File

@@ -239,6 +239,8 @@ namespace Nz
std::vector<Matrix4f>& instances = it2->second.instances;
instances.push_back(transformMatrix);
materialEntry.maxInstanceCount = std::max(materialEntry.maxInstanceCount, instances.size());
}
}

View File

@@ -136,7 +136,7 @@ namespace Nz
m_renderQueue(static_cast<ForwardRenderQueue*>(m_forwardTechnique.GetRenderQueue())),
m_GBufferSize(0U)
{
m_depthStencilBuffer = RenderBuffer::New();
m_depthStencilTexture = Texture::New();
for (unsigned int i = 0; i < 2; ++i)
m_workTextures[i] = Texture::New();
@@ -305,9 +305,9 @@ namespace Nz
* \return Pointer to the rendering buffer
*/
RenderBuffer* DeferredRenderTechnique::GetDepthStencilBuffer() const
Texture* DeferredRenderTechnique::GetDepthStencilTexture() const
{
return m_depthStencilBuffer;
return m_depthStencilTexture;
}
/*!
@@ -652,6 +652,7 @@ namespace Nz
shader->SendInteger(shader->GetUniformLocation("GBuffer0"), 0);
shader->SendInteger(shader->GetUniformLocation("GBuffer1"), 1);
shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2);
shader->SendInteger(shader->GetUniformLocation("DepthBuffer"), 3);
shader = RegisterDeferredShader("DeferredPointSpotLight", r_fragmentSource_PointSpotLight, sizeof(r_fragmentSource_PointSpotLight), basicVertexStage, &error);
@@ -664,6 +665,7 @@ namespace Nz
shader->SendInteger(shader->GetUniformLocation("GBuffer0"), 0);
shader->SendInteger(shader->GetUniformLocation("GBuffer1"), 1);
shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2);
shader->SendInteger(shader->GetUniformLocation("DepthBuffer"), 3);
// Shaders optionnels (S'ils ne sont pas présents, le rendu minimal sera quand même assuré)

View File

@@ -49,8 +49,8 @@ namespace Nz
*/
MaterialPipelineRef MaterialPipeline::GetPipeline(const MaterialPipelineInfo& pipelineInfo)
{
auto it = s_pipelineCache.lower_bound(pipelineInfo);
if (it == s_pipelineCache.end() || it->first != pipelineInfo)
auto it = s_pipelineCache.find(pipelineInfo);
if (it == s_pipelineCache.end())
it = s_pipelineCache.insert(it, PipelineCache::value_type(pipelineInfo, New(pipelineInfo)));
return it->second;
@@ -58,6 +58,8 @@ namespace Nz
void MaterialPipeline::GenerateRenderPipeline(UInt32 flags) const
{
NazaraAssert(m_pipelineInfo.uberShader, "Material pipeline has no uber shader");
ParameterList list;
list.SetParameter("ALPHA_MAPPING", m_pipelineInfo.hasAlphaMap);
list.SetParameter("ALPHA_TEST", m_pipelineInfo.alphaTest);
@@ -136,6 +138,7 @@ namespace Nz
// Once the base shaders are registered, we can now set some default materials
MaterialPipelineInfo pipelineInfo;
pipelineInfo.uberShader = UberShaderLibrary::Get("Basic");
// Basic 2D - No depth write/face culling
pipelineInfo.depthWrite = false;
@@ -144,7 +147,7 @@ namespace Nz
MaterialPipelineLibrary::Register("Basic2D", GetPipeline(pipelineInfo));
// Translucent 2D - Alpha blending with no depth write/face culling
pipelineInfo.blending = false;
pipelineInfo.blending = true;
pipelineInfo.depthWrite = false;
pipelineInfo.faceCulling = false;
pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha;
@@ -152,6 +155,16 @@ namespace Nz
MaterialPipelineLibrary::Register("Translucent2D", GetPipeline(pipelineInfo));
// Translucent 3D - Alpha blending with depth buffer and no depth write/face culling
pipelineInfo.blending = true;
pipelineInfo.depthBuffer = true;
pipelineInfo.depthWrite = false;
pipelineInfo.faceCulling = false;
pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha;
pipelineInfo.srcBlend = BlendFunc_SrcAlpha;
MaterialPipelineLibrary::Register("Translucent3D", GetPipeline(pipelineInfo));
return true;
}

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionController.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
/*!
* \ingroup graphics
* \class Nz::ParticleFunctionController
* \brief Helper class used to provide a function as a particle controller without going in the process of making a new class
*/
/*!
* \brief Calls the controller function
*
* \param group Particle group responsible of the particles
* \param mapper Particle mapper, allowing access to the particle data
* \param startId The first ID of the particle to update (inclusive)
* \param endId The last ID of the particle to update (inclusive)
* \param elapsedTime Elapsed time in seconds since the last update
*/
void ParticleFunctionController::Apply(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime)
{
m_controller(group, mapper, startId, endId, elapsedTime);
}
}

View File

@@ -0,0 +1,28 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionGenerator.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
/*!
* \ingroup graphics
* \class Nz::ParticleFunctionGenerator
* \brief Helper class used to provide a function as a particle generator without going in the process of making a new class
*/
/*!
* \brief Calls the generator function
*
* \param group Particle group responsible of the particles
* \param mapper Particle mapper, allowing access to the particle data
* \param startId The first ID of the particle to update (inclusive)
* \param endId The last ID of the particle to update (inclusive)
*/
void ParticleFunctionGenerator::Generate(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId)
{
m_generator(group, mapper, startId, endId);
}
}

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionRenderer.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
/*!
* \ingroup graphics
* \class Nz::ParticleFunctionRenderer
* \brief Helper class used to provide a function as a particle renderer without going in the process of making a new class
*/
/*!
* \brief Calls the renderer function
*
* \param group Particle group responsible of the particles
* \param mapper Particle mapper, allowing constant access to the particle data
* \param startId The first ID of the particle to update (inclusive)
* \param endId The last ID of the particle to update (inclusive)
* \param renderQueue The concerned render queue that will receive drawable informations
*/
void ParticleFunctionRenderer::Render(const ParticleGroup& group, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue)
{
m_renderer(group, mapper, startId, endId, renderQueue);
}
}

View File

@@ -11,17 +11,12 @@ uniform vec4 LightDirection;
uniform sampler2D GBuffer0;
uniform sampler2D GBuffer1;
uniform sampler2D GBuffer2;
uniform sampler2D DepthBuffer;
uniform mat4 InvViewProjMatrix;
uniform vec2 InvTargetSize;
uniform vec4 SceneAmbient;
float ColorToFloat(vec3 color)
{
const vec3 byte_to_float = vec3(1.0, 1.0/256, 1.0/(256*256));
return dot(color, byte_to_float);
}
#define kPI 3.1415926536
vec3 DecodeNormal(in vec4 encodedNormal)
@@ -44,7 +39,7 @@ void main()
vec3 diffuseColor = gVec0.xyz;
vec3 normal = DecodeNormal(gVec1);
float specularMultiplier = gVec0.w;
float depth = ColorToFloat(gVec2.xyz);
float depth = textureLod(DepthBuffer, texCoord, 0.0).r;
float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5);
vec3 lightDir = -LightDirection.xyz;

File diff suppressed because one or more lines are too long

View File

@@ -19,6 +19,7 @@ uniform vec2 LightParameters3;
uniform sampler2D GBuffer0;
uniform sampler2D GBuffer1;
uniform sampler2D GBuffer2;
uniform sampler2D DepthBuffer;
uniform mat4 InvViewProjMatrix;
uniform vec2 InvTargetSize;
@@ -57,7 +58,7 @@ void main()
vec3 diffuseColor = gVec0.xyz;
vec3 normal = DecodeNormal(gVec1);
float specularMultiplier = gVec0.w;
float depth = ColorToFloat(gVec2.xyz);
float depth = textureLod(DepthBuffer, texCoord, 0.0).r;
float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5);
vec3 viewSpace = vec3(texCoord*2.0 - 1.0, depth*2.0 - 1.0);

File diff suppressed because one or more lines are too long

View File

@@ -2,6 +2,13 @@
layout(early_fragment_tests) in;
#endif
// HACK UNTIL PROPER FIX
#if GLSL_VERSION < 400
#undef SHADOW_MAPPING
#define SHADOW_MAPPING 0
#endif
// HACK
#define LIGHT_DIRECTIONAL 0
#define LIGHT_POINT 1
#define LIGHT_SPOT 2
@@ -61,21 +68,6 @@ uniform vec4 SceneAmbient;
uniform sampler2D TextureOverlay;
/********************Fonctions********************/
vec3 FloatToColor(float f)
{
vec3 color;
f *= 256.0;
color.x = floor(f);
f = (f - color.x) * 256.0;
color.y = floor(f);
color.z = f - color.y;
color.xy *= 0.00390625; // *= 1.0/256
return color;
}
#define kPI 3.1415926536
@@ -177,7 +169,7 @@ void main()
*/
RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11)));
RenderTarget1 = vec4(EncodeNormal(normal));
RenderTarget2 = vec4(FloatToColor(gl_FragCoord.z), (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
RenderTarget2 = vec4(0.0, 0.0, 0.0, (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
#else // FLAG_DEFERRED
#if ALPHA_MAPPING
diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r;

File diff suppressed because one or more lines are too long

View File

@@ -588,7 +588,7 @@ namespace Nz
std::memcpy(&m_impl->colorTargets[0], targets, targetCount*sizeof(UInt8));
m_impl->userDefinedTargets = true;
InvalidateDrawBuffers();
InvalidateTargets();
}
void RenderTexture::SetColorTargets(const std::initializer_list<UInt8>& targets) const
@@ -614,7 +614,7 @@ namespace Nz
*ptr++ = index;
m_impl->userDefinedTargets = true;
InvalidateDrawBuffers();
InvalidateTargets();
}
void RenderTexture::Unlock() const

View File

@@ -31,6 +31,7 @@ namespace Nz
String matName, meshName;
matName = meshName = "default";
m_errorCount = 0;
m_keepLastLine = false;
m_lineCount = 0;
m_meshes.clear();
@@ -299,7 +300,7 @@ namespace Nz
m_positions.push_back(vertex);
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else if (!UnrecognizedLine())
false;
return false;
#endif
}
else if (word == "vn")
@@ -310,7 +311,7 @@ namespace Nz
m_normals.push_back(normal);
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else if (!UnrecognizedLine())
false;
return false;
#endif
}
else if (word == "vt")
@@ -321,12 +322,12 @@ namespace Nz
m_texCoords.push_back(uvw);
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else if (!UnrecognizedLine())
false;
return false;
#endif
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else if (!UnrecognizedLine())
false;
return false;
#endif
break;