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
1
Question by runonthespot · Nov 01, 2010 at 01:59 PM · shadertextureiphoneblendingadditive

Iphone - Blend two textures + Additive blending

Hi there,

I've been using http://www.unifycommunity.com/wiki/index.php?title=Blend_2_Textures successfully, and found that using animations to blend between textures can lead to some nice effects.

I've also in the same game, used a fair amount of the particle additive-with-culling shader for iphone, also, with great visual effects (speedy semi transparency).

I therefore (quite naively) attempted to combine the two shaders, and while I got it working in Unity, on the iphone it is clearly failing.

Reading between the lines in posts, it may be that the iphone (4) doesn't have enough texture slots for me to do this in a single pass, although it's not clear to me if that is the case.

Does anyone have a simple iphone blend-2-textures + additive blend to the scene type shader?

I'll post my code up here when I get access to it again later to show what I've done so far.

Thanks! Mike

The end-goal is to have a simplish shader that allows me to animate a blend between two textures, which is applied to an object "additive particle" blended with the scene.

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 cregox · Dec 02, 2010 at 11:19 PM 0
Share

I'm not sure what you want, but if it's adapting that blend shader into a decal shader that works on iphone, that's exactly what I want! :P

3 Replies

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

Answer by Jessy · Dec 03, 2010 at 12:43 AM

Sorry that this is a month late; I missed it somehow. Here you go, if you still need it. You didn't say that you need the solid color or vertex color tints, so I'm leaving them out for simplicity and possibly performance. Also, I left off the ability to modify the opacity of this with alpha for the same reason. (The shader you mentioned from the Mobile Assets package does all that stuff.) Check it out, then tell me if you need any other features.

Shader "Blend 2 Textures, Additive" {

Properties { _Blend ("Blend", Range (0, 1) ) = 0.5 _MainTex ("Texture 1", 2D) = "" _Texture2 ("Texture 2", 2D) = "" }

SubShader { Tags {"Queue"="Transparent" "IgnoreProjector"="True"} ZWrite Off Blend One One Pass { SetTexture[_MainTex] SetTexture[_Texture2] { ConstantColor (0,0,0, [_Blend]) Combine texture Lerp(constant) previous }
} }

}

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
1

Answer by cregox · Dec 02, 2010 at 11:45 PM

Here, I just found out the answer to my issue, thanks again to master of all unity shaders, Jessy.

But I did a little modification, so it's simpler to change from regular Unity's decal into this. It's just changing variable names:

Shader "Color + 2 Decals, Vertex Lit" {

 Properties
 { 
     _Color ("Main Color", Color) = (1,1,1) 
     _SpecColor ("Spec Color", Color) = (1,1,1) 
     _Emission ("Emmisive Color", Color) = (0,0,0) 
     _Shininess ("Shininess", Range (0.01, 1)) = 0.7 
     _MainTex ("Base (RGBA)", 2D) = ""
     _DecalTex ("Decal (RGBA)", 2D) = ""
 } 

 // More than two texture units
 SubShader {Pass
 {
     Lighting On
     SeparateSpecular On
     Material
     { 
         Diffuse (1,1,1) 
         Ambient (1,1,1) 
         Shininess [_Shininess] 
         Specular [_SpecColor] 
         Emission [_Emission] 
     } 
     SetTexture[_MainTex]
     {
         ConstantColor[_Color]
         Combine texture Lerp(texture) constant
     } 
     SetTexture[_DecalTex] {Combine texture Lerp(texture) previous}
     SetTexture[_] {Combine previous * primary Double}
 }}

 // Two texture units
 SubShader
 { 
     Lighting On
     Material
     { 
         Diffuse (1,1,1) 
         Ambient (1,1,1) 
         Shininess [_Shininess] 
         Specular [_SpecColor] 
         Emission [_Emission]
     }
     Pass
     {
         SetTexture[_MainTex]
         {
             ConstantColor[_Color]
             Combine texture Lerp(texture) constant
         }
         SetTexture[_DecalTex] {Combine texture Lerp(texture) previous}
     }

     // 'Double' Lighting
     Pass {Blend DstColor SrcColor}
 } 

}

See if that helps at all. And sorry if I'm not answering your question! :P

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
Wiki

Answer by Arunraj · Feb 23, 2013 at 09:08 AM

I am in confusion, like i have Game environment as 2D , with two or more textures(max 7) to be rendered one by one above of the each other, but every texture to be in same quality as like original texture quality there should not be any decay or Blend. So here is the problem, i have to go with custom shaders or with scripting. My targeted platform is IOS and Android devices. In this user may be selecting the textures randomly and to rendered in every frames, if textures are changed. So it should not affect the performance as well.

Thanks in advance.

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

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

1 Person is following this question.

avatar image

Related Questions

shader cg blending two textures 1 Answer

Blending parts of texture on 3d object with skinned mesh 0 Answers

Problem with texture blending and vertex color shader for iOS 1 Answer

Encoding Float to RG/RGBA and Blending 0 Answers

How to make a part of a texture on an object seamlessly change to another texture? 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