Ejemplo n.º 1
0
    /// </inheritdoc>
    public override CommandBuffer TryRenderSplats(Queue <QueuedSplat> splatsToRender, out List <QueuedSplat> renderedSplats)
    {
        renderedSplats = new List <QueuedSplat>();
        QueuedSplat splat = splatsToRender.Dequeue();

        renderedSplats.Add(splat);

        // Set Shader Variables
        SplatSO data = splat.splatData;

        SplatSO.Frame frame = data.Frames[splat.frame];

        splatMat.SetTexture("_Previous", splatMap);
        splatMat.SetTexture("_PaintMask", paintMask);
        splatMat.SetTexture("_Mask", frame.mask);
        splatMat.SetTexture("_Normal", frame.normal);
        splatMat.SetVector("_Anchor", data.Anchor);
        splatMat.SetVector("_Rotation", data.CalculateRotation(splat.projectileDir));
        splatMat.SetVector("_Position", splat.worldPos);

        // Set Up Command Buffer
        CommandBuffer splatBuffer = new CommandBuffer();

        splatBuffer.GetTemporaryRT(Shader.PropertyToID("_TEMPORARY"), dims.Width, dims.Height);
        splatBuffer.SetRenderTarget(Shader.PropertyToID("_TEMPORARY"));
        splatBuffer.DrawRenderer(renderer, splatMat);
        splatBuffer.Blit(Shader.PropertyToID("_TEMPORARY"), splatMap);
        return(splatBuffer);
    }
Ejemplo n.º 2
0
    /// </inheritdoc>
    public override CommandBuffer TryRenderSplats(Queue <QueuedSplat> splatsToRender, out List <QueuedSplat> renderedSplats)
    {
        List <Texture2D> masks     = new List <Texture2D>();
        List <Texture2D> normals   = new List <Texture2D>();
        List <Vector4>   anchors   = new List <Vector4>(); // must be vec4 in order to set array
        List <Vector4>   rotations = new List <Vector4>(); // must be vec4 in order to set array
        List <Vector4>   positions = new List <Vector4>(); // must be vec4 in order to set array

        renderedSplats = new List <QueuedSplat>();
        int count = 0;

        while (splatsToRender.Count > 0 && count++ < GoreManager.Instance.NumSplatsToRender)
        {
            // Queue Up Data
            QueuedSplat   splat = splatsToRender.Dequeue();
            SplatSO       data  = splat.splatData;
            SplatSO.Frame frame = data.Frames[splat.frame];
            masks.Add(frame.mask);
            normals.Add(frame.normal);
            anchors.Add(data.Anchor);
            rotations.Add(data.CalculateRotation(splat.projectileDir));
            positions.Add(splat.worldPos);

            renderedSplats.Add(splat);
        }

        // Set Shader Variables
        splatMat.SetTexture("_Previous", splatMap);
        splatMat.SetTexture("_PaintMask", paintMask);
        splatMat.SetTexture("_Masks", CreateTextureArray(masks, ref this.masks));
        splatMat.SetTexture("_Normals", CreateTextureArray(normals, ref this.normals));
        splatMat.SetVectorArray("_Anchors", anchors);
        splatMat.SetVectorArray("_Rotations", rotations);
        splatMat.SetVectorArray("_Positions", positions);
        splatMat.SetInt("_Count", count);

        // Set Up Command Buffer
        CommandBuffer splatBuffer = new CommandBuffer();

        splatBuffer.GetTemporaryRT(Shader.PropertyToID("_TEMPORARY"), dims.Width, dims.Height);
        splatBuffer.SetRenderTarget(Shader.PropertyToID("_TEMPORARY"));
        splatBuffer.DrawRenderer(renderer, splatMat);
        splatBuffer.Blit(Shader.PropertyToID("_TEMPORARY"), splatMap);
        return(splatBuffer);
    }