Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by ragnaros100 · Dec 21, 2015 at 03:25 PM · shadershader programmingworldspacevertex shaderdeformation

Shader question: interaction with world objects?

Hi,

Simple but perhaps a silly question, but is it possible for a shader to interact directly with objects in the scene?

For example: You have a field of grass with a custom shader on it. You then roll a ball with a collider and a rigidbody through the grass, the shader should then deform the verts of the grass away from the ball. (it doesn't need to be 100% physically correct, just a slight deformation for juice purposes)

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by wibble82 · Dec 21, 2015 at 03:58 PM

I think what you're asking is 'can the shader read my scene and deform the verts away from the ball'. The simple answer to this is no! :)

A shader is a very simple program, that runs on the GPU and operates on a few specific blocks of data that you (or unity) give it. These for a vertex shader are typically vertex buffers and constant buffers, and for a pixel shader are the vertices output by the vertex shader, along with textures and constant buffers. Unity exposes this to you in the form of textures, meshes and materials.

Modern GPUs are more flexible, though unity doesn't provide access to much of this functionality as it is a cross platform system.

That all said, it wouldn't be unusual to try and feed the shader some degree of information about collisions to utilize the GPU's processing abilities. For example, if there was only 1 ball in the scene you could feed your vertex shader its position, and have the shader calculate the distance of its vertices from the ball and deform them accordingly.

-Chris

Comment
Add comment · Show 6 · 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 sakthig · Jan 04, 2016 at 01:11 PM 0
Share

Hi Chris,

A related question..

Are demos like this created just for fun ? This scenery would mean nothing when loaded in an unity / any other game engine ?

avatar image tanoshimi sakthig · Jan 04, 2016 at 01:24 PM 1
Share

Yes - that scene only exists on the graphics card - created just before it is rendered. It cannot interact with any objects in your scene, user input, physics etc.

avatar image sakthig tanoshimi · Jan 04, 2016 at 02:53 PM 0
Share

Thanks for answering :)

avatar image cjdev · Jan 05, 2016 at 01:31 AM 1
Share

While the shader can't read the scene it certainly can be fed information, like the position of the balls, and the vertices of the geometry adjusted in the vertex shader accordingly. Shaders are not simple programs at all, in fact they are in many ways more powerful than programs run on CPUs, especially when computing and calculating tasks in parallel. The task in question is definitely feasible and could probably be done with $$anonymous$$imal branching to boot.

avatar image Bunny83 cjdev · Jan 05, 2016 at 07:37 AM 1
Share

Are you sure you read the answer to the end?

avatar image tanoshimi cjdev · Jan 05, 2016 at 07:53 AM 0
Share

Yes - it's relatively easy to make a shader react. $$anonymous$$uch harder to make it interact.

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

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

Mobile performance of splat map shader with distance blending 0 Answers

How to extend a Material Shader so that it also maps the Normal Maps in WorldSpace? 1 Answer

vertex and geometry shader change with distance 0 Answers

Shader to turn materials transparent based on y axis 0 Answers

unity shader custom vertex stream - What does TEXCOORD0.w|x mean? 1 Answer


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