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 VildNinja · Jan 20, 2014 at 01:50 AM · shadermeshuv

Accessing uv without a texture

Hi, I'm in the middle of writing a few shaders, all based on vertex colors. In my water shader, I would like to be able to use the uv coords for some anmations, but I can't find a way to access them without first adding a texture to the shader

the below code works as intended, but I would like to just access uv without having to add the _MainTex property.

 struct Input {
   float4 color : COLOR;
   half2 uv_MainTex;
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
   o.Albedo = IN.color.rgb;
   o.Alpha = IN.color.a + sin(_Time.y * IN.uv_MainTex.x) * IN.uv_MainTex.y;
 }

alternative ways of saving values other than color in the mesh is also very welcome :)

Thanks - Jannek

Comment
Add comment · Show 3
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 SunnyChow · Jan 20, 2014 at 02:58 AM 0
Share

Do you try something like "half2 uv:TEXCOORD0;"?

avatar image SunnyChow · Jan 20, 2014 at 03:00 AM 0
Share

also, isn't it better for water shader to use the world position rather than uv?

avatar image VildNinja · Jan 20, 2014 at 03:25 AM 0
Share

no :/ uv : TEXCOORD0; just gives me empty uv coords. It gives me the warning Shader warning in 'Custom/TexturelessAlphe': Program 'vert_surf', not enough actual parameters for macro 'TRANSFOR$$anonymous$$_TEX'.

And I'm animating the water on a spehere, so worldPos gives weird results.

1 Reply

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

Answer by Bunny83 · Jan 20, 2014 at 03:29 AM

You wrote a Surface-shader. As the linked page explains, a Surface shader "is a code generation approach". It's a high-level language which does a lot stuff in the background. As far as i can tell you can't prevent the compiler from creating the _MainTex variable since the "Surface Shader compiler then figures out what inputs are needed".

You might be able to adapt the shader by looking at the compiled shader. If you don't need automatic lighting and all that stuff you probably should write a "normal" (vertex + fragment) shader on your own.

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 VildNinja · Jan 20, 2014 at 04:33 AM 0
Share

Thanks, I've looked a bit more at it, and implementing basic light in the vertex/fragment shaders looks doable. I don't need shadows for the water, but I need some light.

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

19 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

Related Questions

How to set float or float4 UV in Mesh. 1 Answer

Unity Shadergraph Alpha threshold problem 0 Answers

Any way to set the ZW part of a dynamic mesh's UVs? 0 Answers

How do I get mesh data into post-processing shader (or render a mesh shader to a texture)? 0 Answers

Is there a way to merge 2D tiles into one mesh? 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