• 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 problemecium · May 12, 2011 at 12:14 AM · shaderlab

Is it possible to create "reactive" shaders?

I've been roaming the internet trying to find out if I can create a shader that can change its properties based on events occurring in the surrounding scene, e.g. changes its reflectivity based on how far away another object is, or textures itself based on what is visible from another point in space. Does anyone know if there is support in ShaderLab to read variables from other objects?

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
3

Answer by DaveA · May 12, 2011 at 12:38 AM

I don't know why a shader would need to have those smarts. Can't you just have normal scripts detect whatever you want and set the properties on the shader(s) as needed?

Unless you mean, for example, if you have a large plane (like water) which would have different properties (like wave height) in the proximity of other objects (like boats)?

Comment
Add comment · Show 4 · 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 yoyo · May 12, 2011 at 04:08 PM 0
Share

DaveA's right, just attach your shader to a material associated with a game object, then create a component whose Update method updates the properties of the shader.

avatar image problemecium · May 12, 2011 at 06:17 PM 0
Share

Exactly, that wave thing is a great example. One really cool thing I thought I could do is create a realistic wormhole that draws onto its "surface" whatever is visible on the other side. I also don't understand quite what you mean, yoyo, about updating the properties of a shader - I thought you could only update the properties of a material, i.e. color(s). I've done some more playing around and I'm wondering if it is necessary to have a script write the shader procedurally in-game. Is it?

avatar image DaveA · May 12, 2011 at 07:35 PM 0
Share

You can modify a material, which really modifies the params on its shader. But what you're talking about is very interesting, and I've seen something like it in Epic's tech (at least, that's what it looked like), so it's probably doable, but beyond me. Hope someone that really knows shaders can give you a better answer.

avatar image DaveA · Jan 08, 2013 at 05:01 AM 0
Share

I can't believe I wrote that initial response. $$anonymous$$ickman is right, get those prox shaders for $20. And I can think of lots of reasons for such shaders. I remember seeing ground fog done right for the first time many years ago in Unreal 3. It fades alpha along intersecting edges, very nice.

avatar image
1

Answer by Mickman · Jan 08, 2013 at 04:58 AM

check out " Proximity Changing Shaders " in the asset store.. this might be perfect for what you're looking for.

Comment
Add comment · Show 1 · 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 Mickman · Jan 08, 2013 at 06:06 AM 0
Share

The only thing i am worried about is the Proximity shader package on the asset store might be restricted to only a few shaders.. so I am not sure if you can add your own ?? Also I am wondering if its possible to add them to character rather than just the camera as it describes in the brief.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

SetTexture combine mode QUAD modifer works different on iPhone/iPad 1 Answer

Combine Alphatest and AlphaBlending in shaderlab 1 Answer

Refraction - GrabPass in Forward Rendering 1 Answer

Are there any 'ghost-like'/smokey shaders for a line material? 0 Answers

Writing to RWTexture3D using a pixel shader without using Graphics.Blit 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