• 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 marius.treu · Dec 03, 2012 at 12:04 PM · c#shadervariables

C#-script to shader list variable

Hi,

what I need is a simpley Vector3 / float3 list into my shader. Actually it could also be a an array with variable size.

My goal is to work it like a queue. I 'push' a vector3 / float3 element (into a List / stack / array) on the shader and 'pop' one element from that list each frame!

Is this somehow possible? Doesn't actually sounds that difficult.

Kind regards, Marius

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 Paulius-Liekis · Dec 03, 2012 at 03:31 PM 0
Share

where do you want to do the pushing/popping: in the shader? in scripts?

avatar image marius.treu · Dec 04, 2012 at 11:48 AM 0
Share

in shader!

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Philipp · Dec 03, 2012 at 03:24 PM

I'm not sure I understand the question. If you want to push/pop from within your shader code, then that's not possible (at least not with DX9 shaders), as your shaders can't write arbitrary values in memory. If you want to have a stack in C# and expose the top Vector3 to your shader for read access, you could just write it to a property of your material. If you want to push/pop from C#, but you want every value on the stack read-accessible from your shader code, you could do that by using a texture for the stack, shifting pixels up and down and writing to the top pixel from C# (each pixel could represent a single float).

Am I making sense?

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
0

Answer by marius.treu · Dec 04, 2012 at 12:48 PM

As far as I know you can create arrays into GLSL..

I mean you can create a float3 array for example. I use this array to perform actions like I store for all collisions (calculated on C# and sent to shader) the world position into this float3 array. After, I do highlight the area around that collision and remove that element (pop out of array) and highlight the next element etc.

I know that shaders does not provide any object types read out of C# that's not what I wanted to achieve.

What I want is a simple push / pop array command. Are there no?

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 marius.treu · Dec 04, 2012 at 11:49 AM 0
Share

As far as I know you can create arrays into GLSL..

I mean you can create a float3 array for example. I use this array to perform actions like I store for all collisions (calculated on C# and sent to shader) the world position into this float3 array. After, I do highlight the area around that collision and remove that element (pop out of array) and highlight the next element etc.

I know that shaders does not provide any object types read out of C# that's not what I wanted to achieve.

What I want is a simple push / pop array command. Are there no?

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

11 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

passing variables to control Camera position 1 Answer

Replacing a part of shader graph by value from a script 0 Answers

Taking Variables from different and changing object,How to get a variable from a different object that has the same script 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