Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

World-space UI #3

Open
wilg opened this issue Aug 5, 2017 · 4 comments
Open

World-space UI #3

wilg opened this issue Aug 5, 2017 · 4 comments

Comments

@wilg
Copy link

wilg commented Aug 5, 2017

Looks like this doesn't work on worldspace UI. Can you point me in the right direction to modifying this to work that way? (I'm not a shader expert by any stretch.)

@PavelDoGreat
Copy link
Owner

Sorry for being late. Try to use 2 cameras: one renders everything, except yout world-space ui, with blur and option "Only UI" enabled, second camera renders everything without blur.

I don't know if it works, just gave you some ideas.

@artyom-zuev
Copy link

artyom-zuev commented Oct 13, 2017

To continue the subject - can you please explain a bit more how to use this with UI systems like NGUI (which can be considered "world-space", I suppose, since no UI tailored Unity functionality is used by it)? To be specific, here is the setup:

  • There are two cameras
  • Main camera draws the 3d scene using perspective mode, clearing to skybox or other background
  • UI camera draws after the main camera, using orthographic projection and depth clear mode and rendering only objects on UI layer
  • UI hierarchy is just a collection of transparent widgets scaled to sit nicely within the view rectangle of orthographic UI camera

I have a couple of questions related to that setup:

  • Should perspective camera drawing the world or orthographic UI camera drawing the widgets be hosting your SuperBlur component? So far I'm guessing it should be hosted on world-drawing perspective camera.
  • Should I use "UI" mode on the SuperBlur component? "Screen" mode just makes world camera render a blurred version of it's perspective on every pixel, and "UI only" mode gives me perspective-rendered background from UI camera transform - again, blurring whole screen at once. Only "UI" mode seems to work correctly, drawing blurred perspective view within quads belonging to UI hierarchy widget with blur material.
  • What can cause the shader to only render correctly for the very first frame after change of properties, immediately switching to black once a frame has passed? Here is a gif depicting that issue - changing color of the widget makes the blur rendered correctly, until I click on game view, forcing editor to redraw it and turning everything black:

https://i.imgur.com/CHkKOEN.gifv

I apologize for asking questions not specific to the stock UI system, but I'm hopeful I can get this wonderful asset to work with NGUI (especially since Unity UI was based on NGUI design).

@artyom-zuev
Copy link

artyom-zuev commented Oct 14, 2017

I think I figured it out. There is one problem remaining (UVs are vertically flipped), but otherwise everything works wonderfully. To make the asset work with NGUI or any other world-space UI system, you need to do the following:

  • Attach the SuperBlur component to world-rendering camera
  • Make UISprite/UITexture components use a custom material with a SuperBlur shader
  • Set SuperBlur component to UI mode
  • Go to Play mode

For some reason, blitting is broken in Edit mode - I don't know why, but blitting over UI quads results in pure black color no matter what you do, for as long as you are in Edit mode. Frame Debugger doesn't work correctly in Edit mode either, so I'm not sure what's up with that, but I'm glad everything works in play mode. :)

I'll set up a pull request with some improvements (global texture use instead of explicit reference to single UI material to allow multiple materials to participate in blurring; separate NGUI shader following all NGUI conventions like vertex color use, blending and so on; iOS-style saturation-based boost to blurred pixels etc.) a bit later. Thanks for the wonderful asset! :)

@wilg
Copy link
Author

wilg commented Feb 17, 2018

@artyom-zuev Any chance of that PR? Would love to try out those features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants