Exemplo n.º 1
0
    public ImposterTexture getRenderTexture(ImposterProxy newOwner, int size)
    {
        //Reuse Texture?
        for(int i=0; i<freeImposterTextures.Count; i++)
        {
            ImposterTexture texture = freeImposterTextures[i];

            if (texture.size == size)
            {
                freeImposterTextures.Remove(texture);
                texture.owner = newOwner;

                return texture;
            }
        }

        //Create new Texture
        RenderTexture renderTexture = new RenderTexture(size, size, 16);
        renderTexture.antiAliasing = antialiasing;

        ImposterTexture imposterTexture = new ImposterTexture();
        imposterTexture.owner = newOwner;
        imposterTexture.size = size;
        imposterTexture.createdTime = imposterTexture.lastUsedTime = Time.frameCount;
        imposterTexture.texture = renderTexture;
        imposterTextures.Add(imposterTexture);

        textureMemory += imposterTexture.getMemoryAmount();

        return imposterTexture;
    }
Exemplo n.º 2
0
    private void createProxy()
    {
        GameObject proxyGo = (GameObject)Instantiate(ImposterManager.instance.proxyPrefab.gameObject, transform.position, transform.rotation);
        proxyGo.transform.SetParent(transform);
        proxyGo.transform.localScale = new Vector3(1.0f / transform.lossyScale.x, 1.0f / transform.lossyScale.y, 1.0f / transform.lossyScale.z);

        proxyGo.SetActive(true);
        proxy = proxyGo.GetComponent<ImposterProxy>();
        proxy.shadowZOffset = shadowZOffset;
        proxy.zOffset = zOffset;
        proxy.shadowDivider = 1 << shadowDownSampling;
        proxy.maxShadowDistance = maxShadowDistance;
        proxy.Init(renderers, castShadow && ImposterManager.instance.castShadow);
    }