- Home /
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.
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
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 }
} }
}
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
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081541im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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