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
  3. Dismiss Notice

[RELEASED] Ultimate CRT - Cathode Ray Tube display simulation

Discussion in 'Assets and Asset Store' started by b005t3r, Feb 4, 2017.

  1. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Hi!

    First of all, thanks a lot for, it looks amazing :D
    I am having this error though:

    ullReferenceException: Object reference not set to an instance of an object
    BaseCRTEffect.OnPostRender () (at Assets/UltimateCRT/Scripts/BaseCRTEffect.cs:577)

    I got it on the latest Unity 5.6 as well as Unity 2017 (the most recent one too)

    I use CRT on a camera with a render texture.
    If I set the values back to the default one the error disappears but it looks weird: something like a green blob sort of thing.

    Any clue?

    Cheers!
     
  2. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    Hi, thanks for reporting. I never experienced anything like that, so it would be great if you prepared an example scene and sent it to me so I could reproduce the issue on my side an fix it.
     
  3. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
  4. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    Sorry for the late reply. Haven't had the time to look at it yet, but I'll try to find some this week.
     
  5. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Hey! Did you have a chance to have a look at the issue?
     
  6. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    Sorry, had a busy week, I'll try to give it a look tomorrow and get back to you.
     
  7. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    OK, I gave it a quick look.

    First things first: you didn't add the shaders which came with the package to the project (look them up in UltimateCRT/Resources). Your secondary camera is set not to clear the background, which might cause strange green blob that you described (didn't happen to me however).

    As for the bug, a quick fix: edit BaseCRTEffect.cs and change line 577 from this:

    Code (csharp):
    1. targetTexture.DiscardContents();
    to this:

    Code (csharp):
    1. if(targetTexture != null)
    2.     targetTexture.DiscardContents();
    I still need to find the cause of this error, but this fix should get you going without any problems for now.

    Let me know if that helped.
     
  8. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    I will double check but I tested that and it seems that the shader is not animating the texture anymore. I will give it a second try though, thanks :)
     
  9. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    I'm not sure what that means... Just gave it another go and it looks like everything works fine.

    If you encounter any new issues, let me know of course.
     
  10. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Thanks a lot, will do. I actually need to wait a bit before I update to Unity 2017.1
     
  11. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Hello!

    I finally found the time to upgrade to Unity 2017.1!
    Unfortunately, I still have the issues with Ultimate CRT :(
    I did a small project to illustrate what is happening:
    https://drive.google.com/file/d/0BxbMMxq8Kj91WVUycWZpMjFEX1E/view?usp=sharing
    Basically it renders a weird green thingy :/

    Would you be able to fix it? It is quite important since the game I am working on needs it ASAP :)

    Thanks,
    -Tim
     
  12. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    Thanks for the project. I'll give it a look during the weekend and provide a fix.
     
  13. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Thanks a lot :)
    Have a good weekend
     
  14. GlitchInTheMatrix

    GlitchInTheMatrix

    Joined:
    Apr 12, 2010
    Posts:
    285
    Hi b005t3r, I just bought the post effect, I really love it. great job!

    I having a little problem with it. Seems like the filters don't affect the default UI material. In Unity the one name UI/Default.

    It is automatically used when you make a bitmap font. so all the text in my game still not affected :(

    Any tricks for it?

    thanks
     
  15. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    Have you tried setting this on your Canvas? Should fix it :)

    upload_2017-9-27_17-21-33.png
     
  16. zapposh

    zapposh

    Joined:
    Nov 12, 2016
    Posts:
    117
    Hi,

    I'm using the CRT plugin for Windows UWP builds.

    The screen turns all pink (is the builds as well as in Unity, when in DX11 graphics emulation, which is what UWP uses).
    Does the shader work with DX11?

    A normal standalone Windows build does not have this problem. It also works fine on iOS and Android.

    crt.png
     
  17. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    Never tested it with UWP builds, but it could be a problem with the build itself. If there's anything specific that has to be done, please prepare an example project and I'll test it and see if there's anything I can do about it.
     
  18. E_Urban

    E_Urban

    Joined:
    Sep 16, 2014
    Posts:
    8
    I found a fix for the strange green blob when using render textures. On the "CRT Effect" component set "Texture Scaling" to "Off".

    You will also find that adjusting the aspect ratio of the scene's main camera will affect the scaling of the CRT Effect on the render texture. I found I had to manually set the aspect ratio of the camera that's making the renderTexture via script. Set the aspect to equal the aspect of the render texture destination. Hope that helps.
    Code (CSharp):
    1. Camera cam = GetComponent<Camera>();
    2.         cam.aspect = 16f / 9f;
     
    b005t3r likes this.
  19. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    @InvincibleCat, check out @E_Urban's solution - should help you as well.
     
  20. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Sounds good,
    I will check that out!
    Thanks @E_Urban
     
  21. GrandTheftEx

    GrandTheftEx

    Joined:
    Jan 14, 2013
    Posts:
    32
    Hi
    Łukasz,

    I'm interested in your asset but I'm not too good with technical work. I have a free asset for making 3d models look pixelated (I think its called PixelRender by Kode80) which requires me to attach a shader to my 3d model, this is then tied into a second camera in my scene. So if this shader is applied to a model does this mean it won't be able to also function with your asset? As the slot will already be taken? Is there any chance I could look at the documentation for the asset to get an idea of whether or not I'll be capable of implementing it with what I've already got?

    Cheers,
    Louis
     
  22. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    There are two versions of the shader in the package - one working as a standard Image Effect which means it can be combined with other Image Effects (at an expense of the performance) and another standalone one, which can't be combined with other effects. If your camera shader is an Image Effect, the former should work just fine.

    I'm also attaching the docs, so you can get a better understanding of how it works.

    PS. A bold choice of font :)
     

    Attached Files:

  23. gianmixx

    gianmixx

    Joined:
    May 11, 2018
    Posts:
    1
    Hi I purchased the crt simulator only for use with my old 2d games. Please could you help me to do this? I never used unity, so I'm totally noob about that!
     
  24. Lucarma79

    Lucarma79

    Joined:
    Feb 14, 2015
    Posts:
    5
    Hi all,
    I have some problem to setting up this plugin. In my game I want to apply this filter also to the UI, that is in a canvas gameobject. I have an orthographic camera, that see the game, and the canvas gameobject that contains the Ux.
    Actually I'm using unity 2018.2
    Any ideas?
     
  25. Lucarma79

    Lucarma79

    Joined:
    Feb 14, 2015
    Posts:
    5
    Thank you, this solve the problem
     
  26. Samacvuk

    Samacvuk

    Joined:
    Jan 8, 2017
    Posts:
    30
    If for some reason you have a multi-camera setup and some of it is not displaying (I had the same problem) here is a troubleshooting list of things I had to fix:
    1. Check the cameras Depth Buffer, the ultimate CRT camera has the lowest Depth Buffer (of 0), in Unity the lower a depth buffer the sooner the camera is rendered, this makes it simple to configure the rest.
    2. Only the lowest camera in the depth buffer (if you followed the first note, the Ultimate CRT camera) can clear the scene using solid color (any color) with an alpha of 0f preferably.
    3. Check the Rendering Path of your project and each camera individually to see if it fits how you are developing your game.
    4. If you are using the Standalone version of the Ultimate CRT other image effects can prevent the camera from rendering.
    Hope that can help someone else.
     
    b005t3r likes this.
  27. zephyr7

    zephyr7

    Joined:
    Oct 12, 2013
    Posts:
    16
    Hey,
    the effect is wonderful visually and I'd love to use it in my project.
    However I can't seem to be able to use it together with the current Unity Native PostProcessing Stack in Unity2018.3.
    Can you please help?

    Unless I'm doing some sort of stupid user error here, neither Ultimate CRT no Ultimate CRT Standalone seem to work together with the current Post Processing Stack from the Package Manager, only one of these effects can render at a time. Is there any way to get both? Preferably without additonal Cameras/RenderTexture workarounds if possible.

    Maybe it would even be possible to hook this up to the Post FX Stack? https://github.com/Unity-Technologies/PostProcessing/wiki/Writing-Custom-Effects

    Thanks in advance!
     
  28. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    I'm afraid the answer is: not really. I haven't followed what's been going on in Unity for the past years, so I don't really know what the Post Processing Stack is in the latest release. It looks like I'd have to rewrite the whole thing to make it use the new APIs, which is something I don't really have time for. I just skimmed over the new stuff, but it should be possible to create a simple wrapper for Ultimate CRT, so maybe this is something worth experimenting with? And it shouldn't be that hard - create a simple wrapper holding an instance of UltimateCRT filter and call its methods in Render(). Looks like it should work.
     
  29. zephyr7

    zephyr7

    Joined:
    Oct 12, 2013
    Posts:
    16
    Thank you for your reply!
    Can you please explain the wrapper idea in a bit more detail? I'm not really into shaders so I'm a little lost here.

    "holding an instance of UltimateCRT filter "
    >Which one? The BaseCRTEffect, CRTEffect or StandaloneCRTEffect script?

    "call its methods in Render()"
    >Which methods do have to be called at what point in time exactly? As I understand it Camera.Render() isn't an event that gets sent to a Camera's components but an event on the camera that you have to call yourself on a disabled Camera, or did you mean one of these: OnPreCull, OnPreRender or OnPostRender?
     
  30. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    You won't need to implement any shaders, the whole idea is to simply call StandaloneCRTEffect's methods, but I see they are currently done as event, as you pointed out, so probably altering those scripts will be required as well.

    You can also experiment with simply having a texture you'd render the whole screen to (in the wrapper) and passing that texture to the filter, because all the filter does really is processing a texture.
     
  31. erikhallgren

    erikhallgren

    Joined:
    Feb 2, 2015
    Posts:
    9
    Hi, this asset seems awesome and it does the job in all areas but one. Using the standalone version it seems to be unable to render 3d objects which just aren't displayed. Since that version is more performant it would ofc be nice to use that one, any idea why this is happening?
     
    Last edited: Apr 7, 2019
  32. markzorn

    markzorn

    Joined:
    Oct 6, 2016
    Posts:
    12
    Hello - I am trying to use the CRTEffect component on a camera that isn't fullscreen - say by setting the width and height of the viewport rect to 0.5. However, as soon as the component is enabled, it goes back to full screen and ignores those settings. Is there anything I can do to apply the effect to a camera that only takes up a portion of the screen?
     
  33. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    I think maybe your rendering order has to be altered, so those objects are rendered to the camera's texture before the shader kicks in.

    I never tested that, I'm afraid, so it might not be supported. Shader processes entire texture that camera uses for rendering. I'm pretty sure however, you can alter your setup a bit OR hack the effect, so it only processes a given region of your texture.
     
    Last edited: May 3, 2019
  34. erikhallgren

    erikhallgren

    Joined:
    Feb 2, 2015
    Posts:
    9
    For anyone running into this in the future, this was the issue for me, thank you!
     
    b005t3r likes this.
  35. Samacvuk

    Samacvuk

    Joined:
    Jan 8, 2017
    Posts:
    30
    How can I make this work with the new Lightweight Rendering Pipeline ?
     
  36. Doomlaser

    Doomlaser

    Joined:
    Dec 9, 2013
    Posts:
    22
    Hey, I bought this asset to use on just my UI camera. I have it only applied to the UI camera, and I have the UI render to a texture on top of my game, with a shader on it that renders black as alpha. Despite Ultimate CRT set to render to my UI texture, it appears to take over the rendering of the screen anyway...? Is there any way to bypass this? I _only_ want this to render to my UI camera texture.
     
  37. JohnWizard

    JohnWizard

    Joined:
    Feb 3, 2017
    Posts:
    11
    Hello! Does this asset still work with the latest Unity version? (2019.2) Thank you.
     
  38. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    Is this still supported?
     
  39. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    The plugin is basically complete as it is, so there's not much to support. I doesn't work with the new rendering pipeline though, so this new feature is not supported unfortunately.
     
    Zebbi likes this.
  40. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    I'm trying to simulate this effect, the Blargg NTSC RF cable shader from Fusion emulator:

    Here's the same shot without the shader:

    Is it possible to get the same look as the first picture with this shader?
     
  41. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    Yes, I think something close to that should be possible. The only thing I think might not be exact is how the above image is blurred, it looks like it's only (or more) blurred in the horizontal direction, not vertically, so that's one thing you won't be able to adjust. However, if you feel like it, you could modify the blur pass in the shader to make it work only horizontally and that should do the trick (it's a simple gaussian blur, nothing fancy, really).

    Also, have you seen this?
    I tried to explain what can be done with this effect there.
     
    Zebbi likes this.
  42. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    i
    Unfortunately, I am not great with shader programming so I'm not sure how I'd modify the blur to be horizontal?
     
  43. b005t3r

    b005t3r

    Joined:
    Dec 29, 2016
    Posts:
    46
    This part is actually super simple, it looks like this:

    Code (CSharp):
    1.  
    2.                 half4 blur(half2 uv, half sigma) {
    3.                 half3 final     = half3(0.0, 0.0, 0.0);
    4.  
    5.                 float cornerWeight     = blurKernel.x * blurKernel.x;
    6.                 float edgeWeight    = blurKernel.x * blurKernel.y;
    7.                 float centerWeight    = blurKernel.y * blurKernel.y;
    8.  
    9.                 final += tex2D(_MainTex, uv + float2(-pixelSizeX,    -pixelSizeY)).rgb * cornerWeight;
    10.                 final += tex2D(_MainTex, uv + float2(0,             -pixelSizeY)).rgb * edgeWeight;
    11.                 final += tex2D(_MainTex, uv + float2(pixelSizeX,    -pixelSizeY)).rgb * cornerWeight;
    12.  
    13.                 final += tex2D(_MainTex, uv + float2(-pixelSizeX,    0)).rgb * edgeWeight;
    14.                 final += tex2D(_MainTex, uv + float2(0,            0)).rgb * centerWeight;
    15.                 final += tex2D(_MainTex, uv + float2(pixelSizeX,    0)).rgb * edgeWeight;
    16.  
    17.                 final += tex2D(_MainTex, uv + float2(-pixelSizeX,    pixelSizeY)).rgb * cornerWeight;
    18.                 final += tex2D(_MainTex, uv + float2(0,                pixelSizeY)).rgb * edgeWeight;
    19.                 final += tex2D(_MainTex, uv + float2(pixelSizeX,    pixelSizeY)).rgb * cornerWeight;
    20.  
    21.                 return half4(final / half3(blurZ, blurZ, blurZ), 1.0);
    22.             }
    23.  
    It takes 9 samples around the current pixel. I'd start with changing y-offsets to something lower than now or setting those to 0 :) This should give you less blur vertically.
     
    Zebbi likes this.
  44. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    Thank you, I'll try that!
     
  45. eighto

    eighto

    Joined:
    Apr 27, 2013
    Posts:
    32
    Hello, maybe a dumb question but I've always wondered why the lines with this are vertical instead of horizontal. I've messed with this a lot and could never get horizontal lines like the CRT TV's had. Screen from my game: