Outline renderer can now depth test
This commit is contained in:
@@ -34,7 +34,7 @@ public:
|
|||||||
Type = None;
|
Type = None;
|
||||||
if (const auto& scene = Nuake::Engine::GetCurrentScene(); scene)
|
if (const auto& scene = Nuake::Engine::GetCurrentScene(); scene)
|
||||||
{
|
{
|
||||||
Nuake::Engine::GetCurrentScene()->m_SceneRenderer->mOutlineEntityID = 0;
|
Nuake::Engine::GetCurrentScene()->m_SceneRenderer->mOutlineEntityID = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,21 +48,21 @@ public:
|
|||||||
EditorSelection(const Ref<Nuake::File>& file)
|
EditorSelection(const Ref<Nuake::File>& file)
|
||||||
{
|
{
|
||||||
Type = EditorSelectionType::File;
|
Type = EditorSelectionType::File;
|
||||||
Nuake::Engine::GetCurrentScene()->m_SceneRenderer->mOutlineEntityID = 0;
|
Nuake::Engine::GetCurrentScene()->m_SceneRenderer->mOutlineEntityID = -1;
|
||||||
File = file;
|
File = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorSelection(const Ref<Nuake::Directory>& dir)
|
EditorSelection(const Ref<Nuake::Directory>& dir)
|
||||||
{
|
{
|
||||||
Type = EditorSelectionType::Directory;
|
Type = EditorSelectionType::Directory;
|
||||||
Nuake::Engine::GetCurrentScene()->m_SceneRenderer->mOutlineEntityID = 0;
|
Nuake::Engine::GetCurrentScene()->m_SceneRenderer->mOutlineEntityID = -1;
|
||||||
Directory = dir;
|
Directory = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorSelection(const Nuake::Resource& resource)
|
EditorSelection(const Nuake::Resource& resource)
|
||||||
{
|
{
|
||||||
Type = EditorSelectionType::Resource;
|
Type = EditorSelectionType::Resource;
|
||||||
Nuake::Engine::GetCurrentScene()->m_SceneRenderer->mOutlineEntityID = 0;
|
Nuake::Engine::GetCurrentScene()->m_SceneRenderer->mOutlineEntityID = -1;
|
||||||
Resource = resource;
|
Resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,11 +71,12 @@ namespace Nuake
|
|||||||
mTempModels.clear();
|
mTempModels.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mOutlineEntityID = 0;
|
int mOutlineEntityID = 0;
|
||||||
private:
|
private:
|
||||||
Matrix4 mProjection, mView;
|
Matrix4 mProjection, mView;
|
||||||
Vector3 mCamPos;
|
Vector3 mCamPos;
|
||||||
|
|
||||||
|
// GBuffer
|
||||||
Scope<FrameBuffer> mGBuffer;
|
Scope<FrameBuffer> mGBuffer;
|
||||||
Scope<FrameBuffer> mShadingBuffer;
|
Scope<FrameBuffer> mShadingBuffer;
|
||||||
Scope<FrameBuffer> mToneMapBuffer;
|
Scope<FrameBuffer> mToneMapBuffer;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ void main()
|
|||||||
uniform int u_EntityID;
|
uniform int u_EntityID;
|
||||||
uniform usampler2D u_EntityTexture;
|
uniform usampler2D u_EntityTexture;
|
||||||
uniform vec4 u_OutlineColor;
|
uniform vec4 u_OutlineColor;
|
||||||
|
uniform sampler2D u_Depth;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
@@ -34,7 +35,8 @@ void main()
|
|||||||
|
|
||||||
// sample middle
|
// sample middle
|
||||||
uint middleSample = texture(u_EntityTexture, uv).r;
|
uint middleSample = texture(u_EntityTexture, uv).r;
|
||||||
|
float depth = texture(u_Depth, uv).r;
|
||||||
|
|
||||||
// Correct aspect ratio
|
// Correct aspect ratio
|
||||||
vec2 aspect = 1.0 / vec2(textureSize(u_EntityTexture, 0));
|
vec2 aspect = 1.0 / vec2(textureSize(u_EntityTexture, 0));
|
||||||
|
|
||||||
@@ -44,9 +46,15 @@ void main()
|
|||||||
{
|
{
|
||||||
// Sample image in a circular pattern
|
// Sample image in a circular pattern
|
||||||
vec2 offset = vec2(sin(i), cos(i)) * aspect * radius;
|
vec2 offset = vec2(sin(i), cos(i)) * aspect * radius;
|
||||||
uint col = texture(u_EntityTexture, uv + offset).r;
|
|
||||||
|
|
||||||
if(col == target)
|
// We dont want to sample outside the viewport
|
||||||
|
vec2 sampleUv = uv + offset;
|
||||||
|
sampleUv.x = clamp(sampleUv.x, 0.0, 1.0);
|
||||||
|
sampleUv.y = clamp(sampleUv.y, 0.0, 1.0);
|
||||||
|
|
||||||
|
uint col = texture(u_EntityTexture, sampleUv).r;
|
||||||
|
float depthTarget = texture(u_Depth, sampleUv).r;
|
||||||
|
if(col == target && depthTarget < depth)
|
||||||
{
|
{
|
||||||
hasHit = 1.0f;
|
hasHit = 1.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user