Identifies a RenderTexture for a Rendering.CommandBuffer.
public override void Render(PostProcessRenderContext context) { var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/ContrastBoost")); sheet.properties.SetFloat("_Blend", settings.blend); sheet.properties.SetFloat("_LumSource", settings.sourceLum); sheet.properties.SetFloat("_LumTarget", settings.targetLum); sheet.properties.SetTexture("_CSFLut", settings.csf); //sheet.properties.SetTexture int yuvlId = Shader.PropertyToID("YUVL"); int LId = Shader.PropertyToID("L"); context.command.GetTemporaryRT(yuvlId, context.width, context.height, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBFloat); context.command.GetTemporaryRT(LId, context.width, context.height, 0, FilterMode.Bilinear, RenderTextureFormat.RFloat); UnityEngine.Rendering.RenderTargetIdentifier yuvlIdentifier = new UnityEngine.Rendering.RenderTargetIdentifier(yuvlId); UnityEngine.Rendering.RenderTargetIdentifier LIdentifier = new UnityEngine.Rendering.RenderTargetIdentifier(LId); context.command.BlitFullscreenTriangle(context.source, yuvlIdentifier, sheet, 1); context.command.BlitFullscreenTriangle(yuvlIdentifier, LIdentifier, sheet, 2); context.command.SetGlobalTexture("_YuvlTex", yuvlIdentifier); context.command.BlitFullscreenTriangle(LIdentifier, context.destination, sheet, 3); context.command.ReleaseTemporaryRT(yuvlId); context.command.ReleaseTemporaryRT(LId); }
static public int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); UnityEngine.Rendering.RenderTargetIdentifier o; if (matchType(l, argc, 2, typeof(UnityEngine.Rendering.BuiltinRenderTextureType))) { UnityEngine.Rendering.BuiltinRenderTextureType a1; checkEnum(l, 2, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(string))) { System.String a1; checkType(l, 2, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(int))) { System.Int32 a1; checkType(l, 2, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(UnityEngine.Texture))) { UnityEngine.Texture a1; checkType(l, 2, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (argc == 0) { o = new UnityEngine.Rendering.RenderTargetIdentifier(); pushValue(l, true); pushObject(l, o); return(2); } return(error(l, "New object failed.")); } catch (Exception e) { return(error(l, e)); } }
void UpdateRtSize(int width, int height) { if (rt == null || rt.width != width || rt.height != height) { if (rt != null) { RenderTexture.ReleaseTemporary(rt); } rt = RenderTexture.GetTemporary(width, height, 0); rtId = new UnityEngine.Rendering.RenderTargetIdentifier(rt.colorBuffer); } }
public override void Render(PostProcessRenderContext context) { if (m_prevFrame == null) { m_prevFrame = RenderTexture.GetTemporary(context.width, context.height); m_prevTarget = new UnityEngine.Rendering.RenderTargetIdentifier(m_prevFrame); context.command.Blit(context.source, m_prevTarget); } var sheet = context.propertySheets.Get(Shader.Find("Custom/Warp")); sheet.properties.SetFloat("_Blend", settings.warp.value); sheet.properties.SetTexture("_Backbuffer", m_prevFrame); context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0); context.command.Blit(context.destination, m_prevTarget); m_prevFrame.IncrementUpdateCount(); }
static int _CreateUnityEngine_Rendering_RenderTargetIdentifier(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(int))) { int arg0 = (int)LuaScriptMgr.GetNumber(L, 1); UnityEngine.Rendering.RenderTargetIdentifier obj = new UnityEngine.Rendering.RenderTargetIdentifier(arg0); LuaScriptMgr.PushValue(L, obj); return 1; } else if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(RenderTexture))) { RenderTexture arg0 = (RenderTexture)LuaScriptMgr.GetUnityObject(L, 1, typeof(RenderTexture)); UnityEngine.Rendering.RenderTargetIdentifier obj = new UnityEngine.Rendering.RenderTargetIdentifier(arg0); LuaScriptMgr.PushValue(L, obj); return 1; } else if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(UnityEngine.Rendering.BuiltinRenderTextureType))) { UnityEngine.Rendering.BuiltinRenderTextureType arg0 = (UnityEngine.Rendering.BuiltinRenderTextureType)LuaScriptMgr.GetNetObject(L, 1, typeof(UnityEngine.Rendering.BuiltinRenderTextureType)); UnityEngine.Rendering.RenderTargetIdentifier obj = new UnityEngine.Rendering.RenderTargetIdentifier(arg0); LuaScriptMgr.PushValue(L, obj); return 1; } else if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(string))) { string arg0 = LuaScriptMgr.GetString(L, 1); UnityEngine.Rendering.RenderTargetIdentifier obj = new UnityEngine.Rendering.RenderTargetIdentifier(arg0); LuaScriptMgr.PushValue(L, obj); return 1; } else if (count == 0) { UnityEngine.Rendering.RenderTargetIdentifier obj = new UnityEngine.Rendering.RenderTargetIdentifier(); LuaScriptMgr.PushValue(L, obj); return 1; } else { LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.Rendering.RenderTargetIdentifier.New"); } return 0; }
public static int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); UnityEngine.Rendering.RenderTargetIdentifier o; if(matchType(l,argc,2,typeof(UnityEngine.Rendering.BuiltinRenderTextureType))){ UnityEngine.Rendering.BuiltinRenderTextureType a1; checkEnum(l,2,out a1); o=new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l,true); pushValue(l,o); return 2; } else if(matchType(l,argc,2,typeof(string))){ System.String a1; checkType(l,2,out a1); o=new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l,true); pushValue(l,o); return 2; } else if(matchType(l,argc,2,typeof(int))){ System.Int32 a1; checkType(l,2,out a1); o=new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l,true); pushValue(l,o); return 2; } else if(matchType(l,argc,2,typeof(UnityEngine.RenderTexture))){ UnityEngine.RenderTexture a1; checkType(l,2,out a1); o=new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l,true); pushValue(l,o); return 2; } return error(l,"New object failed."); } catch(Exception e) { return error(l,e); } }
public override void Render(PostProcessRenderContext context) { #if UNITY_EDITOR if (grabDepthMat == null) { Effekseer.EffekseerSettings.AssignAssets(); } #endif if (grabDepthMat == null && Effekseer.EffekseerSettings.Instance.grabDepthShader != null) { grabDepthMat = new Material(Effekseer.EffekseerSettings.Instance.grabDepthShader); } if (Effekseer.EffekseerSystem.Instance == null || grabDepthMat == null) { context.command.Blit(context.source, context.destination); return; } context.command.Blit(context.source, context.destination); var depthDescriptor = new RenderTextureDescriptor(context.width, context.height, RenderTextureFormat.Depth, 16); var depthIdentifer = new UnityEngine.Rendering.RenderTargetIdentifier(propertyId); context.command.GetTemporaryRT(propertyId, depthDescriptor); context.command.Blit(context.source, depthIdentifer, grabDepthMat); prop.colorTargetDescriptor = new RenderTextureDescriptor(context.width, context.height, context.sourceFormat); prop.colorTargetIdentifier = context.destination; prop.depthTargetIdentifier = depthIdentifer; context.command.SetRenderTarget(context.destination, depthIdentifer); Effekseer.EffekseerSystem.Instance.renderer.Render(context.camera, prop, context.command); context.command.ReleaseTemporaryRT(propertyId); }
extern private void SetShadowSamplingMode_Impl(ref UnityEngine.Rendering.RenderTargetIdentifier shadowmap, ShadowSamplingMode mode);
extern private void Blit_Identifier(ref UnityEngine.Rendering.RenderTargetIdentifier source, ref UnityEngine.Rendering.RenderTargetIdentifier dest, Material mat, int pass, Vector2 scale, Vector2 offset);
extern private void SetRandomWriteTarget_Texture(int index, ref UnityEngine.Rendering.RenderTargetIdentifier rt);
private extern void SetGlobalTexture_Impl(int nameID, ref RenderTargetIdentifier rt);
public void Blit(Texture source, RenderTargetIdentifier dest, Material mat, int pass) { this.Blit_Texture(source, ref dest, mat, pass); }
private extern void Blit_Identifier(ref RenderTargetIdentifier source, ref RenderTargetIdentifier dest, [DefaultValue("null")] Material mat, [DefaultValue("-1")] int pass);
/// <summary> /// <para>Add a "set active render target" command.</para> /// </summary> /// <param name="rt">Render target to set for both color & depth buffers.</param> /// <param name="color">Render target to set as a color buffer.</param> /// <param name="colors">Render targets to set as color buffers (MRT).</param> /// <param name="depth">Render target to set as a depth buffer.</param> /// <param name="mipLevel">The mip level of the render target to render into.</param> /// <param name="cubemapFace">The cubemap face of a cubemap render target to render into.</param> public void SetRenderTarget(RenderTargetIdentifier rt, int mipLevel, CubemapFace cubemapFace) { this.SetRenderTarget_Single(ref rt, mipLevel, cubemapFace); }
/// <summary> /// <para>Add a "set active render target" command.</para> /// </summary> /// <param name="rt">Render target to set for both color & depth buffers.</param> /// <param name="color">Render target to set as a color buffer.</param> /// <param name="colors">Render targets to set as color buffers (MRT).</param> /// <param name="depth">Render target to set as a depth buffer.</param> /// <param name="mipLevel">The mip level of the render target to render into.</param> /// <param name="cubemapFace">The cubemap face of a cubemap render target to render into.</param> public void SetRenderTarget(RenderTargetIdentifier color, RenderTargetIdentifier depth) { this.SetRenderTarget_ColDepth(ref color, ref depth, 0, CubemapFace.Unknown); }
public static void SwitchOutOfFastMemory(this CommandBuffer cmd, RenderTargetIdentifier rid, bool copyContents) { Internal_SwitchOutOfFastMemory(cmd, ref rid, copyContents); }
/// <summary> /// <para>Add a "set active render target" command.</para> /// </summary> /// <param name="rt">Render target to set for both color & depth buffers.</param> /// <param name="color">Render target to set as a color buffer.</param> /// <param name="colors">Render targets to set as color buffers (MRT).</param> /// <param name="depth">Render target to set as a depth buffer.</param> /// <param name="mipLevel">The mip level of the render target to render into.</param> /// <param name="cubemapFace">The cubemap face of a cubemap render target to render into.</param> public void SetRenderTarget(RenderTargetIdentifier rt) { this.SetRenderTarget_Single(ref rt, 0, CubemapFace.Unknown); }
public static void SwitchIntoFastMemory(this CommandBuffer cmd, RenderTargetIdentifier rid, FastMemoryFlags fastMemoryFlags, float residency, bool copyContents) { Internal_SwitchIntoFastMemory(cmd, ref rid, fastMemoryFlags, residency, copyContents); }
extern private static void Internal_SwitchOutOfFastMemory([NotNull("NullExceptionObject")] CommandBuffer cmd, ref UnityEngine.Rendering.RenderTargetIdentifier rt, bool copyContents);
extern private static void Internal_SwitchIntoFastMemory([NotNull("NullExceptionObject")] CommandBuffer cmd, ref UnityEngine.Rendering.RenderTargetIdentifier rt, UnityEngine.Rendering.FastMemoryFlags fastMemoryFlags, float residency, bool copyContents);
void AddPaintLayer(RenderTargetIdentifier[] mrt, int sceneRenderID, int colorReadID, int depthReadID, ComputeBuffer strokeBuffer, Material strokeMaterial) { // MAIN BRUSHSTROKE CONTENTS PASS!!!: strokeMaterial.SetPass(0); strokeMaterial.SetBuffer("strokeDataBuffer", strokeBuffer); strokeMaterial.SetBuffer("quadPointsBuffer", quadPointsBuffer); cmdBuffer.SetGlobalTexture("_CanvasColorReadTex", colorReadID); cmdBuffer.SetGlobalTexture("_CanvasDepthReadTex", depthReadID); cmdBuffer.SetRenderTarget(mrt, BuiltinRenderTextureType.CameraTarget); // Set render Targets cmdBuffer.SetGlobalTexture("_BrushColorReadTex", sceneRenderID); // Copy the Contents of FrameBuffer into brushstroke material so it knows what color it should be cmdBuffer.DrawProcedural(Matrix4x4.identity, strokeMaterial, 0, MeshTopology.Triangles, 6, strokeBuffer.count); // Apply brushstrokes }
/// <summary> /// <para>Add a "set active render target" command.</para> /// </summary> /// <param name="rt">Render target to set for both color & depth buffers.</param> /// <param name="color">Render target to set as a color buffer.</param> /// <param name="colors">Render targets to set as color buffers (MRT).</param> /// <param name="depth">Render target to set as a depth buffer.</param> /// <param name="mipLevel">The mip level of the render target to render into.</param> /// <param name="cubemapFace">The cubemap face of a cubemap render target to render into.</param> public void SetRenderTarget(RenderTargetIdentifier color, RenderTargetIdentifier depth, int mipLevel, CubemapFace cubemapFace) { this.SetRenderTarget_ColDepth(ref color, ref depth, mipLevel, cubemapFace); }
public static void BC6HEncodeFastCubemap(this CommandBuffer cmb, RenderTargetIdentifier source, int sourceSize, RenderTargetIdentifier target, int fromMip, int toMip, int targetArrayIndex = 0) { EncodeBC6H.DefaultInstance.EncodeFastCubemap(cmb, source, sourceSize, target, fromMip, toMip, targetArrayIndex); }
/// <summary> /// <para>Add a "set active render target" command.</para> /// </summary> /// <param name="rt">Render target to set for both color & depth buffers.</param> /// <param name="color">Render target to set as a color buffer.</param> /// <param name="colors">Render targets to set as color buffers (MRT).</param> /// <param name="depth">Render target to set as a depth buffer.</param> /// <param name="mipLevel">The mip level of the render target to render into.</param> /// <param name="cubemapFace">The cubemap face of a cubemap render target to render into.</param> public void SetRenderTarget(RenderTargetIdentifier[] colors, RenderTargetIdentifier depth) { this.SetRenderTarget_Multiple(colors, ref depth); }
public void Blit(RenderTargetIdentifier source, RenderTargetIdentifier dest) { this.Blit_Identifier(ref source, ref dest, null, -1); }
static public int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); UnityEngine.Rendering.RenderTargetIdentifier o; if (matchType(l, "ctor__String__Int32__CubemapFace__Int32", argc, 2, typeof(string), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { System.String a1; checkType(l, 3, out a1); System.Int32 a2; checkType(l, 4, out a2); UnityEngine.CubemapFace a3; checkEnum(l, 5, out a3); System.Int32 a4; checkType(l, 6, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, "ctor__Int32__Int32__CubemapFace__Int32", argc, 2, typeof(int), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { System.Int32 a1; checkType(l, 3, out a1); System.Int32 a2; checkType(l, 4, out a2); UnityEngine.CubemapFace a3; checkEnum(l, 5, out a3); System.Int32 a4; checkType(l, 6, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, "ctor__RenderTargetIdentifier__Int32__CubemapFace__Int32", argc, 2, typeof(UnityEngine.Rendering.RenderTargetIdentifier), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { UnityEngine.Rendering.RenderTargetIdentifier a1; checkValueType(l, 3, out a1); System.Int32 a2; checkType(l, 4, out a2); UnityEngine.CubemapFace a3; checkEnum(l, 5, out a3); System.Int32 a4; checkType(l, 6, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, "ctor__Texture__Int32__CubemapFace__Int32", argc, 2, typeof(UnityEngine.Texture), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { UnityEngine.Texture a1; checkType(l, 3, out a1); System.Int32 a2; checkType(l, 4, out a2); UnityEngine.CubemapFace a3; checkEnum(l, 5, out a3); System.Int32 a4; checkType(l, 6, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, "ctor__RenderBuffer__Int32__CubemapFace__Int32", argc, 2, typeof(UnityEngine.RenderBuffer), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { UnityEngine.RenderBuffer a1; checkValueType(l, 3, out a1); System.Int32 a2; checkType(l, 4, out a2); UnityEngine.CubemapFace a3; checkEnum(l, 5, out a3); System.Int32 a4; checkType(l, 6, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, "ctor__BuiltinRenderTextureType", argc, 2, typeof(UnityEngine.Rendering.BuiltinRenderTextureType))) { UnityEngine.Rendering.BuiltinRenderTextureType a1; checkEnum(l, 3, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, "ctor__String", argc, 2, typeof(string))) { System.String a1; checkType(l, 3, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, "ctor__Int32", argc, 2, typeof(int))) { System.Int32 a1; checkType(l, 3, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, "ctor__Texture", argc, 2, typeof(UnityEngine.Texture))) { UnityEngine.Texture a1; checkType(l, 3, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (argc <= 1) { o = new UnityEngine.Rendering.RenderTargetIdentifier(); pushValue(l, true); pushObject(l, o); return(2); } return(error(l, "New object failed.")); } catch (Exception e) { return(error(l, e)); } }
public void SetGlobalTexture(string name, RenderTargetIdentifier value) { this.SetGlobalTexture(Shader.PropertyToID(name), value); }
/// <summary> /// Allocate a RTHandle from a regular render target identifier. /// </summary> /// <param name="texture">Input render target identifier.</param> /// <returns>A new RTHandle referencing the input render target identifier.</returns> public RTHandle Alloc(RenderTargetIdentifier texture) { return(Alloc(texture, "")); }
public void SetGlobalTexture(int nameID, RenderTargetIdentifier value, RenderTextureSubElement element) { SetGlobalTexture_Impl(nameID, ref value, element); }
public void ProcessVTFeedback(RenderTargetIdentifier rt, IntPtr resolver, int slice, int x, int width, int y, int height, int mip) { ValidateAgainstExecutionFlags(CommandBufferExecutionFlags.None, CommandBufferExecutionFlags.AsyncCompute); Internal_ProcessVTFeedback(rt, resolver, slice, x, width, y, height, mip); }
extern private void Internal_SetComputeTextureParam([NotNull] ComputeShader computeShader, int kernelIndex, int nameID, ref UnityEngine.Rendering.RenderTargetIdentifier rt, int mipLevel);
void UpdateCommandBuffer() { var cam = GetComponent<Camera>(); RenderSettings.fogColor = m_fog_color; if (m_quad == null) { m_quad = RaymarcherUtils.GenerateQuad(); } bool reflesh_command_buffer = false; Vector2 reso = new Vector2(cam.pixelWidth, cam.pixelHeight); if(m_resolution_prev!=reso) { m_resolution_prev = reso; reflesh_command_buffer = true; } if (m_enable_adaptive_prev != m_enable_adaptive) { m_enable_adaptive_prev = m_enable_adaptive; reflesh_command_buffer = true; } if (m_dbg_show_steps_prev != m_dbg_show_steps) { m_dbg_show_steps_prev = m_dbg_show_steps; reflesh_command_buffer = true; } if (reflesh_command_buffer) { reflesh_command_buffer = false; ClearCommandBuffer(); } if (m_cb_raymarch==null) { if (m_enable_adaptive) { RenderTargetIdentifier[] rt; m_cb_prepass = new CommandBuffer(); m_cb_prepass.name = "Raymarcher Adaptive PrePass"; int odepth = Shader.PropertyToID("ODepth"); int odepth_prev = Shader.PropertyToID("ODepthPrev"); int ovelocity = Shader.PropertyToID("OVelocity"); int qdepth = Shader.PropertyToID("QDepth"); int qdepth_prev = Shader.PropertyToID("QDepthPrev"); int hdepth = Shader.PropertyToID("HDepth"); int hdepth_prev = Shader.PropertyToID("HDepthPrev"); int adepth = Shader.PropertyToID("ADepth"); int adepth_prev = Shader.PropertyToID("ADepthPrev"); m_cb_prepass.GetTemporaryRT(odepth, cam.pixelWidth / 8, cam.pixelHeight / 8, 0, FilterMode.Point, RenderTextureFormat.RFloat); m_cb_prepass.GetTemporaryRT(odepth_prev,cam.pixelWidth / 8, cam.pixelHeight / 8, 0, FilterMode.Point, RenderTextureFormat.RFloat); m_cb_prepass.GetTemporaryRT(ovelocity, cam.pixelWidth / 8, cam.pixelHeight / 8, 0, FilterMode.Point, RenderTextureFormat.RHalf); m_cb_prepass.GetTemporaryRT(qdepth, cam.pixelWidth / 4, cam.pixelHeight / 4, 0, FilterMode.Point, RenderTextureFormat.RFloat); m_cb_prepass.GetTemporaryRT(qdepth_prev,cam.pixelWidth / 4, cam.pixelHeight / 4, 0, FilterMode.Point, RenderTextureFormat.RFloat); m_cb_prepass.GetTemporaryRT(hdepth, cam.pixelWidth / 2, cam.pixelHeight / 2, 0, FilterMode.Point, RenderTextureFormat.RFloat); m_cb_prepass.GetTemporaryRT(hdepth_prev,cam.pixelWidth / 2, cam.pixelHeight / 2, 0, FilterMode.Point, RenderTextureFormat.RFloat); m_cb_prepass.GetTemporaryRT(adepth, cam.pixelWidth / 1, cam.pixelHeight / 1, 0, FilterMode.Point, RenderTextureFormat.RFloat); m_cb_prepass.GetTemporaryRT(adepth_prev,cam.pixelWidth / 1, cam.pixelHeight / 1, 0, FilterMode.Point, RenderTextureFormat.RFloat); rt = new RenderTargetIdentifier[2] { odepth, ovelocity }; m_cb_prepass.SetGlobalTexture("g_depth_prev", odepth_prev); m_cb_prepass.SetRenderTarget(rt, odepth); m_cb_prepass.DrawMesh(m_quad, Matrix4x4.identity, m_internal_material, 0, 1); m_cb_prepass.Blit(odepth, odepth_prev); m_cb_prepass.SetGlobalTexture("g_velocity", ovelocity); m_cb_prepass.SetRenderTarget(qdepth); m_cb_prepass.SetGlobalTexture("g_depth", odepth); m_cb_prepass.SetGlobalTexture("g_depth_prev", qdepth_prev); m_cb_prepass.DrawMesh(m_quad, Matrix4x4.identity, m_internal_material, 0, 2); m_cb_prepass.Blit(qdepth, qdepth_prev); m_cb_prepass.SetRenderTarget(hdepth); m_cb_prepass.SetGlobalTexture("g_depth", qdepth); m_cb_prepass.SetGlobalTexture("g_depth_prev", hdepth_prev); m_cb_prepass.DrawMesh(m_quad, Matrix4x4.identity, m_internal_material, 0, 3); m_cb_prepass.Blit(hdepth, hdepth_prev); m_cb_prepass.SetRenderTarget(adepth); m_cb_prepass.SetGlobalTexture("g_depth", hdepth); m_cb_prepass.SetGlobalTexture("g_depth_prev", adepth_prev); m_cb_prepass.DrawMesh(m_quad, Matrix4x4.identity, m_internal_material, 0, 4); m_cb_prepass.Blit(adepth, adepth_prev); m_cb_prepass.SetGlobalTexture("g_depth", adepth); cam.AddCommandBuffer(CameraEvent.BeforeGBuffer, m_cb_prepass); } m_cb_raymarch = new CommandBuffer(); m_cb_raymarch.name = "Raymarcher"; m_cb_raymarch.DrawMesh(m_quad, Matrix4x4.identity, m_internal_material, 0, 0); cam.AddCommandBuffer(CameraEvent.BeforeGBuffer, m_cb_raymarch); } }
extern private void CopyTexture_Internal(ref UnityEngine.Rendering.RenderTargetIdentifier src, int srcElement, int srcMip, int srcX, int srcY, int srcWidth, int srcHeight, ref UnityEngine.Rendering.RenderTargetIdentifier dst, int dstElement, int dstMip, int dstX, int dstY, int mode);
public void SetRenderTarget(RenderTargetIdentifier color, RenderTargetIdentifier depth) { this.SetRenderTarget_ColDepth(ref color, ref depth); }
extern private void SetGlobalTexture_Impl(int nameID, ref UnityEngine.Rendering.RenderTargetIdentifier rt);
private extern void SetRenderTarget_Single(ref RenderTargetIdentifier rt);
extern private void IssuePluginCustomBlitInternal(IntPtr callback, uint command, ref UnityEngine.Rendering.RenderTargetIdentifier source, ref UnityEngine.Rendering.RenderTargetIdentifier dest, uint commandParam, uint commandFlags);
private extern void SetRenderTarget_Multiple(RenderTargetIdentifier[] color, ref RenderTargetIdentifier depth);
public static void Blit (SpoutResources resrc, CommandBuffer cb, RTID src, RTID dst, bool alpha) => cb.Blit(src, dst, GetMaterial(resrc), alpha ? 0 : 1);
// Only use mode11 of BC6H encoding /// <summary> /// Encode a Cubemap in BC6H. /// /// It will encode all faces and selected mips of the Cubemap. /// /// It uses only mode 11 of BC6H. /// </summary> /// <param name="cmb">Command buffer for execution</param> /// <param name="source">The source Cubemap</param> /// <param name="sourceSize">The size of the source Cubemap</param> /// <param name="target">The compressed texture. /// It must be a BC6H Cubemap or Cubemap array with the same size as the source Cubemap</param> /// <param name="fromMip">Starting mip to encode</param> /// <param name="toMip">Last mip to encode</param> /// <param name="targetArrayIndex">The index of the cubemap to store the compressed texture. /// /// Only relevant when target is a CubemapArray</param> public void EncodeFastCubemap(CommandBuffer cmb, RenderTargetIdentifier source, int sourceSize, RenderTargetIdentifier target, int fromMip, int toMip, int targetArrayIndex = 0) { var maxMip = Mathf.Max(0, (int)(Mathf.Log(sourceSize) / Mathf.Log(2)) - 2); var actualFromMip = (int)Mathf.Clamp(fromMip, 0, maxMip); var actualToMip = (int)Mathf.Min(maxMip, Mathf.Max(toMip, actualFromMip)); // Convert TextureCube source to Texture2DArray var d = new RenderTextureDescriptor { autoGenerateMips = false, bindMS = false, colorFormat = RenderTextureFormat.ARGBInt, depthBufferBits = 0, dimension = TextureDimension.Tex2DArray, enableRandomWrite = true, msaaSamples = 1, volumeDepth = 6, sRGB = false, useMipMap = false, }; cmb.SetComputeTextureParam(m_Shader, m_KEncodeFastCubemapMip, _Source, source); for (var mip = actualFromMip; mip <= actualToMip; ++mip) { var size = (sourceSize >> mip) >> 2; d.width = size; d.height = size; cmb.GetTemporaryRT(__Tmp_RT[mip], d); } for (var mip = actualFromMip; mip <= actualToMip; ++mip) { var size = (sourceSize >> mip) >> 2; cmb.SetComputeTextureParam(m_Shader, m_KEncodeFastCubemapMip, _Target, __Tmp_RT[mip]); cmb.SetComputeIntParam(m_Shader, _MipIndex, mip); cmb.DispatchCompute(m_Shader, m_KEncodeFastCubemapMip, size, size, 6); } var startSlice = 6 * targetArrayIndex; for (var mip = actualFromMip; mip <= actualToMip; ++mip) { var rtMip = Mathf.Clamp(mip, actualFromMip, actualToMip); for (var faceId = 0; faceId < 6; ++faceId) { cmb.CopyTexture(__Tmp_RT[rtMip], faceId, 0, target, startSlice + faceId, mip); } } for (var mip = actualFromMip; mip <= actualToMip; ++mip) { cmb.ReleaseTemporaryRT(__Tmp_RT[mip]); } }
// Build commands for the AO pass (used in the ambient-only mode). void BuildAOCommands() { var cb = aoCommands; var tw = targetCamera.pixelWidth; var th = targetCamera.pixelHeight; var format = RenderTextureFormat.R8; var rwMode = RenderTextureReadWrite.Linear; if (downsampling) { tw /= 2; th /= 2; } // AO buffer var m = aoMaterial; var rtMask = Shader.PropertyToID("_OcclusionTexture"); cb.GetTemporaryRT(rtMask, tw, th, 0, FilterMode.Bilinear, format, rwMode); // AO estimation cb.Blit((Texture)null, rtMask, m, 0); if (blurIterations > 0) { // Blur buffer var rtBlur = Shader.PropertyToID("_OcclusionBlurTexture"); cb.GetTemporaryRT(rtBlur, tw, th, 0, FilterMode.Bilinear, format, rwMode); // Blur iterations for (var i = 0; i < blurIterations; i++) { cb.SetGlobalVector("_BlurVector", Vector2.right); cb.Blit(rtMask, rtBlur, m, 1); cb.SetGlobalVector("_BlurVector", Vector2.up); cb.Blit(rtBlur, rtMask, m, 1); } cb.ReleaseTemporaryRT(rtBlur); } // Combine AO to the G-buffer. var mrt = new RenderTargetIdentifier[] { BuiltinRenderTextureType.GBuffer0, // Albedo, Occ BuiltinRenderTextureType.CameraTarget // Ambient }; cb.SetRenderTarget(mrt, BuiltinRenderTextureType.CameraTarget); cb.DrawMesh(quadMesh, Matrix4x4.identity, m, 0, 3); cb.ReleaseTemporaryRT(rtMask); }
public void SetRenderTarget(RenderTargetIdentifier[] colors, RenderTargetIdentifier depth) { this.SetRenderTarget_Multiple(colors, ref depth); }
private extern void SetRenderTarget_ColDepth(ref RenderTargetIdentifier color, ref RenderTargetIdentifier depth);
public void Blit(Texture source, RenderTargetIdentifier dest) { this.Blit_Texture(source, ref dest, null, -1); }
private extern void Blit_Texture(Texture source, ref RenderTargetIdentifier dest, Material mat, int pass);
private void SetRenderTarget_Single(ref RenderTargetIdentifier rt, int mipLevel, CubemapFace cubemapFace);
public void Blit(RenderTargetIdentifier source, RenderTargetIdentifier dest, Material mat, int pass) { this.Blit_Identifier(ref source, ref dest, mat, pass); }
private void SetRenderTarget_ColDepth(ref RenderTargetIdentifier color, ref RenderTargetIdentifier depth, int mipLevel, CubemapFace cubemapFace);
private void Blit_Identifier(ref RenderTargetIdentifier source, ref RenderTargetIdentifier dest) { int pass = -1; Material mat = null; this.Blit_Identifier(ref source, ref dest, mat, pass); }
/// <summary> /// <para>Add a "set shadow sampling mode" command.</para> /// </summary> /// <param name="shadowmap">Shadowmap render target to change the sampling mode on.</param> /// <param name="mode">New sampling mode.</param> public void SetShadowSamplingMode(RenderTargetIdentifier shadowmap, ShadowSamplingMode mode) { this.SetShadowSamplingMode_Impl(ref shadowmap, mode); }
public void SetGlobalTexture(int nameID, RenderTargetIdentifier value) { this.SetGlobalTexture_Impl(nameID, ref value); }
private void SetShadowSamplingMode_Impl(ref RenderTargetIdentifier shadowmap, ShadowSamplingMode mode);
public void SetRenderTarget(RenderTargetIdentifier rt) { this.SetRenderTarget_Single(ref rt); }
static public int constructor(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); UnityEngine.Rendering.RenderTargetIdentifier o; if (matchType(l, argc, 2, typeof(UnityEngine.Rendering.BuiltinRenderTextureType))) { UnityEngine.Rendering.BuiltinRenderTextureType a1; a1 = (UnityEngine.Rendering.BuiltinRenderTextureType)LuaDLL.luaL_checkinteger(l, 2); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(string))) { System.String a1; checkType(l, 2, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(string), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { System.String a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); UnityEngine.CubemapFace a3; a3 = (UnityEngine.CubemapFace)LuaDLL.luaL_checkinteger(l, 4); System.Int32 a4; checkType(l, 5, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(int))) { System.Int32 a1; checkType(l, 2, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(int), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { System.Int32 a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); UnityEngine.CubemapFace a3; a3 = (UnityEngine.CubemapFace)LuaDLL.luaL_checkinteger(l, 4); System.Int32 a4; checkType(l, 5, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(UnityEngine.Rendering.RenderTargetIdentifier), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { UnityEngine.Rendering.RenderTargetIdentifier a1; checkValueType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); UnityEngine.CubemapFace a3; a3 = (UnityEngine.CubemapFace)LuaDLL.luaL_checkinteger(l, 4); System.Int32 a4; checkType(l, 5, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(UnityEngine.Texture))) { UnityEngine.Texture a1; checkType(l, 2, out a1); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(UnityEngine.Texture), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { UnityEngine.Texture a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); UnityEngine.CubemapFace a3; a3 = (UnityEngine.CubemapFace)LuaDLL.luaL_checkinteger(l, 4); System.Int32 a4; checkType(l, 5, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (matchType(l, argc, 2, typeof(UnityEngine.RenderBuffer), typeof(int), typeof(UnityEngine.CubemapFace), typeof(int))) { UnityEngine.RenderBuffer a1; checkValueType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); UnityEngine.CubemapFace a3; a3 = (UnityEngine.CubemapFace)LuaDLL.luaL_checkinteger(l, 4); System.Int32 a4; checkType(l, 5, out a4); o = new UnityEngine.Rendering.RenderTargetIdentifier(a1, a2, a3, a4); pushValue(l, true); pushValue(l, o); return(2); } else if (argc == 0) { o = new UnityEngine.Rendering.RenderTargetIdentifier(); pushValue(l, true); pushObject(l, o); return(2); } return(error(l, "New object failed.")); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
// Build commands for the AO pass (used in the ambient-only mode). void BuildAOCommands() { var cb = aoCommands; var tw = targetCamera.pixelWidth; var th = targetCamera.pixelHeight; var ts = downsampling ? 2 : 1; var format = aoTextureFormat; var rwMode = RenderTextureReadWrite.Linear; var filter = FilterMode.Bilinear; // AO buffer var m = aoMaterial; var rtMask = Shader.PropertyToID("_OcclusionTexture"); cb.GetTemporaryRT(rtMask, tw / ts, th / ts, 0, filter, format, rwMode); // AO estimation cb.Blit((Texture)null, rtMask, m, 2); // Blur buffer var rtBlur = Shader.PropertyToID("_OcclusionBlurTexture"); // Primary blur filter (large kernel) cb.GetTemporaryRT(rtBlur, tw, th, 0, filter, format, rwMode); cb.SetGlobalVector("_BlurVector", Vector2.right * 2); cb.Blit(rtMask, rtBlur, m, 4); cb.ReleaseTemporaryRT(rtMask); cb.GetTemporaryRT(rtMask, tw, th, 0, filter, format, rwMode); cb.SetGlobalVector("_BlurVector", Vector2.up * 2 * ts); cb.Blit(rtBlur, rtMask, m, 4); cb.ReleaseTemporaryRT(rtBlur); // Secondary blur filter (small kernel) cb.GetTemporaryRT(rtBlur, tw, th, 0, filter, format, rwMode); cb.SetGlobalVector("_BlurVector", Vector2.right * ts); cb.Blit(rtMask, rtBlur, m, 6); cb.ReleaseTemporaryRT(rtMask); cb.GetTemporaryRT(rtMask, tw, th, 0, filter, format, rwMode); cb.SetGlobalVector("_BlurVector", Vector2.up * ts); cb.Blit(rtBlur, rtMask, m, 6); cb.ReleaseTemporaryRT(rtBlur); // Combine AO to the G-buffer. var mrt = new RenderTargetIdentifier[] { BuiltinRenderTextureType.GBuffer0, // Albedo, Occ BuiltinRenderTextureType.CameraTarget // Ambient }; cb.SetRenderTarget(mrt, BuiltinRenderTextureType.CameraTarget); cb.SetGlobalTexture("_OcclusionTexture", rtMask); cb.DrawMesh(quadMesh, Matrix4x4.identity, m, 0, 8); cb.ReleaseTemporaryRT(rtMask); }
private static void InsertCommand(UnityEngine.Rendering.CommandBuffer buf, PluginExtCommands command, UnityEngine.Rendering.RenderTargetIdentifier source, UnityEngine.Rendering.RenderTargetIdentifier dest, UInt32 commandParam, UInt32 commandFlags) { buf.IssuePluginCustomBlit(PluginExtGetIssueEventCallback(), (UInt32)command, source, dest, commandParam, commandFlags); }