|
Our current project is using a Post Processing Outline Shader. We have imported the Standard Assets and the Pro Standard assets to fix the original upside down errors introduced by 2.6. However, if Anti-Aliasing is turned on now, our outline flips upside down. How do I stop the outline from flipping upside down when Anti-Aliasing is turned on? EDIT : Here is the shader in question. To generate the Depth/Normals texture I'm using a very slightly modified version (just turned off culling on Transparent Cutout RenderType) of the "Camera - DepthNormalTexture" provided in the Built In shader package from the Unity site
(comments are locked)
|
|
Aras is right, but for some strange reason the Shader Replacement project didn't get updated on our website - this will be fixed asap. In the meantime: this is what the Edge Detection example needed in it's vertex shader:
And it is also what your shader needs. The reason for this inconvenience is that D3D and OpenGL interpret Y coordinate differently. We are handling that in Unity behind the scenes, so that the user doesn't have to worry about it, but with anti-aliasing on D3D it would force us to blit the entire image upside-down, which is expensive. It's a lot cheaper to just flip the Y coordinate as the example shows. Works like a charm. Much appreciated. Can I make a request that this information be put into the Image Effects documentation?
Nov 23 '09 at 11:24 PM
Murcho
Good point, will make it so.
Nov 24 '09 at 08:40 AM
robert ♦
The docs have been updated: http://unity3d.com/support/documentation/Components/SL-PlatformDifferences.html And so has the Shader Replacement example project: http://unity3d.com/support/resources/example-projects/shader-replacement
Dec 01 '09 at 10:23 PM
robert ♦
That is a fantastic writeup. Kudos to you!
Dec 11 '09 at 02:24 AM
Murcho
It was Aras ;)
Dec 11 '09 at 02:39 PM
robert ♦
(comments are locked)
|
|
I'm finding when I use the suggested fix
That the result isn't the same as when AA is off, what happens is the result is slightly offset in Y. Any thoughts? The reason is the Direct X renders pixels to the centre of the texel, rather than the top left corner. See this article for details : http://www.sjbrown.co.uk/2003/05/01/fix-directx-rasterisation/ To counter that, you should either add or subtract half of your Texture_TexelSize variable to your sampling uv coordinates.
Nov 24 '09 at 11:48 AM
Murcho
(comments are locked)
|
|
What is the "Post Processing Outline" shader? Making Image Effects + FSAA work can be quite involved. Most of the times it all works, except when it does not. Take a look at Edge Detection sample in Shader Replacement project for an example where solution is more involved. I've posted the shader on my blog here : http://murcho.alumnaie.net/11/real-time-unity-post-processing-shader-woes/ I have a feeling there is something to do with the "_RenderTexture_ST" variable I'm not doing, as I don't understand what is in the _ST component. I've combined the Outline Shader in our current project with the SSAO shader, and when AA is turned on, the outline still flips upside down, however the SSAO component doesn't.
Nov 22 '09 at 12:49 AM
Murcho
"Most of the times it all works, except when it does not." - I LOVE THIS. hahaha.
Nov 22 '09 at 09:34 PM
equalsequals
(comments are locked)
|

Are you using graphics.blit? As far as I know, that call is supposed to handle all the weirdness for you.
Yes, I'm using Graphics.Blit().