void Awake()
 {
     colorCorrectionLookup = Camera.main.GetComponent <ColorCorrectionLookup>();
     if (colorCorrectionLookup == null)
     {
         Debug.LogError("Can't aply color correction effect. The games camera does not have a color correction component attached.");
     }
 }
Esempio n. 2
0
 public override void OnInit()
 {
     cameraGo     = Camera.main.gameObject;
     cameraAnime  = cameraGo.GetComponent <Animator>();
     followRole   = cameraGo.GetComponent <FollowRole>();
     tiltShift    = cameraGo.GetComponent <TiltShift>();
     vigChrAbe    = cameraGo.GetComponent <VignetteAndChromaticAberration>();
     clrCorLookup = cameraGo.GetComponent <ColorCorrectionLookup>();
     rain         = GameObject.FindGameObjectWithTag("EffectRain");
 }
Esempio n. 3
0
    public static void ApplyBrightness()
    {
        Texture2D temp2DTex;

        if (Options.colorcorrection == 1)
        {
            temp2DTex = (Resources.Load("wmlut") as Texture2D);
        }
        else
        {
            temp2DTex = (Resources.Load("deflut") as Texture2D);
        }
        ColorCorrectionLookup colorCorrectionLookup = (ColorCorrectionLookup)UnityEngine.Object.FindObjectOfType(typeof(ColorCorrectionLookup));

        if (colorCorrectionLookup)
        {
            colorCorrectionLookup.Convert(temp2DTex, Options.brightness, Options.gamma);
        }
    }
Esempio n. 4
0
    void Start()
    {
        playpal  = WADReader.GetPlaypal();
        colormap = WADReader.GetColormap();

        LUTTexture            = new Texture3D(textureSize, textureSize, textureSize, TextureFormat.RGB24, false);
        LUTTexture.filterMode = FilterMode.Point;
        Color[] colors = new Color[textureSize * textureSize * textureSize];
        for (int r = 0; r < textureSize; r++)
        {
            for (int g = 0; g < textureSize; g++)
            {
                for (int b = 0; b < textureSize; b++)
                {
                    Vector4 source = new Vector4(r, g, b) / textureSize;
                    Vector4 color  = Vector4.zero;
                    for (int i = 0; i < playpal.GetLength(1) / 3; i++)
                    {
                        Vector4 target = new Vector4(playpal[0, i * 3], playpal[0, i * 3 + 1], playpal[0, i * 3 + 2]) / 255;
                        if (Vector4.Distance(source, target) < Vector4.Distance(source, color))
                        {
                            color = target;
                        }
                    }
                    color.w = 1;
                    colors[r + g * textureSize + b * textureSize * textureSize] = color;
                }
            }
        }
        LUTTexture.SetPixels(colors);
        LUTTexture.Apply();

        ColorCorrectionLookup lookup = GetComponent <ColorCorrectionLookup>();

        lookup.converted3DLut = LUTTexture;
    }
Esempio n. 5
0
    protected override void OnPrefabInit()
    {
        Util.Reset(base.transform);
        base.transform.SetLocalPosition(new Vector3(Grid.WidthInMeters / 2f, Grid.HeightInMeters / 2f, -100f));
        targetOrthographicSize = maxOrthographicSize;
        Instance = this;
        DisableUserCameraControl = false;
        baseCamera           = CopyCamera(Camera.main, "baseCamera");
        mrt                  = baseCamera.gameObject.AddComponent <MultipleRenderTarget>();
        mrt.onSetupComplete += OnMRTSetupComplete;
        baseCamera.gameObject.AddComponent <LightBufferCompositor>();
        baseCamera.transparencySortMode = TransparencySortMode.Orthographic;
        baseCamera.transform.parent     = base.transform;
        Util.Reset(baseCamera.transform);
        int mask  = LayerMask.GetMask("PlaceWithDepth", "Overlay");
        int mask2 = LayerMask.GetMask("Construction");

        cameras.Add(baseCamera);
        baseCamera.cullingMask &= ~mask;
        baseCamera.cullingMask |= mask2;
        baseCamera.tag          = "Untagged";
        baseCamera.gameObject.AddComponent <CameraRenderTexture>().TextureName = "_LitTex";
        infraredCamera                  = CopyCamera(baseCamera, "Infrared");
        infraredCamera.cullingMask      = 0;
        infraredCamera.clearFlags       = CameraClearFlags.Color;
        infraredCamera.depth            = baseCamera.depth - 1f;
        infraredCamera.transform.parent = base.transform;
        infraredCamera.gameObject.AddComponent <Infrared>();
        simOverlayCamera                  = CopyCamera(baseCamera, "SimOverlayCamera");
        simOverlayCamera.cullingMask      = LayerMask.GetMask("SimDebugView");
        simOverlayCamera.clearFlags       = CameraClearFlags.Color;
        simOverlayCamera.depth            = baseCamera.depth + 1f;
        simOverlayCamera.transform.parent = base.transform;
        simOverlayCamera.gameObject.AddComponent <CameraRenderTexture>().TextureName = "_SimDebugViewTex";
        overlayCamera                  = Camera.main;
        overlayCamera.name             = "Overlay";
        overlayCamera.cullingMask      = (mask | mask2);
        overlayCamera.clearFlags       = CameraClearFlags.Nothing;
        overlayCamera.transform.parent = base.transform;
        overlayCamera.depth            = baseCamera.depth + 3f;
        overlayCamera.transform.SetLocalPosition(Vector3.zero);
        overlayCamera.transform.localRotation = Quaternion.identity;
        overlayCamera.renderingPath           = RenderingPath.Forward;
        overlayCamera.allowHDR = false;
        overlayCamera.tag      = "Untagged";
        CameraReferenceTexture cameraReferenceTexture = overlayCamera.gameObject.AddComponent <CameraReferenceTexture>();

        cameraReferenceTexture.referenceCamera = baseCamera;
        ColorCorrectionLookup component = overlayCamera.GetComponent <ColorCorrectionLookup>();

        component.Convert(dayColourCube, string.Empty);
        component.Convert2(nightColourCube, string.Empty);
        cameras.Add(overlayCamera);
        lightBufferCamera                  = CopyCamera(overlayCamera, "Light Buffer");
        lightBufferCamera.clearFlags       = CameraClearFlags.Color;
        lightBufferCamera.cullingMask      = LayerMask.GetMask("Lights");
        lightBufferCamera.depth            = baseCamera.depth - 1f;
        lightBufferCamera.transform.parent = base.transform;
        lightBufferCamera.transform.SetLocalPosition(Vector3.zero);
        lightBufferCamera.rect = new Rect(0f, 0f, 1f, 1f);
        LightBuffer lightBuffer = lightBufferCamera.gameObject.AddComponent <LightBuffer>();

        lightBuffer.Material       = LightBufferMaterial;
        lightBuffer.CircleMaterial = LightCircleOverlay;
        lightBuffer.ConeMaterial   = LightConeOverlay;
        overlayNoDepthCamera       = CopyCamera(overlayCamera, "overlayNoDepth");
        int mask3 = LayerMask.GetMask("Overlay", "Place");

        baseCamera.cullingMask               &= ~mask3;
        overlayNoDepthCamera.clearFlags       = CameraClearFlags.Depth;
        overlayNoDepthCamera.cullingMask      = mask3;
        overlayNoDepthCamera.transform.parent = base.transform;
        overlayNoDepthCamera.transform.SetLocalPosition(Vector3.zero);
        overlayNoDepthCamera.depth = baseCamera.depth + 4f;
        overlayNoDepthCamera.tag   = "MainCamera";
        overlayNoDepthCamera.gameObject.AddComponent <NavPathDrawer>();
        uiCamera                  = CopyCamera(overlayCamera, "uiCamera");
        uiCamera.clearFlags       = CameraClearFlags.Depth;
        uiCamera.cullingMask      = LayerMask.GetMask("UI");
        uiCamera.transform.parent = base.transform;
        uiCamera.transform.SetLocalPosition(Vector3.zero);
        uiCamera.depth              = baseCamera.depth + 5f;
        timelapseFreezeCamera       = CopyCamera(uiCamera, "timelapseFreezeCamera");
        timelapseFreezeCamera.depth = uiCamera.depth + 3f;
        timelapseFreezeCamera.gameObject.AddComponent <FillRenderTargetEffect>();
        timelapseFreezeCamera.enabled = false;
        Camera     camera     = CloneCamera(overlayCamera, "timelapseCamera");
        Timelapser timelapser = camera.gameObject.AddComponent <Timelapser>();

        camera.transparencySortMode = TransparencySortMode.Orthographic;
        Game.Instance.timelapser    = timelapser;
        GameScreenManager.Instance.SetCamera(GameScreenManager.UIRenderTarget.ScreenSpaceCamera, uiCamera);
        GameScreenManager.Instance.SetCamera(GameScreenManager.UIRenderTarget.WorldSpace, uiCamera);
        GameScreenManager.Instance.SetCamera(GameScreenManager.UIRenderTarget.ScreenshotModeCamera, uiCamera);
        infoText = GameScreenManager.Instance.screenshotModeCanvas.GetComponentInChildren <LocText>();
    }