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 p3k07 · Jul 07, 2020 at 11:02 PM · guigraphics

Shader Graph - Vertex point ref issue.

Sup,

I've spent all day trying to wrap my head around shadergraphs and have come to some kind of understanding with the process. However it's annoying me that I can't accomplish what I'm trying to do, so here I am hoping someone can assist.

Basically I want to convert THIS shader script into a shadergraph and I don't quite understand how to get vertex points within the shadergraph. Specifically these 4 lines are what bother me.

 half4 color = (tex2D (_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color; 
 fixed4 topColor = _TopRightColor * IN.texcoord.x + _TopLeftColor * (1 - IN.texcoord.x); 
 fixed4 bottomColor = _BottomRightColor * IN.texcoord.x + _BottomLeftColor * (1 - IN.texcoord.x); 
 color = color * (topColor * IN.texcoord.y + bottomColor * (1 - IN.texcoord.y));

How do I access the vertex at a given point and assign it a colour? I'm trying to make a 4 corner gradient window.

If someone wants to go ahead and convert this shader for me, that'd be ace ^^ If not, then if anyone can point me in the right direction, I'd be eternally grateful.

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
2
Best Answer

Answer by Namey5 · Jul 09, 2020 at 09:31 AM

The basic idea is just to blend between the corner colours based on the mesh UV coordinates - first from left to right, then from bottom to top. I've also multiplied by vertex colour to make it compatible with UI, but keep in mind shader graph is fairly limited and some of the UI support in that shader just isn't really possible to do with a graph.

graph


ua7.png (227.2 kB)
Comment
Add comment · Show 3 · 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 p3k07 · Jul 09, 2020 at 10:04 AM 0
Share

$$anonymous$$y $$anonymous$$an! 48 hours I've been trying to solve this for and you just come in and smash it all out the window. This works perfectly so thank you very much.

Looking at yours from $$anonymous$$e though, I can't understand why $$anonymous$$e wont work. I'm gonna compare them now and see. If you know then if you could let me know where I'm going wrong, at least then I can learn from this.

Thank you so much again :)

https://imgur.com/gallery/HXm3$$anonymous$$P1 alt text

shd.png (158.7 kB)
avatar image Namey5 p3k07 · Jul 09, 2020 at 11:07 AM 1
Share

Honestly yours looks fine to me. The original does the interpolation manually (ta + (1 - t)b), but we can just use the lerp function ins$$anonymous$$d which compiles to identical code (it's just much easier to read and work with). The only other main difference is that you use object space xy coordinates (v.vertex), whereas the original uses manually authored unwrapped UV coordinates (IN.texcoord) - both can work, but the former is more for procedural texturing when UVs aren't available.

avatar image p3k07 Namey5 · Jul 09, 2020 at 11:23 AM 0
Share

That Position node was the culprit. Changed it to a UV node and it's all working now.

Thank you so much for your graph, it really helped a lot and I actually understand what was going wrong. I like yours better as it is more compact and easier to look at.

Now on to the next venture!

Cheers man :)

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

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

Related Questions

Is this a problem of unity 3 or i am doing something wrong. 1 Answer

Fade A Whole Scene From Black & White to Colour 1 Answer

GUI.DrawTexture versus Graphics.DrawTexture 4 Answers

Graphics.DrawTexture drawing in both 2d and 3d?!? 2 Answers

Choosing the right resolution 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