Skip to content

Commit

Permalink
Fix a warning where camera's commands uses in URP
Browse files Browse the repository at this point in the history
  • Loading branch information
durswd committed Jan 13, 2025
1 parent 9d2be52 commit 33a31db
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override void Execute(ScriptableRenderContext renderContext, CommandBu
prop.colorTargetDescriptor = new UnityEngine.RenderTextureDescriptor(hdCamera.actualWidth, hdCamera.actualHeight, colorBuffer.rt.format, 0, colorBuffer.rt.mipmapCount);
prop.colorTargetDescriptor.msaaSamples = hdCamera.msaaSamples == MSAASamples.None ? 1 : 2;
prop.isRequiredToChangeViewport = true;
EffekseerSystem.Instance.renderer.Render(hdCamera.camera, LayerMask.value, prop, cmd, blitter);
EffekseerSystem.Instance.renderer.Render(hdCamera.camera, LayerMask.value, prop, cmd, true, blitter);
}

protected override void Cleanup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override void Render(PostProcessRenderContext context)
prop.canGrabDepth = true;
context.command.SetRenderTarget(context.destination, depthIdentifer);

Effekseer.EffekseerSystem.Instance.renderer.Render(context.camera, int.MaxValue, prop, context.command, standardBlitter);
Effekseer.EffekseerSystem.Instance.renderer.Render(context.camera, int.MaxValue, prop, context.command, false, standardBlitter);

