Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hover highlight outline #2842

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public override void Configure(CommandBuffer cmd, RenderTextureDescriptor camera

public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
Debug.Log($"ALE - m_HighLightRenderers: {m_HighLightRenderers.Count}");
if (m_HighLightRenderers is not { Count: > 0 })
return;

Expand Down Expand Up @@ -137,6 +138,7 @@ private void ExecuteCommand(ScriptableRenderContext context, RenderingData rende
materialToUse.SetColor(highlightColour, !clear ? settings.Color : Color.clear);
materialToUse.SetFloat(outlineWidth, !clear ? settings.Width : 0);
materialToUse.SetVector(highlightObjectOffset, Vector3.zero);
commandBuffer.Clear();
commandBuffer.DrawRenderer(renderer, materialToUse, 0, 0);
}
}
Expand Down
161 changes: 86 additions & 75 deletions Explorer/Assets/DCL/Rendering/Highlight/HighlightRendererFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ internal class HighlightRendererFeature_Settings
[SerializeField] internal float DepthSensitivity = 0.05f;
[SerializeField] internal float NormalsSensitivity = 1.0f;
[SerializeField] internal float ColorSensitivity = 0.5f;
[SerializeField] internal Color OutlineColor = new (1.0f, 1.0f, 1.0f, 0.5f);
//[SerializeField] internal Color OutlineColor = new (1.0f, 1.0f, 1.0f, 0.5f);
}

public partial class HighlightRendererFeature : ScriptableRendererFeature
public partial class HighlightRendererFeature //: ScriptableRendererFeature
{
private const string k_ShaderName_HighlightInput = "DCL/HighlightInput_Override";
private const string k_ShaderName_HighlightInputBlur = "DCL/HighlightInput_Blur";
Expand Down Expand Up @@ -83,26 +83,26 @@ public override void SetupRenderPasses(ScriptableRenderer _renderer, in Renderin
{
// Highlight Input - Override Material & Shader, Colour & Depth Render Targets and pass setups
{
if (highlightInputMaterial == null)
if (!highlightInputMaterial)
{
m_ShaderHighlightInput = Shader.Find(k_ShaderName_HighlightInput);

if (m_ShaderHighlightInput == null)
if (!m_ShaderHighlightInput)
{
ReportHub.LogError(m_ReportData, "m_ShaderHighlightInput not found.");
return;
}

highlightInputMaterial = CoreUtils.CreateEngineMaterial(m_ShaderHighlightInput);

if (highlightInputMaterial == null)
if (!highlightInputMaterial)
{
ReportHub.LogError(m_ReportData, "highlightInputMaterial not found.");
return;
}
}

if (highlightInputBlurMaterial == null)
if (!highlightInputBlurMaterial)
{
m_ShaderHighlightInputBlur = Shader.Find(k_ShaderName_HighlightInputBlur);

Expand All @@ -114,7 +114,7 @@ public override void SetupRenderPasses(ScriptableRenderer _renderer, in Renderin

highlightInputBlurMaterial = CoreUtils.CreateEngineMaterial(m_ShaderHighlightInputBlur);

if (highlightInputBlurMaterial == null)
if (!highlightInputBlurMaterial)
{
ReportHub.LogError(m_ReportData, "highlightInputBlurMaterial not found.");
return;
Expand All @@ -123,81 +123,90 @@ public override void SetupRenderPasses(ScriptableRenderer _renderer, in Renderin

// Highlight - Colour Texture
{
var desc = new RenderTextureDescriptor();
desc.autoGenerateMips = false;
desc.bindMS = false;
desc.colorFormat = RenderTextureFormat.ARGB32;
desc.depthBufferBits = 0;
desc.depthStencilFormat = GraphicsFormat.None;
desc.dimension = TextureDimension.Tex2D;
desc.enableRandomWrite = false;
desc.graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm;
desc.height = _renderingData.cameraData.cameraTargetDescriptor.height;
desc.memoryless = RenderTextureMemoryless.None;
desc.mipCount = 0;
desc.msaaSamples = 1;
desc.shadowSamplingMode = ShadowSamplingMode.None;
desc.sRGB = false;
desc.stencilFormat = GraphicsFormat.None;
desc.useDynamicScale = false;
desc.useMipMap = false;
desc.volumeDepth = 0;
desc.vrUsage = VRTextureUsage.None;
desc.width = _renderingData.cameraData.cameraTargetDescriptor.width;
var desc = new RenderTextureDescriptor
{
autoGenerateMips = false,
bindMS = false,
colorFormat = RenderTextureFormat.ARGB32,
depthBufferBits = 0,
depthStencilFormat = GraphicsFormat.None,
dimension = TextureDimension.Tex2D,
enableRandomWrite = false,
graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm,
height = _renderingData.cameraData.cameraTargetDescriptor.height,
memoryless = RenderTextureMemoryless.None,
mipCount = 0,
msaaSamples = 1,
shadowSamplingMode = ShadowSamplingMode.None,
sRGB = false,
stencilFormat = GraphicsFormat.None,
useDynamicScale = false,
useMipMap = false,
volumeDepth = 0,
vrUsage = VRTextureUsage.None,
width = _renderingData.cameraData.cameraTargetDescriptor.width,
};

highlightRTDescriptor_Colour = desc;
RenderingUtils.ReAllocateIfNeeded(ref highlightRTHandle_Colour, highlightRTDescriptor_Colour, FilterMode.Point, TextureWrapMode.Clamp, isShadowMap: false, anisoLevel: 1, mipMapBias: 0F, name: "_Highlight_ColourTexture");
}

// Highlight - Depth Texture
{
var desc = new RenderTextureDescriptor();
desc.autoGenerateMips = false;
desc.bindMS = false;
desc.colorFormat = RenderTextureFormat.Shadowmap;
desc.depthBufferBits = 32;
desc.depthStencilFormat = GraphicsFormat.D32_SFloat;
desc.dimension = TextureDimension.Tex2D;
desc.enableRandomWrite = false;
desc.graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm;
desc.height = _renderingData.cameraData.cameraTargetDescriptor.height;
desc.memoryless = RenderTextureMemoryless.None;
desc.mipCount = 0;
desc.msaaSamples = 1;
desc.shadowSamplingMode = ShadowSamplingMode.None;
desc.sRGB = false;
desc.stencilFormat = GraphicsFormat.None;
desc.useDynamicScale = false;
desc.useMipMap = false;
desc.volumeDepth = 0;
desc.vrUsage = VRTextureUsage.None;
desc.width = _renderingData.cameraData.cameraTargetDescriptor.width;
var desc = new RenderTextureDescriptor
{
autoGenerateMips = false,
bindMS = false,
colorFormat = RenderTextureFormat.Shadowmap,
depthBufferBits = 32,
depthStencilFormat = GraphicsFormat.D32_SFloat,
dimension = TextureDimension.Tex2D,
enableRandomWrite = false,
graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm,
height = _renderingData.cameraData.cameraTargetDescriptor.height,
memoryless = RenderTextureMemoryless.None,
mipCount = 0,
msaaSamples = 1,
shadowSamplingMode = ShadowSamplingMode.None,
sRGB = false,
stencilFormat = GraphicsFormat.None,
useDynamicScale = false,
useMipMap = false,
volumeDepth = 0,
vrUsage = VRTextureUsage.None,
width = _renderingData.cameraData.cameraTargetDescriptor.width,
};

highlightRTDescriptor_Depth = desc;
RenderingUtils.ReAllocateIfNeeded(ref highlightRTHandle_Depth, highlightRTDescriptor_Depth, FilterMode.Point, TextureWrapMode.Clamp, isShadowMap: false, anisoLevel: 1, mipMapBias: 0F, name: "_Highlight_DepthTexture");
}

// Highlight - Blur Texture (PING & PONG)
{
var desc = new RenderTextureDescriptor();
desc.autoGenerateMips = false;
desc.bindMS = false;
desc.colorFormat = RenderTextureFormat.ARGB32;
desc.depthBufferBits = 0;
desc.depthStencilFormat = GraphicsFormat.None;
desc.dimension = TextureDimension.Tex2D;
desc.enableRandomWrite = false;
desc.graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm;
desc.height = _renderingData.cameraData.cameraTargetDescriptor.height;
desc.memoryless = RenderTextureMemoryless.None;
desc.mipCount = 0;
desc.msaaSamples = 1;
desc.shadowSamplingMode = ShadowSamplingMode.None;
desc.sRGB = false;
desc.stencilFormat = GraphicsFormat.None;
desc.useDynamicScale = false;
desc.useMipMap = false;
desc.volumeDepth = 0;
desc.vrUsage = VRTextureUsage.None;
desc.width = _renderingData.cameraData.cameraTargetDescriptor.width;
var desc = new RenderTextureDescriptor
{
autoGenerateMips = false,
bindMS = false,
colorFormat = RenderTextureFormat.ARGB32,
depthBufferBits = 0,
depthStencilFormat = GraphicsFormat.None,
dimension = TextureDimension.Tex2D,
enableRandomWrite = false,
graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm,
height = _renderingData.cameraData.cameraTargetDescriptor.height,
memoryless = RenderTextureMemoryless.None,
mipCount = 0,
msaaSamples = 1,
shadowSamplingMode = ShadowSamplingMode.None,
sRGB = false,
stencilFormat = GraphicsFormat.None,
useDynamicScale = false,
useMipMap = false,
volumeDepth = 0,
vrUsage = VRTextureUsage.None,
width = _renderingData.cameraData.cameraTargetDescriptor.width,
};

highlightRTDescriptor_Colour_Blur = desc;
RenderingUtils.ReAllocateIfNeeded(ref highlightRTHandle_Colour_Blur_Ping, highlightRTDescriptor_Colour_Blur, FilterMode.Point, TextureWrapMode.Clamp, isShadowMap: false, anisoLevel: 1, mipMapBias: 0F, name: "_Highlight_ColourTexture_Blur_Ping");
RenderingUtils.ReAllocateIfNeeded(ref highlightRTHandle_Colour_Blur_Pong, highlightRTDescriptor_Colour_Blur, FilterMode.Point, TextureWrapMode.Clamp, isShadowMap: false, anisoLevel: 1, mipMapBias: 0F, name: "_Highlight_ColourTexture_Blur_Pong");
Expand All @@ -218,19 +227,19 @@ public override void SetupRenderPasses(ScriptableRenderer _renderer, in Renderin

// Highlight Output Material, Shader, RenderTarget and pass setups
{
if (highlightOutputMaterial == null)
if (!highlightOutputMaterial)
{
m_ShaderHighlightOutput = Shader.Find(k_ShaderName_HighlightOutput);

if (m_ShaderHighlightOutput == null)
if (!m_ShaderHighlightOutput)
{
ReportHub.LogError(m_ReportData, "m_ShaderHighlightOutput not found.");
return;
}

highlightOutputMaterial = CoreUtils.CreateEngineMaterial(m_ShaderHighlightOutput);

if (highlightOutputMaterial == null)
if (!highlightOutputMaterial)
{
ReportHub.LogError(m_ReportData, "highlightOutputMaterial not found.");
return;
Expand All @@ -244,10 +253,12 @@ public override void SetupRenderPasses(ScriptableRenderer _renderer, in Renderin
public override void AddRenderPasses(ScriptableRenderer _renderer, ref RenderingData _renderingData)
{
// Highlight Input
if (highlightInputMaterial != null && m_ShaderHighlightInput != null && highlightRTHandle_Colour != null) { _renderer.EnqueuePass(highlightInputRenderPass); }
if (highlightInputMaterial && m_ShaderHighlightInput && highlightRTHandle_Colour != null)
_renderer.EnqueuePass(highlightInputRenderPass);

// HighLight Output
if (highlightOutputMaterial != null && m_ShaderHighlightOutput != null) { _renderer.EnqueuePass(highlightOutputRenderPass); }
if (highlightOutputMaterial && m_ShaderHighlightOutput)
_renderer.EnqueuePass(highlightOutputRenderPass);
}

protected override void Dispose(bool _bDisposing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ public void ClearCastShadows() {
public const int AlphaTextureFieldNumber = 5;
private global::Decentraland.Common.TextureUnion alphaTexture_;
/// <summary>
/// default = null
/// default = null. Note that tilling and offset properties are ignored for this texture.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
Expand Down Expand Up @@ -932,7 +932,7 @@ public void ClearCastShadows() {
public const int EmissiveTextureFieldNumber = 5;
private global::Decentraland.Common.TextureUnion emissiveTexture_;
/// <summary>
/// default = null
/// default = null. Note that tilling and offset properties are ignored for this texture.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
Expand All @@ -947,7 +947,7 @@ public void ClearCastShadows() {
public const int BumpTextureFieldNumber = 6;
private global::Decentraland.Common.TextureUnion bumpTexture_;
/// <summary>
/// default = null
/// default = null. Note that tilling and offset properties are ignored for this texture.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
Expand Down
Loading