Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by StephanK · Aug 09, 2010 at 12:27 PM · shaderimage-effects

Motion Blur effect on Windows with multiple cameras

I am trying to use the Motion Blur effect from the Pro Standard Assets. It works as expected, but on windows it flips the image upside down. I know that this has to do with D3D9 api and I read about the fix in the manuals. Also the problem seems to be a bit bigger than the docs claim, as it doesn't happen to anti-aliased images only, but rather all the time on windows. I think this is because I'm using multiple camera passes, where the first one has the motion blur effect. However, as I'm quite new to shaders and Shader Lab I can't seem to figure out how to apply the fix to this particular image effect. My idea was to add an extra pass after the two original ones, that does the swapping in the fragment shader. My approach works as far as the swapping is concerned, but I also completely lose the blur effect, which makes me suspect that I'm somehow using the original textures before blurring occurred, but I don't know how to access the texture generated in the last pass. This is what I have so far:

Shader "Hidden/MotionBlur" { Properties { _MainTex ("Base (RGB)", RECT) = "white" {} _AccumOrig("AccumOrig", Float) = 0.65 }

SubShader { ZTest Always Cull Off ZWrite Off Fog { Mode off }

 Pass {
     Blend SrcAlpha OneMinusSrcAlpha
     ColorMask RGB
     SetTexture [_MainTex] {
         ConstantColor (0,0,0,[_AccumOrig])
         Combine texture, constant
     }
 }

 Pass {
     Blend One Zero
     ColorMask A
     SetTexture [_MainTex] {
         Combine texture
     }
 }

 Pass {

CGPROGRAM #include "UnityCG.cginc"

struct v2f { float2 uv[4] : TEXCOORD0; };

uniform float4 _MainTex_TexelSize; uniform samplerRECT _MainTex : register(s0);

half4 frag (v2f v) : COLOR { half4 o;

if SHADER_API_D3D9

if (_MainTex_TexelSize.y < 0) v.uv[0].y = 1-v.uv[0].y; #endif

o = texRECT(_MainTex, v.uv[0]); return o; }

pragma fragment frag

ENDCG

 }

}

Fallback off

}

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cyb3rManiak · Aug 09, 2010 at 01:32 PM 0
Share

What do you mean you're using multiple camera passes? Do you actually render the camera manually using Camera.Render()? Or did you mean you use multiple cameras that are just with different depths to render one on top of the other?

avatar image StephanK · Aug 09, 2010 at 02:32 PM 0
Share

Different depths.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by StephanK · Aug 09, 2010 at 06:09 PM

This is not a really a solution for the original problem, but I found a workaround. If I change all calls to ImageEffects.Blit in the MotionBlur.cs file to Graphics.Blit it doesn't flip the image anymore. I'm not even sure why that works, but it did solve my problem. Still interested in a "clean" solution and explanation though... ;)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Anti-Aliasing causes post processing effects to flip. 3 Answers

How to force the compilation of a shader in Unity? 5 Answers

What is the right way to modify depth of field focal distance via script at runtime? 1 Answer

SSAO: How do I get rid of these artifacts? 0 Answers

Custom Brightness/Contrast shader doesn't work on OpenGL ES 2.0 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges