Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Realtime compression to get camera artifacts.

Discussion in 'Shaders' started by Cactus_on_Fire, May 21, 2018.

  1. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Hello.

    Is there a way to compress what the unity camera sees in realtime? I guess it can be achieved by getting a render texture from camera, exporting it, then re-importing it with lowest compression settings but that would heavily drop the FPS.

    So instead is there a way to compress the raw image from camera directly ? I only want the lowest and fastest compression settings to get those camera artifacts that you see in actual videos.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,256
  3. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Oh that's pretty cool thanks. I remember Keijiro's Kino Bokeh depth of field effect. His stuff is awesome :)
     
  4. pixelrunner314

    pixelrunner314

    Joined:
    Dec 29, 2020
    Posts:
    1
    What about other effects than the datamosh effect? I'm trying to make a horror game about liminal spaces (kinda like the backrooms), and I want to make it look like it is a video/image being recorded by a medium quality camera.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,256
    There are a ton of "glitch" or "vhs" post processing assets on the store. It really depends on what kind of effect you're looking for. It's kind of all about faking whatever artifact you're looking to have with noise textures or pseudo random functions. If you want to be really fancy you can recreate some of the artifacts of video compression by actually doing some elements of that compression in a shader. Things like converting the rendered color to YUV 4:2:0 (or worse) and back to RGB to get color resolution artifacts. Might even offset the YUV channels to simulate a bad analog signal. Etc.
     
  6. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    I did get to somewhere by making the UVs mosaic depending on how detailed the RenderTexture is so that the brightness and colors closer to each other appear compressed as you'd see in a video artifact.

    Original scene / The compression effect.

    Bitrate Artifacts Effect.jpg
     
    cs5947 and bgolus like this.
  7. cs5947

    cs5947

    Joined:
    Feb 6, 2021
    Posts:
    6
    how do you make the uvs mosaic? sorry, i'm really new to unity and just wondering where and how to do that, whether it's the render texture itself, shader code or something else
     
  8. cs5947

    cs5947

    Joined:
    Feb 6, 2021
    Posts:
    6
    oh and your example looks really good too
     
    Cactus_on_Fire likes this.