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 quicktom · Sep 13, 2012 at 03:29 PM · blurimage effect

where to assign this shader varible?

where to assign this shader varible?

I have recently used ImageEffect, i.e. Blur. But I cannot figure out how the "_BlurOffsets" varible is assigned or be used? Does anybody know how that shader work?

 CGINCLUDE
     #include "UnityCG.cginc"
     struct v2f {
         float4 pos : POSITION;
         half2 uv : TEXCOORD0;
         half2 taps[4] : TEXCOORD1; 
     };
     sampler2D _MainTex;
     half4 _MainTex_TexelSize;
     half4 _BlurOffsets;
     v2f vert( appdata_img v ) {
         v2f o; 
         o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
         o.uv = v.texcoord - _BlurOffsets.xy * _MainTex_TexelSize.xy; // hack, see BlurEffect.cs for the reason for this. let's make a new blur effect soon
         o.taps[0] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy;
         o.taps[1] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy;
         o.taps[2] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy * half2(1,-1);
         o.taps[3] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy * half2(1,-1);
         return o;
     }
     half4 frag(v2f i) : COLOR {
         half4 color = tex2D(_MainTex, i.taps[0]);
         color += tex2D(_MainTex, i.taps[1]);
         color += tex2D(_MainTex, i.taps[2]);
         color += tex2D(_MainTex, i.taps[3]); 
         return color * 0.25;
     }
     ENDCG
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by paraself · Aug 08, 2015 at 06:25 PM

_BlurOffsets is assigned when you used graphics.BlitMultiTap 's offset feature. For example, when you do Graphics.BlitMultiTap(source, dest, mtl, new Vector(-4,5)); _BlurOffsets.xy will be assigned to (-4,5).

see this research (in Chinese):

http://game.ceeger.com/forum/read.php?tid=3450&fid=2&page=1

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
avatar image
-1

Answer by bruce965 · Sep 13, 2012 at 03:36 PM

In a MonoBehaviour Script:

`renderer.sharedMaterial.SetVector("_BlurOffsets", new Vector3(x, y, z));`

Comment
Add comment · Show 5 · 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
avatar image bruce965 · Sep 13, 2012 at 03:37 PM 0
Share

NOTE: You may have to use a Vector4 ins$$anonymous$$d of a Vector3...

avatar image quicktom · Sep 17, 2012 at 12:55 AM 0
Share

The Shader is "Hidden/BlurEffectConeTap", and the script is BlurEffect.cs, and I didnot find "renderer.shared$$anonymous$$aterial.SetVector("_BlurOffsets", new Vector3(x, y, z));", how is "_BlurOffsets" is working in script without assigning?

avatar image bruce965 · Sep 17, 2012 at 03:34 AM 0
Share

Just add this line in Start() method of the *.cs script.

avatar image temptest123 · Dec 18, 2012 at 09:15 AM 0
Share

I just tried to understand the code of this imageEffect too - and I also can't figure out where exactly is the '_BlurOffsets' variable setup? I mean - the Blur effect works already - so there must be somewhere some code that assigns this variable. but where?

avatar image temptest123 · Dec 18, 2012 at 09:27 AM 0
Share

$$anonymous$$y best guess is, that it's set in Graphics.Blit$$anonymous$$ultiTap() - but that'd be quite a hack somehow?

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

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Vertical Blur Image Effect 0 Answers

How to blur an image in memory? 1 Answer

Modifying an image effect component over time. 0 Answers

how to use motion blur just for background (unity pro) 0 Answers

GUI Texture blur 5 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