context.command.ReleaseTemporaryRT(propertyId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public override void Execute(ScriptableRenderContext context, ref UnityEngine.Re

var cmd = CommandBufferPool.Get(RenderPassName);
prop.canGrabDepth = renderingData.cameraData.requiresDepthTexture;
Effekseer.EffekseerSystem.Instance.renderer.Render(renderingData.cameraData.camera, layerMask.value, prop, cmd, blitter);
Effekseer.EffekseerSystem.Instance.renderer.Render(renderingData.cameraData.camera, layerMask.value, prop, cmd, true, blitter);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
Expand Down
7 changes: 4 additions & 3 deletions Dev/Plugin/Assets/Effekseer/Scripts/EffekseerRenderPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ internal class RenderPathBase : IDisposable
public DepthRenderTexture depthTexture;
protected bool isDistortionEnabled = false;
protected bool isDepthEnabled = false;
protected bool _isScriptable = false;

/// <summary>
/// Distortion is disabled forcely because of VR
/// </summary>
protected bool isDistortionMakeDisabledForcely = false;

public virtual void Init(Camera camera, CameraEvent cameraEvent, int renderId, bool isCommandBufferFromExternal) { }
public virtual void Init(Camera camera, CameraEvent cameraEvent, int renderId, bool isCommandBufferFromExternal, bool isScriptable) { }

public virtual void ResetParameters(bool enableDistortion, bool enableDepth, RenderTargetProperty renderTargetProperty,
IEffekseerBlitter blitter, StereoRendererUtil.StereoRenderingTypes stereoRenderingType = StereoRendererUtil.StereoRenderingTypes.None)
Expand Down Expand Up @@ -150,7 +151,7 @@ public void CleanUp()
renderPaths.Clear();
}

public void UpdateRenderPath(bool disableCullingMask, Camera camera, int additionalMask, RenderTargetProperty renderTargetProperty, CommandBuffer targetCommandBuffer, IEffekseerBlitter blitter, CameraEvent cameraEvent, out T path, out int allEffectMask, out int cameraMask)
public void UpdateRenderPath(bool disableCullingMask, Camera camera, int additionalMask, RenderTargetProperty renderTargetProperty, CommandBuffer targetCommandBuffer, bool isScriptable, IEffekseerBlitter blitter, CameraEvent cameraEvent, out T path, out int allEffectMask, out int cameraMask)
{
path = null;

Expand Down Expand Up @@ -246,7 +247,7 @@ public void UpdateRenderPath(bool disableCullingMask, Camera camera, int additio
}

path = new T();
path.Init(camera, cameraEvent, nextRenderID, targetCommandBuffer != null);
path.Init(camera, cameraEvent, nextRenderID, targetCommandBuffer != null, isScriptable);
var stereoRenderingType = (camera.stereoEnabled) ? StereoRendererUtil.GetStereoRenderingType() : StereoRendererUtil.StereoRenderingTypes.None;
path.ResetParameters(EffekseerRendererUtils.IsDistortionEnabled, EffekseerRendererUtils.IsDepthEnabled, renderTargetProperty, blitter, stereoRenderingType);
renderPaths.Add(new CameraWithMask(camera, additionalMask), path);
Expand Down
2 changes: 1 addition & 1 deletion Dev/Plugin/Assets/Effekseer/Scripts/EffekseerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public interface IEffekseerRenderer

void CleanUp();

void Render(Camera camera, int additionalMask, RenderTargetProperty renderTargetProperty, CommandBuffer targetCommandBuffer, IEffekseerBlitter blitter);
void Render(Camera camera, int additionalMask, RenderTargetProperty renderTargetProperty, CommandBuffer targetCommandBuffer, bool isScriptable, IEffekseerBlitter blitter);

void OnPostRender(Camera camera);
}
Expand Down
11 changes: 6 additions & 5 deletions Dev/Plugin/Assets/Effekseer/Scripts/EffekseerRendererNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ private class RenderPath : RenderPathBase
{
Material fakeMaterial = null;

public override void Init(Camera camera, CameraEvent cameraEvent, int renderId, bool isCommandBufferFromExternal)
public override void Init(Camera camera, CameraEvent cameraEvent, int renderId, bool isCommandBufferFromExternal, bool isScriptable)
{
this.camera = camera;
this.renderId = renderId;
this.cameraEvent = cameraEvent;
this.isCommandBufferFromExternal = isCommandBufferFromExternal;
this._isScriptable = isScriptable;

var fakeShader = EffekseerDependentAssets.Instance.fakeMaterial;
#if UNITY_EDITOR
Expand Down Expand Up @@ -68,7 +69,7 @@ public override void ResetParameters(bool enableDistortion, bool enableDepth, Re
}

// register the command to a camera
if (!isCommandBufferFromExternal)
if (!isCommandBufferFromExternal && !_isScriptable)
{
this.camera.AddCommandBuffer(this.cameraEvent, this.commandBuffer);
}
Expand Down Expand Up @@ -215,16 +216,16 @@ public void Render(Camera camera)
{
if (!EffekseerSettings.Instance.renderAsPostProcessingStack)
{
Render(camera, int.MaxValue, null, null, standardBlitter);
Render(camera, int.MaxValue, null, null, false, standardBlitter);
}
}

public void Render(Camera camera, int additionalMask, RenderTargetProperty renderTargetProperty, CommandBuffer targetCommandBuffer, IEffekseerBlitter blitter)
public void Render(Camera camera, int additionalMask, RenderTargetProperty renderTargetProperty, CommandBuffer targetCommandBuffer, bool isScriptable, IEffekseerBlitter blitter)
{
RenderPath path;
int allEffectMask;
int cameraMask;
renderPathContainer.UpdateRenderPath(disableCullingMask, camera, additionalMask, renderTargetProperty, targetCommandBuffer, blitter, cameraEvent, out path, out allEffectMask, out cameraMask);
renderPathContainer.UpdateRenderPath(disableCullingMask, camera, additionalMask, renderTargetProperty, targetCommandBuffer, isScriptable, blitter, cameraEvent, out path, out allEffectMask, out cameraMask);
if (path == null)
{
return;
Expand Down
20 changes: 12 additions & 8 deletions Dev/Plugin/Assets/Effekseer/Scripts/EffekseerRendererUnity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -739,13 +739,14 @@ private class RenderPath : RenderPathBase

List<DelayEvent> _delayEvents = null;

public override void Init(Camera camera, CameraEvent cameraEvent, int renderId, bool isCommandBufferFromExternal)
public override void Init(Camera camera, CameraEvent cameraEvent, int renderId, bool isCommandBufferFromExternal, bool isScriptable)
{
this.camera = camera;
this.renderId = renderId;
this.cameraEvent = cameraEvent;
this._delayEvents = new List<DelayEvent>();
this.isCommandBufferFromExternal = isCommandBufferFromExternal;
this._isScriptable = isScriptable;
_materialProps = new MaterialPropCollection();
_modelBuffers = new ModelBufferCollection();
_customDataBuffers = new CustomDataBufferCollection();
Expand All @@ -756,16 +757,19 @@ public override void ResetParameters(bool enableDistortion, bool enableDepth, Re
isDistortionEnabled = enableDistortion;
isDepthEnabled = enableDepth;

RendererUtils.SetupBackgroundBuffer(ref renderTexture, isDistortionEnabled, camera, renderTargetProperty);
RendererUtils.SetupDepthBuffer(ref depthTexture, isDepthEnabled, camera, renderTargetProperty);

// Create a command buffer that is effekseer renderer
if (!isCommandBufferFromExternal)
{
this.commandBuffer = new CommandBuffer();
this.commandBuffer.name = "Effekseer Rendering";
}

// register the command to a camera
RendererUtils.SetupBackgroundBuffer(ref renderTexture, isDistortionEnabled, camera, renderTargetProperty);
RendererUtils.SetupDepthBuffer(ref depthTexture, isDepthEnabled, camera, renderTargetProperty);

// register the command to a camera
if (!isCommandBufferFromExternal && !_isScriptable)
{
this.camera.AddCommandBuffer(this.cameraEvent, this.commandBuffer);
}

Expand Down Expand Up @@ -940,16 +944,16 @@ public void Render(Camera camera)
{
if (!EffekseerSettings.Instance.renderAsPostProcessingStack)
{
Render(camera, int.MaxValue, null, null, standardBlitter);
Render(camera, int.MaxValue, null, null, false, standardBlitter);
}
}

public void Render(Camera camera, int additionalMask, RenderTargetProperty renderTargetProperty, CommandBuffer targetCommandBuffer, IEffekseerBlitter blitter)
public void Render(Camera camera, int additionalMask, RenderTargetProperty renderTargetProperty, CommandBuffer targetCommandBuffer, bool isScriptable, IEffekseerBlitter blitter)
{
RenderPath path;
int allEffectMask;
int cameraMask;
_renderPathContainer.UpdateRenderPath(disableCullingMask, camera, additionalMask, renderTargetProperty, targetCommandBuffer, blitter, cameraEvent, out path, out allEffectMask, out cameraMask);
_renderPathContainer.UpdateRenderPath(disableCullingMask, camera, additionalMask, renderTargetProperty, targetCommandBuffer, isScriptable, blitter, cameraEvent, out path, out allEffectMask, out cameraMask);
if (path == null)
{
return;
Expand Down

0 comments on commit 33a31db

Please sign in to comment.