Тема: Диваны
Показать сообщение отдельно
Старый 08.10.2010, 12:04   #27
pax
Unity/C# кодер
 
Аватар для pax
 
Регистрация: 03.10.2005
Адрес: Россия, Рязань
Сообщений: 7,568
Написано 3,006 полезных сообщений
(для 5,323 пользователей)
Ответ: Диваны

Решил использовать двухпроходный шейдер для двухтекстурных видеокарт без использования Cg вставок.
Получилось следующее:
Shader "Divan/VertexLit" {
Properties {
    
_Color ("Main Color"Color) = (1,1,1,1)
    
_SpecColor ("Spec Color"Color) = (1,1,1,1)
    
_Shininess ("Shininess"Range (0.011)) = 0.7
    _MainTex 
("Base (RGB)"2D) = "white" {}
    
_LightMap ("Lightmap (RGB)"2D) = "lightmap" LightmapMode }
    
_LightMap2 ("Lightmap2 (RGB)"2D) = "lightmap" LightmapMode }
    
_LightMapT ("LightmapT"Range (0.01)) = 0.0 
}


// ------------------------------------------------------------------
// Two texture cards

SubShader {
    
LOD 100
    Tags 
"RenderType"="Opaque" }

    
Pass {
        
Name "LM"
        
        
BindChannels {
            
Bind "Vertex"vertex
            Bind 
"texcoord1"texcoord0 // lightmap uses 2nd uv
            
Bind "texcoord1"texcoord1 // lightmap2 uses 2nd uv
        
}
        
        
SetTexture [_LightMap] {
            
combine texture
        
}
        
SetTexture [_LightMap2] {
            
constantColor (0.5,0.5,0.5,[_LightMapT])
            
combine texture lerp(constantprevious
        
}
    }
    
    
Pass {
        
Name "COLOR"
        
Tags {"LightMode" "Vertex"}
        
Material {
            
Diffuse [_Color]
            
Shininess [_Shininess]
            
Specular [_SpecColor]
        }

        
Lighting On
        SeparateSpecular On
        ZWrite Off
        Offset 0
, -1
        Blend DstColor Zero
        
        BindChannels 
{
            
Bind "Vertex"vertex
            Bind 
"normal"normal
            Bind 
"texcoord"texcoord0 // main uses 1st uv
        
}
        
        
SetTexture [_MainTex] {
            
ConstantColor [_Color]
            
combine texture Constanttexture
            matrix 
[_MainTexMatrix]
        }
    }
}

Fallback "VertexLit"

Теперь есть поддержка старых видеокарт и блики исправились.
__________________
Blitz3d to Unity Wiki
(Offline)
 
Ответить с цитированием