DrawRenderer() private méthode

private DrawRenderer ( Renderer renderer, Material material ) : void
renderer Renderer
material Material
Résultat void
 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);
     }
 }
 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);
     }
 }
Exemple #3
0
 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 DrawRenderer(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 3)
         {
             UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l);
             UnityEngine.Renderer a1;
             checkType(l, 2, out a1);
             UnityEngine.Material a2;
             checkType(l, 3, out a2);
             self.DrawRenderer(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l);
             UnityEngine.Renderer a1;
             checkType(l, 2, out a1);
             UnityEngine.Material a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             self.DrawRenderer(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 5)
         {
             UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l);
             UnityEngine.Renderer a1;
             checkType(l, 2, out a1);
             UnityEngine.Material a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Int32 a4;
             checkType(l, 5, out a4);
             self.DrawRenderer(a1, a2, a3, a4);
             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 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 void OnPreRender()
    {
        var act = gameObject.activeInHierarchy && enabled;
        if (!act)
        {
            Cleanup();
            return;
        }

        var cam = Camera.current;
        if (!cam)
            return;

        CommandBuffer buf = null;
        // Did we already add the command buffer on this camera? Nothing to do then.
        if (m_Cameras.ContainsKey(cam))
            return;

        if (!DepthMaterial)
        {
            DepthMaterial = new Material(DepthShader);
            DepthMaterial.hideFlags = HideFlags.HideAndDontSave;
        }

        buf = new CommandBuffer();
        buf.name = "Render Grass Depth Reference";
        m_Cameras[cam] = buf;

        int referenceDepthID = Shader.PropertyToID("_rdepth");
        buf.GetTemporaryRT(referenceDepthID, -1, -1, 24, FilterMode.Point, RenderTextureFormat.Depth);
        buf.SetRenderTarget(new RenderTargetIdentifier(referenceDepthID));
        buf.ClearRenderTarget(true, false, Color.white, 1);

        foreach (MeshRenderer r in GrassMeshes)
            buf.DrawRenderer(r, DepthMaterial);

        buf.SetRenderTarget(new RenderTargetIdentifier(BuiltinRenderTextureType.CameraTarget));

        buf.SetGlobalTexture("_ReferenceDepth", referenceDepthID);

        cam.AddCommandBuffer(CameraEvent.BeforeImageEffects, buf);
        Debug.Log("Add Command Buffer");
    }
Exemple #7
0
			// Fills given command buffer with this highlighter rendering commands
			public bool FillBuffer(ref CommandBuffer buffer)
			{
				if (IsDestroyed()) { return false; }

				for (int i = 0, imax = data.Count; i < imax; i++)
				{
					Data d = data[i];
					buffer.DrawRenderer(renderer, d.material, d.submeshIndex);
				}
				return true;
			}
    private void CreateCommandBuffers()
    {
        m_renderCmdBuffer = new CommandBuffer();
        m_renderCmdBuffer.name = "Highlights: Drawing Objects";

        // Drawing objects to the buffer
        m_renderCmdBuffer.SetRenderTarget(m_colorRT, BuiltinRenderTextureType.CameraTarget);
        m_renderCmdBuffer.ClearRenderTarget(false, true, Color.clear);

        var pass = m_selectionType == HighlightType.Glow ? HighlightPass.MarkStencilArea : HighlightPass.DrawSolid;
        foreach(var hObject in m_renderers)
        {
            m_renderCmdBuffer.SetGlobalColor("_Color", hObject.Value);
            m_renderCmdBuffer.SetGlobalFloat("_Cutoff",  m_cutoffValue * 0.5f);
            m_renderCmdBuffer.DrawRenderer(hObject.Key, m_highlightMaterial, 0, (int) pass);
        }
            
        foreach(var hObject in m_renderers)
        {
            m_renderCmdBuffer.SetGlobalColor("_Color", hObject.Value);
            m_renderCmdBuffer.DrawRenderer(hObject.Key, m_highlightMaterial, 0, (int) HighlightPass.ExtrudeOutline);
        }

        var drawEvent = GetCameraDrawEvent();
        m_camera.AddCommandBuffer(drawEvent, m_renderCmdBuffer);
    }
    private void drawOverrideEyeMat(CommandBuffer buf, OverrideEye eyeObj, int pass)
    {
        if(eyeObj.Mr != null)
        {
            MeshFilter _mf = eyeObj.GetComponent<MeshFilter>();

            for(int _i = 0; _i < _mf.sharedMesh.subMeshCount; ++_i)
            {
                buf.DrawMesh(_mf.sharedMesh, eyeObj.gameObject.transform.localToWorldMatrix, this.m_overrideEyeMat, _i, pass);
            }
        }
        else if(eyeObj.SkinMr != null)
        {
            for(int _i = 0; _i < eyeObj.SkinMr.sharedMesh.subMeshCount; ++_i)
            {
                buf.DrawRenderer(eyeObj.SkinMr, this.m_overrideEyeMat, _i, pass);
            }
        }
    }
    private void drawSlefMat(CommandBuffer buf, OverrideEye eyeObj, int pass)
    {
        if(eyeObj.Mr != null)
        {
            MeshFilter _mf = eyeObj.GetComponent<MeshFilter>();

            for(int _i = 0; _i < _mf.sharedMesh.subMeshCount; ++_i)
            {
                buf.DrawMesh(_mf.sharedMesh, eyeObj.gameObject.transform.localToWorldMatrix, eyeObj.Materials[_i], _i, pass);
            }
        }
        else if(eyeObj.SkinMr != null)
        {
            for(int _i = 0; _i < eyeObj.SkinMr.sharedMesh.subMeshCount; ++_i)
            {
                eyeObj.Materials[_i].EnableKeyword("DIRLIGHTMAP_OFF");
                eyeObj.Materials[_i].EnableKeyword("DYNAMICLIGHTMAP_OFF");
                buf.DrawRenderer(eyeObj.SkinMr, eyeObj.Materials[_i], _i, pass);
            }
        }
    }