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 Kayn-SD · Jun 15, 2013 at 03:07 PM · shaderblendinguvstexture atlas

Blending between two parts of a texture atlas, using another texture atlas as an Alpha Channel

For a procedural mesh generator I'm constructing, I'm building a mesh dynamically and assigning it a series of UV sets, based on a pair of texture atlases - one for the main texture (the checkerboard) and one for the borders (the dirt). This just uses a Decal2UVs shader and 2 UV sets - uv1 being the main texture, and uv2 being the border texture

yes, isn't it pretty and dungeonkeepery? Anyone with a sense of deja vu should look at me asking how to build one of these a few years back in the forums

Now while this is perfectly serviceable, I would like to use a lot more border effects, but given all the permutations available for a eight sided border checker, I could only realistically fit five on a ^2 sheet (there are 45 non-blank options per border, not including anything I plan for diagonals - at 64px on a 1024 sheet, that works out to about 5, with some left over).

What I ideally want is to have the border sheet contain Alpha Channels that fade between textures on the texture atlas itself, as on the image below:

Diagram for what might be a two pass shader using three uv sets and two textures. I think?

I'm not especially good at Shaderlab, understanding only enough to hammer out a basic lerp between alpha after a few hours of tinkering, and certainly not good enough to pull three UV sets out of only two on the mesh. I was reading that there is a possibility of accessing the Vertex Color objects (which I'm not using) and jury-rig those as a third and fourth UVs if I need them.

If someone can point me in the right direction for building this kind of shader that takes two sets of UVs from one texture atlas, another set of UVs from a border texture atlas, and interpolates between the first two using the third as a guide, I would be very grateful. Alternatively, if one already exists out there I'd appreciate that too (either commercial and noncommercial)

untitled-1.png (382.1 kB)
untitled-2.png (67.2 kB)
Comment
Add comment · Show 1
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 Kayn-SD · Jun 16, 2013 at 03:17 PM 0
Share

This is my current shader code. It shares the border shader with the second instance of the main texture - I need to somehow get a texcoord2 from somewhere

 Shader "Custom/BlendTextureAtlasShader" {
 Properties {
     _Color ("$$anonymous$$ain Color", Color) = (1,1,1,1)
     _SpecColor ("Spec Color", Color) = (1,1,1,1)
     _Emission ("Emmisive Color", Color) = (0,0,0,0)
     _Shininess ("Shininess", Range (0.01, 1)) = 0.7
     _$$anonymous$$ainTex ("Base (RGB)", 2D) = "white" {}
     _DecalTex ("Decal (RGBA)", 2D) = "black" {}
 }
 
 SubShader {
     $$anonymous$$aterial {
         Diffuse [_Color]
         Ambient [_Color]
         Shininess [_Shininess]
         Specular [_SpecColor]
         Emission [_Emission]
     }
     Tags { "Queue" = "Transparent" }
      Pass {
          BindChannels {
             Bind "texcoord", texcoord// main uses 1st uv
         }
         Lighting On
         SeparateSpecular On
         
         Blend SrcAlpha One$$anonymous$$inusSrcAlpha
          
            SetTexture[_$$anonymous$$ainTex]
      }
      Pass {
         BindChannels {
             Bind "texcoord", texcoord1 // main uses 1st uv
             Bind "texcoord1", texcoord0 // border needs to use a 3rd UV?
         }
         Lighting On
         SeparateSpecular On
         
         Blend SrcAlpha One$$anonymous$$inusSrcAlpha
          
            SetTexture[_$$anonymous$$ainTex]
         SetTexture[_DecalTex] {Combine previous Lerp(texture) texture}  
     }
 }
 
 Fallback " VertexLit", 1
 }

0 Replies

· Add your reply
  • Sort: 

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

15 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

Related Questions

shader for light replacement blending, instead of additive blending? 0 Answers

Help with triplanar atlas shader. 2 Answers

Weird shader thing 1 Answer

Shader texture blend performance 0 Answers

Blending Reflection 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