Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
What could be some ways to fake realtime global illumination from an emissive render texture?

I'm trying to make a movie theater with a video player screen, and since unity Enlighten support is heading out I'm trying to find an alternative. also this is for mobile vr headsets so full realtime gi isn't really the best option anyway.

This is what I have so far. But its very basic and since unity doesn't support realtime area lights the light doesn't really look like its from the screen.

Any help would be greatly appreciated!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScreenLight : MonoBehaviour
{
    public Light[] sLights;
    public Material[] materials;
    public RenderTexture rt;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        // Remember currently active render texture
        RenderTexture currentActiveRT = RenderTexture.active;

        // Set the supplied RenderTexture as the active one
        RenderTexture.active = rt;

        // Create a new Texture2D and read the RenderTexture image into it
        Texture2D tex = new Texture2D(rt.width, rt.height);
        tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);

        // Restore previously active render texture
        RenderTexture.active = currentActiveRT;

        var texColors = tex.GetPixels32();
        var total = texColors.Length;
        var r = 0; var g = 0; var b = 0;
        for (var i = 0; i < total; i++)
        {
            r += texColors[i].r;
            g += texColors[i].g;
            b += texColors[i].b;
        }

        // Gets average texture color
        Color averageColor = new Color32((byte)(r / total), (byte)(g / total), (byte)(b / total), 0);


        // Updates lights and materials to the average texture color
        foreach (Material mat in materials)
        {
            mat.SetColor("_EmissionColor", averageColor);
        }

        foreach (Light l in sLights)
        {
            l.color = averageColor;
        }
    }
}
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda