public void OnEnable() { if (_commands == null) { _commands = new UnityEngine.Rendering.CommandBuffer(); } }
public bool SetActiveFeature(Feature value) { if (!IsFeatureAvailableInternal(value)) { Debug.LogErrorFormat("VRWorks feature " + GetFeatureName(value) + " is not supported on this hardware"); return false; } uint renderFeatures = 0; if (value == Feature.MultiResolution) { renderFeatures |= kPluginExtFeatureMRSCons; } else if (value == Feature.SinglePassStereo) { renderFeatures |= kPluginExtFeatureSPSActive; } else if (value == Feature.LensMatchedShading) { renderFeatures |= kPluginExtFeatureSPSActive | kPluginExtFeatureLMSActive; } UnitySetRenderFeatureState(renderFeatures); UnityEngine.Rendering.CommandBuffer buf = new UnityEngine.Rendering.CommandBuffer(); InsertMarker(buf, PluginExtMarker.kPluginExtMarkerSetRenderFeatures, renderFeatures); Graphics.ExecuteCommandBuffer(buf); GL.Flush(); return true; }
//public override string GetName() //{ // return "Render Solid Color Outliner"; //} //public override void PopulateCommandBuffer(CommandBuffer cb) //{ // cb.ClearRenderTarget(true, true, Color.clear); // var m_outterLineMat = context.materialFactory.Get("Unlit/ColorSel"); // if (outRen) // cb.DrawRenderer(outRen, m_outterLineMat); //} //public override CameraEvent GetCameraEvent() //{ // return CameraEvent.AfterImageEffectsOpaque; //} public void Prepare(RenderTexture source, Material uberMaterial, UnityEngine.Rendering.CommandBuffer cb) { var outLine = model.settings.outLine; var blurMaterial = context.materialFactory.Get("Hidden/OutLine"); blurMaterial.SetVector("_Parameter", new Vector4(outLine.blurSize * 0.5f, -outLine.blurSize * 0.5f, 0.0f, 0.0f)); int rtW = (int)(source.width * outLine.rtScale); int rtH = (int)(source.height * outLine.rtScale); RenderTexture rt1 = RenderTexture.GetTemporary(rtW, rtH, 0, source.format); rt1.filterMode = FilterMode.Bilinear; Graphics.SetRenderTarget(rt1); Graphics.ExecuteCommandBuffer(cb); //Debug.Log("excues cb!"); RenderTexture rt2 = context.renderTextureFactory.Get(rtW, rtH, 0, source.format); rt2.filterMode = FilterMode.Bilinear; blurMaterial.SetVector("_BlurOffsets", new Vector4(outLine.blurSize * 0.5f, -outLine.blurSize * 0.5f, 0.0f, 0.0f)); Graphics.Blit(rt1, rt2, blurMaterial); RenderTexture.ReleaseTemporary(rt1); // Push everything to the uber material uberMaterial.SetTexture("_OutBlurTex", rt2); uberMaterial.SetColor("_OutColor", outLine.outterColor); uberMaterial.EnableKeyword("OUTLINE"); //RenderTexture.ReleaseTemporary(rt2); }
static int AddCommandBuffer(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3) { UnityEngine.Light obj = (UnityEngine.Light)ToLua.CheckObject <UnityEngine.Light>(L, 1); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)ToLua.CheckObject(L, 2, TypeTraits <UnityEngine.Rendering.LightEvent> .type); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)ToLua.CheckObject <UnityEngine.Rendering.CommandBuffer>(L, 3); obj.AddCommandBuffer(arg0, arg1); return(0); } else if (count == 4) { UnityEngine.Light obj = (UnityEngine.Light)ToLua.CheckObject <UnityEngine.Light>(L, 1); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)ToLua.CheckObject(L, 2, TypeTraits <UnityEngine.Rendering.LightEvent> .type); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)ToLua.CheckObject <UnityEngine.Rendering.CommandBuffer>(L, 3); UnityEngine.Rendering.ShadowMapPass arg2 = (UnityEngine.Rendering.ShadowMapPass)ToLua.CheckObject(L, 4, TypeTraits <UnityEngine.Rendering.ShadowMapPass> .type); obj.AddCommandBuffer(arg0, arg1, arg2); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Light.AddCommandBuffer")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int AddCommandBufferAsync(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 4) { Light obj = (Light)LuaScriptMgr.GetUnityObjectSelf(L, 1, "Light"); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)LuaScriptMgr.GetNetObject(L, 2, typeof(UnityEngine.Rendering.LightEvent)); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)LuaScriptMgr.GetNetObject(L, 3, typeof(UnityEngine.Rendering.CommandBuffer)); UnityEngine.Rendering.ComputeQueueType arg2 = (UnityEngine.Rendering.ComputeQueueType)LuaScriptMgr.GetNetObject(L, 4, typeof(UnityEngine.Rendering.ComputeQueueType)); obj.AddCommandBufferAsync(arg0, arg1, arg2); return(0); } else if (count == 5) { Light obj = (Light)LuaScriptMgr.GetUnityObjectSelf(L, 1, "Light"); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)LuaScriptMgr.GetNetObject(L, 2, typeof(UnityEngine.Rendering.LightEvent)); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)LuaScriptMgr.GetNetObject(L, 3, typeof(UnityEngine.Rendering.CommandBuffer)); UnityEngine.Rendering.ShadowMapPass arg2 = (UnityEngine.Rendering.ShadowMapPass)LuaScriptMgr.GetNetObject(L, 4, typeof(UnityEngine.Rendering.ShadowMapPass)); UnityEngine.Rendering.ComputeQueueType arg3 = (UnityEngine.Rendering.ComputeQueueType)LuaScriptMgr.GetNetObject(L, 5, typeof(UnityEngine.Rendering.ComputeQueueType)); obj.AddCommandBufferAsync(arg0, arg1, arg2, arg3); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: Light.AddCommandBufferAsync"); } return(0); }
public void EndDisableFeature() { UnityEngine.Rendering.CommandBuffer buf = new UnityEngine.Rendering.CommandBuffer(); uint renderFeatures = UnityGetRenderFeatureState(); InsertMarker(buf, PluginExtMarker.kPluginExtMarkerSetRenderFeatures, renderFeatures); Graphics.ExecuteCommandBuffer(buf); }
void OnEnable() { _commands = new UnityEngine.Rendering.CommandBuffer(); if (gameObject.GetComponent <Camera>() == null) { if (_texture != null && _textureCamera == null) { _textureCamera = gameObject.AddComponent <Camera>(); _textureCamera.clearFlags = CameraClearFlags.SolidColor; _textureCamera.backgroundColor = new UnityEngine.Color(0.0f, 0.0f, 0.0f, 0.0f); _textureCamera.renderingPath = RenderingPath.Forward; _textureCamera.depthTextureMode = DepthTextureMode.None; _textureCamera.opaqueSortMode = UnityEngine.Rendering.OpaqueSortMode.NoDistanceSort; _textureCamera.transparencySortMode = TransparencySortMode.Orthographic; _textureCamera.clearStencilAfterLightingPass = false; #if UNITY_5_6_OR_NEWER _textureCamera.allowHDR = false; #else _textureCamera.hdr = false; #endif _textureCamera.useOcclusionCulling = false; _textureCamera.cullingMask = 0; _textureCamera.targetTexture = _texture; _textureCamera.enabled = false; } } LoadXaml(false); }
static int AddCommandBuffer(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Light), typeof(UnityEngine.Rendering.LightEvent), typeof(UnityEngine.Rendering.CommandBuffer))) { UnityEngine.Light obj = (UnityEngine.Light)ToLua.ToObject(L, 1); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)ToLua.ToObject(L, 2); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)ToLua.ToObject(L, 3); obj.AddCommandBuffer(arg0, arg1); return(0); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Light), typeof(UnityEngine.Rendering.LightEvent), typeof(UnityEngine.Rendering.CommandBuffer), typeof(UnityEngine.Rendering.ShadowMapPass))) { UnityEngine.Light obj = (UnityEngine.Light)ToLua.ToObject(L, 1); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)ToLua.ToObject(L, 2); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)ToLua.ToObject(L, 3); UnityEngine.Rendering.ShadowMapPass arg2 = (UnityEngine.Rendering.ShadowMapPass)ToLua.ToObject(L, 4); obj.AddCommandBuffer(arg0, arg1, arg2); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Light.AddCommandBuffer")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int AddCommandBufferAsync(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 4) { UnityEngine.Light obj = (UnityEngine.Light)ToLua.CheckObject(L, 1, typeof(UnityEngine.Light)); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)ToLua.CheckObject(L, 2, typeof(UnityEngine.Rendering.LightEvent)); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)ToLua.CheckObject(L, 3, typeof(UnityEngine.Rendering.CommandBuffer)); UnityEngine.Rendering.ComputeQueueType arg2 = (UnityEngine.Rendering.ComputeQueueType)ToLua.CheckObject(L, 4, typeof(UnityEngine.Rendering.ComputeQueueType)); obj.AddCommandBufferAsync(arg0, arg1, arg2); return(0); } else if (count == 5) { UnityEngine.Light obj = (UnityEngine.Light)ToLua.CheckObject(L, 1, typeof(UnityEngine.Light)); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)ToLua.CheckObject(L, 2, typeof(UnityEngine.Rendering.LightEvent)); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)ToLua.CheckObject(L, 3, typeof(UnityEngine.Rendering.CommandBuffer)); UnityEngine.Rendering.ShadowMapPass arg2 = (UnityEngine.Rendering.ShadowMapPass)ToLua.CheckObject(L, 4, typeof(UnityEngine.Rendering.ShadowMapPass)); UnityEngine.Rendering.ComputeQueueType arg3 = (UnityEngine.Rendering.ComputeQueueType)ToLua.CheckObject(L, 5, typeof(UnityEngine.Rendering.ComputeQueueType)); obj.AddCommandBufferAsync(arg0, arg1, arg2, arg3); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Light.AddCommandBufferAsync")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// Sends render commands to native code /// </summary> public static void RenderOnscreen(Noesis.View view, bool flipY, UnityEngine.Rendering.CommandBuffer commands) { // This is a workaround for a bug in Unity. When rendering nothing Unity sends us an empty MTLRenderCommandEncoder if (UnityEngine.SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal) { if (_dummyMesh == null) { _dummyMesh = new UnityEngine.Mesh(); _dummyMesh.vertices = new UnityEngine.Vector3[3]; _dummyMesh.vertices[0] = new UnityEngine.Vector3(0, 0, 0); _dummyMesh.vertices[1] = new UnityEngine.Vector3(0, 0, 0); _dummyMesh.vertices[2] = new UnityEngine.Vector3(0, 0, 0); _dummyMesh.triangles = new int[3] { 0, 2, 1 }; } if (_dummyMaterial == null) { _dummyMaterial = new UnityEngine.Material(UnityEngine.Shader.Find("UI/Default")); } commands.DrawMesh(_dummyMesh, new UnityEngine.Matrix4x4(), _dummyMaterial); } commands.IssuePluginEventAndData(_renderOnscreenCallback, flipY ? 1 : 0, view.CPtr.Handle); }
static public int SetGlobalTexture(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Rendering.RenderTargetIdentifier))) { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Rendering.RenderTargetIdentifier a2; checkValueType(l, 3, out a2); self.SetGlobalTexture(a1, a2); return(0); } else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Rendering.RenderTargetIdentifier))) { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.Rendering.RenderTargetIdentifier a2; checkValueType(l, 3, out a2); self.SetGlobalTexture(a1, a2); return(0); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int SetGlobalMatrix(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Matrix4x4))) { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Matrix4x4 a2; checkValueType(l, 3, out a2); self.SetGlobalMatrix(a1, a2); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Matrix4x4))) { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.Matrix4x4 a2; checkValueType(l, 3, out a2); self.SetGlobalMatrix(a1, a2); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
public bool SetActiveFeature(Feature value) { if (!IsFeatureAvailableInternal(value)) { Debug.LogErrorFormat("VRWorks feature " + GetFeatureName(value) + " is not supported on this hardware"); return false; } // These are _all_ currently implemented and valid feature combinations. // Trying to modify these flags will result in unpredictable behavior. uint renderFeatures = 0; if (value == Feature.MultiResolution) { renderFeatures |= kPluginExtFeatureMRSCons; } else if (value == Feature.SinglePassStereo) { renderFeatures |= kPluginExtFeatureSPSActive; } else if (value == Feature.LensMatchedShading) { renderFeatures |= kPluginExtFeatureSPSActive | kPluginExtFeatureLMSActive; } UnitySetRenderFeatureState(renderFeatures); UnityEngine.Rendering.CommandBuffer buf = new UnityEngine.Rendering.CommandBuffer(); InsertMarker(buf, PluginExtMarker.kPluginExtMarkerSetRenderFeatures, renderFeatures); Graphics.ExecuteCommandBuffer(buf); GL.Flush(); return true; }
public void Awake() { m_CommandBuffer = new UnityEngine.Rendering.CommandBuffer[(int)CB.kCB_Count]; for (int i = 0; i < (int)CB.kCB_Count; i++) { m_CommandBuffer[i] = new UnityEngine.Rendering.CommandBuffer(); } }
void Start() { if (dCam) { UnityEngine.Rendering.CommandBuffer cmd = new UnityEngine.Rendering.CommandBuffer(); cmd.SetGlobalTexture("_DEEEPTH", UnityEngine.Rendering.BuiltinRenderTextureType.Depth); GetComponent <Camera>().AddCommandBuffer(UnityEngine.Rendering.CameraEvent.AfterDepthTexture, cmd); } }
public override void IssueDrawCall_FrontDepth(AndRenderer br, CommandBuffer cb) { var renderer = GetComponent<Renderer>(); int n = m_depth_materials.Length; for (int i = 0; i < n; ++i) { cb.DrawRenderer(renderer, m_depth_materials[i], i, 1); } }
static public int DrawMesh(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 4) { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); UnityEngine.Mesh a1; checkType(l, 2, out a1); UnityEngine.Matrix4x4 a2; checkValueType(l, 3, out a2); UnityEngine.Material a3; checkType(l, 4, out a3); self.DrawMesh(a1, a2, a3); pushValue(l, true); return(1); } else if (argc == 5) { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); UnityEngine.Mesh a1; checkType(l, 2, out a1); UnityEngine.Matrix4x4 a2; checkValueType(l, 3, out a2); UnityEngine.Material a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); self.DrawMesh(a1, a2, a3, a4); pushValue(l, true); return(1); } else if (argc == 6) { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); UnityEngine.Mesh a1; checkType(l, 2, out a1); UnityEngine.Matrix4x4 a2; checkValueType(l, 3, out a2); UnityEngine.Material a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); System.Int32 a5; checkType(l, 6, out a5); self.DrawMesh(a1, a2, a3, a4, a5); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
public override void IssueDrawCall_BackStencil(LightWithStencilShadow light, CommandBuffer commands) { var renderer = GetComponent<Renderer>(); int n = m_stencil_materials.Length; for (int i = 0; i < n; ++i) { commands.DrawRenderer(renderer, m_stencil_materials[i], i, 1); } }
public CommandBuffer GetCommandBuffer() { if (m_cb == null) { m_cb = new CommandBuffer(); m_cb.name = "Hair Shadow"; GetComponent<Light>().AddCommandBuffer(LightEvent.AfterShadowMap, m_cb); } return m_cb; }
void OnDisable() { if (m_commands != null) { var cam = GetComponent<Camera>(); cam.RemoveCommandBuffer(CameraEvent.AfterLighting, m_commands); m_commands.Release(); m_commands = null; } }
/*void OnRenderImage(RenderTexture s, RenderTexture d) * { // LastTexture = s; * // s.ConvertToEquirect * StackBlit(s); * Graphics.Blit(s, d); * //LastTexture2 = d; * }*/ //static CameraEvent EventType {get {return TransparentFlag ? CameraEvent.BeforeImageEffects : CameraEvent.AfterForwardOpaque; } } void EnableLast2() { LastBuffer2 = new UnityEngine.Rendering.CommandBuffer() { name = "EMX Water Buffer" }; CheckLastTex(); LastBuffer2.Blit(BuiltinRenderTextureType.CurrentActive, LastTexture2); this_camera.AddCommandBuffer(EventType, LastBuffer2); //, UnityEngine.Rendering.ComputeQueueType.Background*/ }
static int RemoveCommandBuffer(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 3); Light obj = (Light)LuaScriptMgr.GetUnityObjectSelf(L, 1, "Light"); UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)LuaScriptMgr.GetNetObject(L, 2, typeof(UnityEngine.Rendering.LightEvent)); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)LuaScriptMgr.GetNetObject(L, 3, typeof(UnityEngine.Rendering.CommandBuffer)); obj.RemoveCommandBuffer(arg0, arg1); return(0); }
/// <summary> /// Return a new command buffer. /// This will be called the first time /// the mesh is rendered for each camera /// that renders the ocean. /// </summary> public override CommandBuffer Create(Camera cam) { CommandBuffer cmd = new CommandBuffer(); cmd.name = "Ceto DepthGrab Cmd: " + cam.name; //int width = cam.pixelWidth; //int height = cam.pixelHeight; //int scale = ResolutionToNumber(Resolution); //width /= scale; //height /= scale; RenderTextureFormat format; //screen grab currently disabled. /* if (cam.hdr) format = RenderTextureFormat.ARGBHalf; else format = RenderTextureFormat.ARGB32; //Copy screen into temporary RT. int grabID = Shader.PropertyToID("Ceto_GrabCopyTexture"); cmd.GetTemporaryRT(grabID, width, height, 0, FilterMode.Bilinear, format, RenderTextureReadWrite.Default); cmd.Blit(BuiltinRenderTextureType.CurrentActive, grabID); cmd.SetGlobalTexture(GrabName, grabID); */ if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat)) format = RenderTextureFormat.RFloat; else format = RenderTextureFormat.RHalf; //Copy depths into temporary RT. int depthID = Shader.PropertyToID("Ceto_DepthCopyTexture"); cmd.GetTemporaryRT(depthID, cam.pixelWidth, cam.pixelHeight, 0, FilterMode.Point, format, RenderTextureReadWrite.Linear); cmd.Blit(BuiltinRenderTextureType.CurrentActive, depthID, m_copyDepthMat, 0); cmd.SetGlobalTexture(DepthName, depthID); cam.AddCommandBuffer(Event, cmd); CommandData data = new CommandData(); data.command = cmd; data.width = cam.pixelWidth; data.height = cam.pixelHeight; if (m_data.ContainsKey(cam)) m_data.Remove(cam); m_data.Add(cam, data); return cmd; }
static public int get_sizeInBytes(IntPtr l) { try { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); pushValue(l, self.sizeInBytes); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public void OnEnable() { if (_commands == null) { _commands = new UnityEngine.Rendering.CommandBuffer(); } if (NoesisSettings.IsNoesisEnabled()) { RegisterFont(); } }
static public int get_name(IntPtr l) { try { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); pushValue(l, true); pushValue(l, self.name); return(2); } catch (Exception e) { return(error(l, e)); } }
public void ApplyPartials(UnityEngine.Rendering.CommandBuffer commands) { Profiler.BeginSample("Copy partials to RT"); for (int i = 0; i < UsedTextureCount; i++) { int columns = (i == UsedTextureCount - 1) ? UsedTextureLastSize : RAYS_PER_PARTIAL; commands.CopyTexture( Partials[i], 0, 0, 0, 0, Partials[i].width, columns, FinalTexture, 0, 0, 0, i * RAYS_PER_PARTIAL); } Profiler.EndSample(); }
void OnPreRender() { if (!gameObject.activeInHierarchy && !enabled) { return; } var cam = GetComponent<Camera>(); if (m_commands == null) { m_material = new Material(m_shader); m_commands = new CommandBuffer(); m_commands.name = "Rim Light"; cam.AddCommandBuffer(CameraEvent.AfterLighting, m_commands); } m_commands.Clear(); if (cam.hdr) { m_material.EnableKeyword("UNITY_HDR_ON"); m_material.SetInt("_SrcBlend", (int)BlendMode.One); m_material.SetInt("_DstBlend", (int)BlendMode.One); m_commands.SetRenderTarget(BuiltinRenderTextureType.CameraTarget); } else { m_material.DisableKeyword("UNITY_HDR_ON"); m_material.SetInt("_SrcBlend", (int)BlendMode.DstColor); m_material.SetInt("_DstBlend", (int)BlendMode.Zero); m_commands.SetRenderTarget(BuiltinRenderTextureType.GBuffer3); } m_commands.DrawMesh(m_quad, Matrix4x4.identity, m_material, 0, 0); if (m_edge_highlighting) { m_material.EnableKeyword("ENABLE_EDGE_HIGHLIGHTING"); } else { m_material.DisableKeyword("ENABLE_EDGE_HIGHLIGHTING"); } if (m_mul_smoothness) { m_material.EnableKeyword("ENABLE_SMOOTHNESS_ATTENUAION"); } else { m_material.DisableKeyword("ENABLE_SMOOTHNESS_ATTENUAION"); } m_material.SetVector("_Color", GetLinearColor()); m_material.SetVector("_Params1", new Vector4(m_fresnel_bias, m_fresnel_scale, m_fresnel_pow, m_intensity)); m_material.SetVector("_Params2", new Vector4(m_edge_intensity, m_edge_threshold, m_edge_radius, 0.0f)); }
static public int constructor(IntPtr l) { try { UnityEngine.Rendering.CommandBuffer o; o=new UnityEngine.Rendering.CommandBuffer(); pushValue(l,true); pushValue(l,o); return 2; } catch(Exception e) { return error(l,e); } }
public void AddCommandBufferAsync(CameraEvent evt, CommandBuffer buffer, ComputeQueueType queueType) { if (!Rendering.CameraEventUtils.IsValid(evt)) { throw new ArgumentException(string.Format(@"Invalid CameraEvent value ""{0}"".", (int)evt), "evt"); } if (buffer == null) { throw new NullReferenceException("buffer is null"); } AddCommandBufferAsyncImpl(evt, buffer, queueType); }
static public int Clear(IntPtr l) { try { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); self.Clear(); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public void RemoveCommandBuffer(CameraEvent evt, CommandBuffer buffer) { if (!Rendering.CameraEventUtils.IsValid(evt)) { throw new ArgumentException(string.Format(@"Invalid CameraEvent value ""{0}"".", (int)evt), "evt"); } if (buffer == null) { throw new NullReferenceException("buffer is null"); } RemoveCommandBufferImpl(evt, buffer); }
static bool Light_RemoveCommandBuffer__LightEvent__CommandBuffer(JSVCall vc, int argc) { int len = argc; if (len == 2) { UnityEngine.Rendering.LightEvent arg0 = (UnityEngine.Rendering.LightEvent)JSApi.getEnum((int)JSApi.GetType.Arg); UnityEngine.Rendering.CommandBuffer arg1 = (UnityEngine.Rendering.CommandBuffer)JSMgr.datax.getObject((int)JSApi.GetType.Arg); ((UnityEngine.Light)vc.csObj).RemoveCommandBuffer(arg0, arg1); } return(true); }
static public int constructor(IntPtr l) { try { UnityEngine.Rendering.CommandBuffer o; o = new UnityEngine.Rendering.CommandBuffer(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { UnityEngine.Rendering.CommandBuffer o; o = new UnityEngine.Rendering.CommandBuffer(); pushValue(l, o); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_name(IntPtr l) { try { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); string v; checkType(l, 2, out v); self.name = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int ReleaseTemporaryRT(IntPtr l) { try { UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.ReleaseTemporaryRT(a1); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
// public bool FillBuffer(CommandBuffer buffer) { if (r == null) { return false; } if (lastCamera == Camera.current) { for (int i = 0, imax = data.Count; i < imax; i++) { Data d = data[i]; buffer.DrawRenderer(r, d.material, d.submeshIndex); } } return true; }
public override void IssueDrawCall_DepthMask(SubRenderer br, CommandBuffer cb) { var renderer = GetComponent<Renderer>(); int n = m_mask_materials.Length; for (int i = 0; i < n; ++i) { cb.DrawRenderer(renderer, m_mask_materials[i], i, 0); cb.DrawRenderer(renderer, m_mask_materials[i], i, 1); if (br.m_enable_piercing) { cb.DrawRenderer(renderer, m_mask_materials[i], i, 2); } cb.DrawRenderer(renderer, m_mask_materials[i], i, 3); } }
internal override void UpdateTransform( CommandBuffer updateCB, bool starting ) #endif { if ( !m_initialized ) { Initialize(); return; } Profiler.BeginSample( "Solid.Update" ); if ( !starting && m_wasVisible ) m_prevLocalToWorld = m_currLocalToWorld; m_moved = true; if ( !m_owner.Overlay ) { Vector3 position = m_transform.position; Quaternion rotation = m_transform.rotation; Vector3 scale = m_transform.lossyScale; m_moved = starting || VectorChanged( position, m_lastPosition ) || RotationChanged( rotation, m_lastRotation ) || VectorChanged( scale, m_lastScale ); if ( m_moved ) { m_lastPosition = position; m_lastRotation = rotation; m_lastScale = scale; } } m_currLocalToWorld = m_transform.localToWorldMatrix; if ( starting || !m_wasVisible ) m_prevLocalToWorld = m_currLocalToWorld; m_wasVisible = m_meshRenderer.isVisible; Profiler.EndSample(); }
internal override void RenderVectors(Camera camera, CommandBuffer renderCB, float scale, Quality quality) { if (this.m_initialized && !this.m_error && this.m_meshRenderer.isVisible) { bool flag = (this.m_owner.Instance.CullingMask & 1 << this.m_obj.gameObject.layer) != 0; if (!flag || (flag && this.m_moved)) { int num = (!flag) ? 255 : this.m_owner.Instance.GenerateObjectId(this.m_obj.gameObject); Matrix4x4 value; if (this.m_obj.FixedStep) { value = this.m_owner.PrevViewProjMatrixRT * this.m_currLocalToWorld; } else { value = this.m_owner.PrevViewProjMatrixRT * this.m_prevLocalToWorld; } renderCB.SetGlobalMatrix("_AM_MATRIX_PREV_MVP", value); renderCB.SetGlobalFloat("_AM_OBJECT_ID", (float)num * 0.003921569f); renderCB.SetGlobalFloat("_AM_MOTION_SCALE", (!flag) ? 0f : scale); int num2 = (quality != Quality.Mobile) ? 2 : 0; for (int i = 0; i < this.m_sharedMaterials.Length; i++) { MotionState.MaterialDesc materialDesc = this.m_sharedMaterials[i]; int shaderPass = num2 + ((!materialDesc.coverage) ? 0 : 1); if (materialDesc.coverage) { Texture mainTexture = materialDesc.material.mainTexture; if (mainTexture != null) { materialDesc.propertyBlock.SetTexture("_MainTex", mainTexture); } if (materialDesc.cutoff) { materialDesc.propertyBlock.SetFloat("_Cutoff", materialDesc.material.GetFloat("_Cutoff")); } } renderCB.DrawMesh(this.m_mesh, this.m_transform.localToWorldMatrix, this.m_owner.Instance.SolidVectorsMaterial, i, shaderPass, materialDesc.propertyBlock); } } } }
void OnEnable() { m_outputDir.CreateDirectory(); m_quad = FrameCapturerUtils.CreateFullscreenQuad(); m_mat_copy = new Material(m_shCopy); // initialize exr context fcAPI.fcExrConfig conf = fcAPI.fcExrConfig.default_value; m_ctx = fcAPI.fcExrCreateContext(ref conf); // initialize render targets m_scratch_buffers = new RenderTexture[m_targets.Length]; for (int i = 0; i < m_scratch_buffers.Length; ++i) { var rt = m_targets[i]; m_scratch_buffers[i] = new RenderTexture(rt.width, rt.height, 0, rt.format); m_scratch_buffers[i].Create(); } // initialize command buffers { m_cb_copy = new CommandBuffer(); m_cb_copy.name = "PngOffscreenRecorder: Copy"; for (int i = 0; i < m_targets.Length; ++i) { m_cb_copy.SetRenderTarget(m_scratch_buffers[i]); m_cb_copy.SetGlobalTexture("_TmpRenderTarget", m_targets[i]); m_cb_copy.DrawMesh(m_quad, Matrix4x4.identity, m_mat_copy, 0, 3); } } }
internal override void UpdateTransform(CommandBuffer updateCB, bool starting) { if (!this.m_initialized) { this.Initialize(); return; } if (!starting && this.m_wasVisible) { this.m_prevLocalToWorld = this.m_currLocalToWorld; } bool isVisible = this.m_renderer.isVisible; if (!this.m_error && (isVisible || starting) && !starting && this.m_wasVisible) { Array.Copy(this.m_currVertices, this.m_prevVertices, this.m_targetVertexCount); } this.m_currLocalToWorld = Matrix4x4.TRS(this.m_transform.position, this.m_transform.rotation, Vector3.one); if (starting || !this.m_wasVisible) { this.m_prevLocalToWorld = this.m_currLocalToWorld; } this.m_starting = starting; this.m_wasVisible = isVisible; }
protected override void IssueDrawCall() { if (m_cb == null) { m_cb = new CommandBuffer(); m_cb.name = "MPLightRenderer"; foreach (var c in m_cameras) { if (c != null) c.AddCommandBuffer(CameraEvent.AfterLighting, m_cb); } m_mpb = new MaterialPropertyBlock(); m_mpb.AddColor("_Color", GetLinearColor()); } m_cb.Clear(); if (m_hdr) { m_cb.SetRenderTarget(BuiltinRenderTextureType.CameraTarget); } else { m_cb.SetRenderTarget(BuiltinRenderTextureType.GBuffer3); } m_mpb.SetColor("_Color", GetLinearColor()); m_mpb.SetFloat("g_size", m_size); m_mpb.SetFloat("_OcculusionStrength", m_occulusion_strength); m_mpb.SetColor("_HeatColor", GetLinearHeatColor()); m_mpb.SetFloat("_HeatThreshold", m_heat_threshold); Matrix4x4 matrix = Matrix4x4.identity; m_actual_materials.ForEach(a => { for (int i = 0; i < m_batch_count; ++i) { m_cb.DrawMesh(m_expanded_mesh, matrix, a[i], 0, 0, m_mpb); } }); }
void OnDisable() { // Destroy all the temporary resources. if (_aoMaterial != null) DestroyImmediate(_aoMaterial); _aoMaterial = null; if (_aoCommands != null) targetCamera.RemoveCommandBuffer(CameraEvent.BeforeReflections, _aoCommands); _aoCommands = null; }
void ReleaseContext() { if(m_cb != null) { m_cb.Release(); m_cb = null; } // scratch buffer is kept fcAPI.fcGuard(() => { fcAPI.fcEraseDeferredCall(m_callback); m_callback = 0; if (m_ctx.ptr != IntPtr.Zero) { fcAPI.fcMP4DestroyContext(m_ctx); m_ctx.ptr = IntPtr.Zero; } if (m_ostream.ptr != IntPtr.Zero) { fcAPI.fcDestroyStream(m_ostream); m_ostream.ptr = IntPtr.Zero; } }); }
internal virtual void RenderVectors( Camera camera, CommandBuffer renderCB, float scale, AmplifyMotion.Quality quality ) {}
private static extern void INTERNAL_CALL_ClearRenderTarget(CommandBuffer self, bool clearDepth, bool clearColor, ref Color backgroundColor, float depth);
public void ResetGPUData() { ReleaseGPUData(); m_instance_data.Resize(m_max_instances); if (m_instance_buffer != null) { m_instance_buffer.Allocate(m_max_instances); } BatchRendererUtil.CreateVertexBuffer(m_mesh, ref m_vertex_buffer, ref m_vertex_count); { Material m = m_material; if (m_enable_rotation) { m.EnableKeyword("ENABLE_INSTANCE_ROTATION"); } if (m_enable_scale) { m.EnableKeyword("ENABLE_INSTANCE_SCALE"); } if (m_enable_emission) { m.EnableKeyword("ENABLE_INSTANCE_EMISSION"); } if (m_enable_color) { m.EnableKeyword("ENABLE_INSTANCE_COLOR"); } if (m_enable_uv_offset) { m.EnableKeyword("ENABLE_INSTANCE_UVOFFSET"); } if (m_instance_buffer != null) { m.SetBuffer("g_vertices", m_vertex_buffer); m.SetBuffer("g_instance_buffer_t", m_instance_buffer.translation); m.SetBuffer("g_instance_buffer_r", m_instance_buffer.rotation); m.SetBuffer("g_instance_buffer_s", m_instance_buffer.scale); m.SetBuffer("g_instance_buffer_color", m_instance_buffer.color); m.SetBuffer("g_instance_buffer_emission", m_instance_buffer.emission); m.SetBuffer("g_instance_buffer_uv", m_instance_buffer.uv_offset); } } { m_cb = new CommandBuffer(); m_cb.name = "ProceduralGBuffer"; m_cb.DrawProcedural(Matrix4x4.identity, m_material, 0, MeshTopology.Triangles, m_vertex_count, m_max_instances); m_camera.AddCommandBuffer(CameraEvent.AfterGBuffer, m_cb); } // set default values UpdateGPUResources(); }
void OnDisable() { RemoveCommandBuffers(); if (m_cb_copy != null) { m_cb_copy.Release(); m_cb_copy = null; } for (int i = 0; i < m_scratch_buffers.Length; ++i) { m_scratch_buffers[i].Release(); } m_scratch_buffers = null; fcAPI.fcGuard(() => { EraseCallbacks(); fcAPI.fcExrDestroyContext(m_ctx); m_ctx.ptr = System.IntPtr.Zero; }); }
internal abstract void UpdateTransform( CommandBuffer updateCB, bool starting );
private static extern void INTERNAL_CALL_SetGlobalColor(CommandBuffer self, int nameID, ref Color value);
void InitializeContext() { m_num_video_frames = 0; // initialize scratch buffer UpdateScratchBuffer(); // initialize context and stream { m_mp4conf = fcAPI.fcMP4Config.default_value; m_mp4conf.video = m_captureVideo; m_mp4conf.audio = m_captureAudio; m_mp4conf.video_width = m_scratch_buffer.width; m_mp4conf.video_height = m_scratch_buffer.height; m_mp4conf.video_max_framerate = 60; m_mp4conf.video_bitrate = m_videoBitrate; m_mp4conf.audio_bitrate = m_audioBitrate; m_mp4conf.audio_sampling_rate = AudioSettings.outputSampleRate; m_mp4conf.audio_num_channels = fcAPI.fcGetNumAudioChannels(); m_ctx = fcAPI.fcMP4CreateContext(ref m_mp4conf); m_output_file = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".mp4"; m_ostream = fcAPI.fcCreateFileStream(GetOutputPath()); fcAPI.fcMP4AddOutputStream(m_ctx, m_ostream); } // initialize command buffer { int tid = Shader.PropertyToID("_TmpFrameBuffer"); m_cb = new CommandBuffer(); m_cb.name = "MP4Recorder: copy frame buffer"; m_cb.GetTemporaryRT(tid, -1, -1, 0, FilterMode.Bilinear); m_cb.Blit(BuiltinRenderTextureType.CurrentActive, tid); m_cb.SetRenderTarget(m_scratch_buffer); m_cb.DrawMesh(m_quad, Matrix4x4.identity, m_mat_copy, 0, 0); m_cb.ReleaseTemporaryRT(tid); } }
private static extern void INTERNAL_CALL_SetGlobalMatrix(CommandBuffer self, int nameID, ref Matrix4x4 value);
static int _CreateUnityEngine_Rendering_CommandBuffer(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { UnityEngine.Rendering.CommandBuffer obj = new UnityEngine.Rendering.CommandBuffer(); LuaScriptMgr.PushObject(L, obj); return 1; } else { LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.Rendering.CommandBuffer.New"); } return 0; }
private static extern void InitBuffer(CommandBuffer buf);
/// <summary> /// Create a command buffer that renders the AR screen full screen at the right time. /// </summary> /// <returns>The AR screen command buffer.</returns> public static CommandBuffer CreateARScreenCommandBuffer() { CommandBuffer buf = new CommandBuffer(); #if UNITY_EDITOR _InternResourcesForEmulation(); buf.Blit((Texture)m_emulatedARScreenTexture, BuiltinRenderTextureType.CurrentActive, m_emulationArScreenMaterial); #else IntPtr func = API.TangoUnity_getRenderTextureFunction(); buf.IssuePluginEvent(func, 0); #endif return buf; }
private static extern void INTERNAL_CALL_DrawMesh(CommandBuffer self, Mesh mesh, ref Matrix4x4 matrix, Material material, int submeshIndex, int shaderPass, MaterialPropertyBlock properties);
public override void OnDisable() { base.OnDisable(); ReleaseGPUResources(); foreach (var c in m_cameras) { if (c != null) c.RemoveCommandBuffer(CameraEvent.AfterLighting, m_cb); } m_cameras = null; if (m_cb != null) { m_cb.Release(); m_cb = null; } }
public static extern void ExecuteCommandBuffer(CommandBuffer buffer);