Search Unity

[RELEASED] Projector Simulator

Discussion in 'Assets and Asset Store' started by shwhjw, Nov 28, 2017.

  1. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Hey, I'm considering purchasing this, but I'm using URP.
    Now that URP supports Light Cookies, is there a chance that this asset will be supported as well?
    Thanks!
     
  2. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi, I wasn't aware URP now supported cookies, give me a few days to investigate and I'll get back to you!
     
    JudahMantell likes this.
  3. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi, I've had a look and it should certainly be possible to support URP, but some of the maths need rethinking. I should be able to submit a new version in the next couple of weeks.
     
  4. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    I'm having an issue which appears to be a near clipping plane. For the life of me I can't find the setting for this, and there also seems to be an issue with the shadows. Any suggestions are super appreciated!

    at the range I want it, pointed straight down:
    upload_2022-8-5_11-29-46.png

    at a greater range straight down:
    upload_2022-8-5_11-30-50.png


    at the range I want it, but 45'
    upload_2022-8-5_11-32-24.png


    I'm guessing this is a near clip because of the objects in the foreground not getting a projection, but also even at far away, the closer to 90'... no joy on receiving a projection (as you can see from the ground near the center of the projection vs the edges). Thank you for any help!
     
  5. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi Tempest, it's difficult to tell what's going on, I've never seen this issue before and am unable to replicate it, at least not by projecting onto a plane at a large distance. Are you able to share your project, or a simple version of it showing the issue?

    The projectors use standard Unity spotlights, are you able to replicate the lighting issue with a standard Spotlight?

    You may be able to find the issue by adjusting the settings of the spotlights inside the projector. If you select all spotlights and adjust e.g. the Bias or render mode, does it affect the result?
    upload_2022-8-5_18-7-8.png
     
  6. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    Thank you for your quick response. It's strange. On regular planes, it is fine. It seems to be with instantiated geometry. I've tried it both with google's map and GoMap. Same story. And no... spotlights seem to be fine. (Here I attached a spotlight to the same prefab as the projector. (projector is facing forward, and spotlight is facing down) upload_2022-8-5_17-16-32.png
     
  7. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Can you upload one of your meshes here (or somewhere like WeTransfer if it's too big)?

    Are there any settings in the mesh, or mesh import settings, that make a difference?
     
  8. Martin-Sam

    Martin-Sam

    Joined:
    Aug 19, 2020
    Posts:
    2
    Hi. We bought the projector simulator package and we noticed a texture memory leak in the 'ProjectorSim_RenderTexture' component because in the shader-based path it creates three RenderTextures (redCookie, greenCookie and blueCookie in class 'Cookie') but it never calls RenderTexture.Release / Destroy(RenderTexture) on them. We noticed because we destroy and recreate the projector component often during the lifetime of our simulator application because we have to change the optical properties during runtime.
     
  9. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Thanks for the heads up, will fix in next release.
     
  10. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    Unfortunately, I can't because they're generated on the fly with downloaded DEM data using GO Map. (sorry for the late reply, was out of town)
     
  11. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    The meshrender settings are standard btw, and the material is a standard shader (with the addition of culling turned off)-
     
  12. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    Hello? I really need help. Any ideas at all? Can you at least tell me what I should look for?
     
  13. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    Just pinging again. We're really stuck here and need help.
     
  14. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    I'm happy to get on zoom and show you what is happening at your convenience. I'll DM you a calendly link so we can do this if you're up for it.
     
  15. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi, sorry for some reason I stopped getting email pings when this thread is updated. I'll choose a time on your calendly.
     
  16. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    I understand you can't share a project if you need login information etc to stream the terrain data at runtime, but can you save the geometry as a prefab once you are in Play mode and then share that?
     
  17. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    I've just pushed the URP update to the asset store! Should be live in a few days.
     
  18. ovjang

    ovjang

    Joined:
    Apr 12, 2015
    Posts:
    4
  19. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi ovjang, it should work but I will test this tomorrow. Can I ask which version of Unity you're using?
     
  20. ovjang

    ovjang

    Joined:
    Apr 12, 2015
    Posts:
    4
    Hello shwhjw!
    I am using Unity 2022.1.23f1.

    ProjectionSimRenderTexture.cs
    It appears that previousProcessingTimes is not initialized.

    NullReferenceException: Object reference not set to an instance of an object
    ProjectorSim_RenderTexture.UpdateImage () (at Assets/ProjectorSimulator/Scripts/ProjectorSim_RenderTexture.cs:263)

    upload_2023-3-12_9-15-59.png
     
  21. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    previousProcessingTimes should be initialised in the Awake() function, so something's not right if it's null.
    upload_2023-3-12_17-16-29.png

    I've just tested a video in Unity 2021.3 and I don't get your error, so maybe something's causing UpdateImage() to be called before Awake() in Unity 2022 for some reason. I'll download your version and test again.

    For now as a workaround you should just be able to change the 'if' statement on line 260 to if(false) and the problematic code won't run (the processing time check is more for the CPU-based processing in the standard renderer. URP uses shaders so is very likely fast enough). There may be other problems though if things are getting called before Awake().
     
  22. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    I just tested in 2022.1.23f1 and playing a video in the sample scene is working... does the error happen for you every time? Does it happen in the editor, or only in builds?
     
  23. ovjang

    ovjang

    Joined:
    Apr 12, 2015
    Posts:
    4
    Thank you for your answer.
    It happens every time in my environment.
    I run it in Editor.I have not tried with the executable file.
     
    Last edited: Mar 13, 2023
  24. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Are you able to zip a small project that has the issue and send it?

    My only other suggestion would be to try another version of Unity as it does sound like a very strange bug I've not seen before.
     
  25. ovjang

    ovjang

    Joined:
    Apr 12, 2015
    Posts:
    4
    I made it in Unity2021 on a Windows platform and it works. Does it work on android platform?
    Maybe it will work if I make it again in 2022.
    Thanks for your help.
     
    Last edited: Mar 16, 2023
  26. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi, sorry for late answer. I have tested on android before successfully but only with built-in renderer, not with URP. Have you tried it yet on android?
     
  27. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    I've just found by testing (on 2021.3.12f1) that Graphics.Blit() (a function that is used during the creation of the spotlight cookies) doesn't seem to work at all when using WebGL+ URP together. I've tested without spotlghts and just applying the textures to geometry (with a simpler shader or no shader at all), so it seems a fundamental issue with Unity. If you need WebGL probably best to stick with built-in renderer for now.
     
  28. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Scratch that, Blit() does work and the error is caused when we attempt to find the shader (I only thought a simple Blit wasn't working because I was Blitting after trying to find the shader). Although the shader is included in "always included shaders" (and in a Resources folder), it still can't be found by the look of it.
     
  29. MalcolmSith

    MalcolmSith

    Joined:
    Mar 13, 2018
    Posts:
    3
    I am getting a crash upon leaving a scene with one or multiple projectors WITHOUT legacy shading/computing checked. It works with legacy but is too slow overall so I'd like to fix it. This happens only in the windows build and not in the editor playmode. I'm on 2021.3.18f1 but have also tested a newer 2022 version of editor. Any idea what may cause this? All of my projectors use the same video and render texture.
     
  30. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi, I think I know the cause of this (problem releasing a RenderTexture). I thought I fixed this but will do another test tonight and report back.
     
  31. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    That fix wasn't included in the last release for some reason but I have it ready to go, am submitting an update to the Asset Store now. It should be live in a few days as version 1.57. Unfortunately it is more complicated than just changing a few lines of code in a single file so it's not really something I can instruct you to change yourself on here.
     
  32. MalcolmSith

    MalcolmSith

    Joined:
    Mar 13, 2018
    Posts:
    3
    Fantastic! You are a legend!
     
  33. MalcolmSith

    MalcolmSith

    Joined:
    Mar 13, 2018
    Posts:
    3
    Just tried a build! It works!!

    Thank you!!
     
    shwhjw likes this.
  34. cheryl_l

    cheryl_l

    Joined:
    Aug 28, 2019
    Posts:
    6
    Hi Shwhjw, this is a super useful asset! I was wondering if it's possible to update the projector throw ratio and have the change be reflected live while playing in the game. I wanted to write a script that lets the player change different attributes of the projector in-game, but if I update the throw ratio attribute directly, I don't see a change in the projected image. Is there some sort of update/refresh function that needs to be run?
     
  35. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi Cheryl_l,

    It is not possible by default to update the projector settings at runtime currently. The reason for this is if using the original CPU-based processing you wouldn't want to do this at runtime as it is very slow, but it is "probably" fast enough now if you are using the shader method (CPU processing is now only required for keystone correction with the standard built-in renderer, I think the shader method should work for every other use case).

    That said, it is probably possible to update the RenderTextureProjector's settings at runtime by updating all the necessary variables of the RenderTextureProjector's CookieCreator's CookieData struct and then calling Initialise() again on the CookieCreator, but I haven't tested this. It is more difficult with the ImageProjector because all the cookies are created when the level is loaded and don't support live updates.

    I have now started refactoring the code to make the ImageProjector and RenderTexture projector inherit from the same base class, to clean up the code and make it easier to make future changes. I will try and make it easier to update the RenderTextureProjector settings at runtime too.

    Currently Projector Simulator Pro does support updating values at runtime more easily if you can't wait for the next PS update (it might take a few months). The reason PSP can do it is because it never had the CPU-based processing and there is only one type of projector, so it is much "cleaner" (hence me now refactoring PS).

    I will probably take out the CPU-based processing from PS if I can get the keystoning to work with the shader processing, I don't think there would be any situations in which it would be needed then and it would simplify the code (someone please correct me if you do need it for another reason).

    Kind regards,
    Simon.
     
  36. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    Hi!, I'm trying to add an image to the images list through a script, but the projector isn't cycling through to it. I need help figuring out why it's not working.

    Here's the situation: I've written a script to add the image to the list, expecting it to be displayed by the projector. However, the projector seems to be stuck on the previous images and isn't showing the newly added one.

    If you have any insights or suggestions on how to resolve this issue, I would greatly appreciate your assistance.
     
  37. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi TempestDroneworx,

    The ImageProjector works by creating one set of cookies per image when the level loads. It then discards the original images to save memory, so the cookies cannot be created again. Creating cookies takes time if using keystoning as the shader doesn't support it yet, so it falls back to CPU processing, and creating more cookies could affect frame rate (for this reason it is not possible to add more images at runtime).

    Is there a way you can do what you want with the RenderTexture projector? The best way would probably be to use Graphics.Blit() to display whichever image you want on the projected RenderTexture.

    Kind regards,
    Simon.
     
  38. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Alternatively you might be able to edit the script to run the code to generate the cookies again when a new one is added. If you can find the part that clears the list of images you can prevent the old images being deleted too. I'm travelling at the moment so can't look myself unfortunately. I know it is a bit fragile if you mess with the order of things too much.
     
  39. TempestDroneworx

    TempestDroneworx

    Joined:
    Jul 12, 2022
    Posts:
    20
    Hey, thanks for getting back to me! I appreciate your suggestion to potentially edit the script and regenerate the cookies when a new one is added. Unfortunately, I'm unable to modify the ProjectorSim script at the moment due to the way my project is made, so that approach isn't feasible for me.

    However, I'm wondering if there's an alternative way to refresh the cookies from another script. Is there a specific function or method that could be utilized to achieve this? It would be great to know if there's a workaround I can explore given the constraints I'm facing.

    Again, thank you for taking the time to respond and offer your input.
     
  40. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    It sounds like the "easiest" solution if you want to add images at runtime would be to use the RenderTexture projector, and make your own script with your own list of images that you can modify at runtime, and Blit your image onto the projected RenderTexture when you want to change image.
     
  41. krakentanz

    krakentanz

    Joined:
    Aug 13, 2020
    Posts:
    34
    Hi Shwhjw,
    quick question about your asset: Is it possible to fiddle with the projector's light's falloff? I need it to be unrealistic and have zero falloff (not even linear). Is this an option?
    Cheers!
     
  42. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi Krakentanz, do you mean falloff with distance? The projectors contain standard spotlights and uses Unity's built-in lighting system, so I think there will always be some falloff, unfortunately.

    A Decal Projector might be the closest to what you want, but I don't think it allows shadows:
    https://docs.unity3d.com/Manual/visual-effects-decals.html
     
  43. krakentanz

    krakentanz

    Joined:
    Aug 13, 2020
    Posts:
    34
    Hey, thanks for the reply! The problem with decals is that they are a parallel projection, not a point projection, which is what I'd need. I'll keep on looking, cheers!
     
  44. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    The "Projectors" in the built-in renderer/Standard Assets package can use either point or parallel projection, but I guess you are using HDRP or URP.
     
  45. IainEC_MTC

    IainEC_MTC

    Joined:
    Oct 19, 2022
    Posts:
    1
    This is a nice little plugin, is it possible to to project onto a transparent material? only showing where the projection hits in a scene?

    Thanks in advance!
     
  46. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi, PS uses Unity's lighting system so if the transparent material can be lit, it can be projected onto. What do you mean by "only showing where the projection hits in a scene"?
     
    Last edited: Jan 4, 2024
  47. wechat_os_Qy042tNNCpnWBThuabU6Z7Uxc

    wechat_os_Qy042tNNCpnWBThuabU6Z7Uxc

    Joined:
    Apr 12, 2021
    Posts:
    19
    I'm using the 1.57 version of the plugin, but I still can't render the picture when using urp. The Unity version I'm using is 2022.3. upload_2024-1-4_11-53-14.png
     
  48. wechat_os_Qy042tNNCpnWBThuabU6Z7Uxc

    wechat_os_Qy042tNNCpnWBThuabU6Z7Uxc

    Joined:
    Apr 12, 2021
    Posts:
    19
    The platform I need to use this plugin is webgl, and the built-in rendering pipeline supports up to 4 pixel lights, but if I need multiple projectors in a scene, I need to upgrade the urp, or you have other better solutions that support multiple projectors in webgl.
     
  49. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Hi, you will need the latest Projector Simulator version (1.58) to use URP with WebGL, as stated in the doc's release notes:

    upload_2024-1-4_17-43-3.png
     
  50. wechat_os_Qy042tNNCpnWBThuabU6Z7Uxc

    wechat_os_Qy042tNNCpnWBThuabU6Z7Uxc

    Joined:
    Apr 12, 2021
    Posts:
    19
    But the version I see in the asset store is still 1.57, and I don't see whether 1.58 has not been updated or something is wrong.