Tuesday, April 16, 2024
HomeSample Page

Sample Page Title


enter image description hereI’m engaged on a personality generator that creates thumbnail sprites for every character. I’m utilizing a separate digicam that renders to a RenderTexture, which is used to create a sprite utilizing ReadPixels(). The ensuing sprites seem to have their colours multiplied. I’m stumped. I’ve messed round extensively with lighting and ambient lighting. Right now the one lighting is ambient. I’ve tried varied colour codecs for the RenderTexture. I’ve tried assigning completely different supplies to the ensuing sprite, together with the default.

Here is the related code, which generates the sprite:

IEnumerator GeneratePortrait(Npc npc)
    {
        Texture2D tex = new Texture2D(512, 512);
        RenderTexture.energetic = rt; //assigned at Start()
        tex.ReadPixels(new Rect(0, 0, tex.width, tex.peak), 0, 0);
        yield return null;
        tex.Apply();
        RenderTexture.energetic = null;
        npc.sprite = Sprite.Create(tex, new Rect(0, 0, 512, 512), new Vector2(256, 256));
    }

Update I attempted altering the road that creates the feel to
Texture2D tex = new Texture2D(512, 512, TextureFormat.ARGB4444, false);
This should not work; the format of the RenderTexture is the default for the goal platform R8G8B8A8_UNORM however the result’s a lot better. Still some multiplication taking place, however acceptably shut.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments