0
Not a bug

It's not working, Could you help us?

Yuno vor 9 Jahren aktualisiert von Freya Holmér (Developer) vor 9 Jahren 4
Now we are using shader forge new version with unity 5. It's working on unity editor. but, it's not working in android mobile devices (samsung galaxy phones).

Here is our shader code.


// Shader created with Shader Forge v1.13 // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/

// Note: Manually altering this data may prevent you from opening it in Shader Forge

/*SF_DATA;ver:1.13;sub:START;pass:START;ps:flbk:,lico:1,lgpr:1,nrmq:1,nrsp:0,limd:1,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,rprd:False,enco:True,rmgx:True,rpth:0,hqsc:True,hqlp:False,tesm:0,bsrc:0,bdst:1,culm:0,dpts:2,wrdp:True,dith:2,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.4887003,fgcg:0.688332,fgcb:0.9632353,fgca:1,fgde:0.003,fgrn:0,fgrf:300,ofsf:0,ofsu:0,f2p0:True;n:type:ShaderForge.SFN_Final,id:3046,x:33711,y:32383,varname:node_3046,prsc:2|diff-9043-OUT,amdfl-1603-RGB;n:type:ShaderForge.SFN_Lerp,id:5465,x:32467,y:32291,varname:node_5465,prsc:2|A-7264-RGB,B-4430-RGB,T-5095-R;n:type:ShaderForge.SFN_Tex2d,id:7264,x:32186,y:32348,ptovrint:False,ptlb:_MainTex,ptin:__MainTex,varname:node_7264,prsc:2,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:5095,x:32398,y:32761,ptovrint:False,ptlb:_SplatMap,ptin:__SplatMap,varname:node_5095,prsc:2,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:4430,x:32186,y:32527,ptovrint:False,ptlb:_Texture1,ptin:__Texture1,varname:node_4430,prsc:2,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Lerp,id:9078,x:32849,y:32334,varname:node_9078,prsc:2|A-5465-OUT,B-8238-RGB,T-5095-G;n:type:ShaderForge.SFN_Tex2d,id:8238,x:32592,y:32374,ptovrint:False,ptlb:_Texture2,ptin:__Texture2,varname:node_8238,prsc:2,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Lerp,id:4731,x:33169,y:32422,varname:node_4731,prsc:2|A-9078-OUT,B-5869-RGB,T-5095-B;n:type:ShaderForge.SFN_Tex2d,id:5869,x:32779,y:32509,ptovrint:False,ptlb:_Texture3,ptin:__Texture3,varname:node_5869,prsc:2,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:3363,x:33098,y:32731,ptovrint:False,ptlb:_Texture4,ptin:__Texture4,varname:node_3363,prsc:2,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Lerp,id:9043,x:33337,y:32519,varname:node_9043,prsc:2|A-4731-OUT,B-3363-RGB,T-5095-A;n:type:ShaderForge.SFN_Color,id:1603,x:33452,y:32713,ptovrint:False,ptlb:Color,ptin:_Color,varname:node_1603,prsc:2,glob:False,c1:0.5,c2:0.5,c3:0.5,c4:1;proporder:7264-5095-4430-8238-5869-3363-1603;pass:END;sub:END;*/



Shader "Custom/Terrain_splatmap" {

Properties {

__MainTex ("_MainTex", 2D) = "white" {}

__SplatMap ("_SplatMap", 2D) = "white" {}

__Texture1 ("_Texture1", 2D) = "white" {}

__Texture2 ("_Texture2", 2D) = "white" {}

__Texture3 ("_Texture3", 2D) = "white" {}

__Texture4 ("_Texture4", 2D) = "white" {}

_Color ("Color", Color) = (0.5,0.5,0.5,1)

}

SubShader {

Tags {

"RenderType"="Opaque"

}

LOD 200

Pass {

Name "FORWARD"

Tags {

"LightMode"="ForwardBase"

}





CGPROGRAM

#pragma vertex vert

#pragma fragment frag

#define UNITY_PASS_FORWARDBASE

#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )

#include "UnityCG.cginc"

#include "AutoLight.cginc"

#include "Lighting.cginc"

#include "UnityPBSLighting.cginc"

#include "UnityStandardBRDF.cginc"

#pragma multi_compile_fwdbase_fullshadows

#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON

#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE

#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON

#pragma multi_compile_fog

#pragma exclude_renderers xbox360 ps3

#pragma target 2.0

uniform sampler2D __MainTex; uniform float4 __MainTex_ST;

uniform sampler2D __SplatMap; uniform float4 __SplatMap_ST;

uniform sampler2D __Texture1; uniform float4 __Texture1_ST;

uniform sampler2D __Texture2; uniform float4 __Texture2_ST;

uniform sampler2D __Texture3; uniform float4 __Texture3_ST;

uniform sampler2D __Texture4; uniform float4 __Texture4_ST;

uniform float4 _Color;

struct VertexInput {

float4 vertex : POSITION;

float3 normal : NORMAL;

float4 tangent : TANGENT;

float2 texcoord0 : TEXCOORD0;

float2 texcoord1 : TEXCOORD1;

float2 texcoord2 : TEXCOORD2;

};

struct VertexOutput {

float4 pos : SV_POSITION;

float2 uv0 : TEXCOORD0;

float2 uv1 : TEXCOORD1;

float2 uv2 : TEXCOORD2;

float4 posWorld : TEXCOORD3;

float3 normalDir : TEXCOORD4;

float3 tangentDir : TEXCOORD5;

float3 bitangentDir : TEXCOORD6;

LIGHTING_COORDS(7,8)

UNITY_FOG_COORDS(9)

#if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)

float4 ambientOrLightmapUV : TEXCOORD10;

#endif

};

VertexOutput vert (VertexInput v) {

VertexOutput o = (VertexOutput)0;

o.uv0 = v.texcoord0;

o.uv1 = v.texcoord1;

o.uv2 = v.texcoord2;

#ifdef LIGHTMAP_ON

o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;

o.ambientOrLightmapUV.zw = 0;

#elif UNITY_SHOULD_SAMPLE_SH

#endif

#ifdef DYNAMICLIGHTMAP_ON

o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;

#endif

o.normalDir = UnityObjectToWorldNormal(v.normal);

o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );

o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);

o.posWorld = mul(_Object2World, v.vertex);

float3 lightColor = _LightColor0.rgb;

o.pos = mul(UNITY_MATRIX_MVP, v.vertex);

UNITY_TRANSFER_FOG(o,o.pos);

TRANSFER_VERTEX_TO_FRAGMENT(o)

return o;

}

float4 frag(VertexOutput i) : COLOR {

i.normalDir = normalize(i.normalDir);

float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);

/// Vectors:

float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);

float3 normalDirection = i.normalDir;

float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);

float3 lightColor = _LightColor0.rgb;

// Lighting:

float attenuation = LIGHT_ATTENUATION(i);

float3 attenColor = attenuation * _LightColor0.xyz;

float Pi = 3.141592654;

float InvPi = 0.31830988618;

/// GI Data:

UnityLight light;

#ifdef LIGHTMAP_OFF

light.color = lightColor;

light.dir = lightDirection;

light.ndotl = LambertTerm (normalDirection, light.dir);

#else

light.color = half3(0.f, 0.f, 0.f);

light.ndotl = 0.0f;

light.dir = half3(0.f, 0.f, 0.f);

#endif

UnityGIInput d;

d.light = light;

d.worldPos = i.posWorld.xyz;

d.worldViewDir = viewDirection;

d.atten = attenuation;

#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)

d.ambient = 0;

d.lightmapUV = i.ambientOrLightmapUV;

#else

d.ambient = i.ambientOrLightmapUV;

#endif

UnityGI gi = UnityGlobalIllumination (d, 1, 0, normalDirection);

lightDirection = gi.light.dir;

lightColor = gi.light.color;

/// Diffuse:

float NdotL = max(0.0,dot( normalDirection, lightDirection ));

float3 directDiffuse = max( 0.0, NdotL) * attenColor;

float3 indirectDiffuse = float3(0,0,0);

indirectDiffuse += _Color.rgb; // Diffuse Ambient Light

indirectDiffuse += gi.indirect.diffuse;

float4 __MainTex_var = tex2D(__MainTex,TRANSFORM_TEX(i.uv0, __MainTex));

float4 __Texture1_var = tex2D(__Texture1,TRANSFORM_TEX(i.uv0, __Texture1));

float4 __SplatMap_var = tex2D(__SplatMap,TRANSFORM_TEX(i.uv0, __SplatMap));

float4 __Texture2_var = tex2D(__Texture2,TRANSFORM_TEX(i.uv0, __Texture2));

float4 __Texture3_var = tex2D(__Texture3,TRANSFORM_TEX(i.uv0, __Texture3));

float4 __Texture4_var = tex2D(__Texture4,TRANSFORM_TEX(i.uv0, __Texture4));

float3 diffuseColor = lerp(lerp(lerp(lerp(__MainTex_var.rgb,__Texture1_var.rgb,__SplatMap_var.r),__Texture2_var.rgb,__SplatMap_var.g),__Texture3_var.rgb,__SplatMap_var.b),__Texture4_var.rgb,__SplatMap_var.a);

float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;

// Final Color:

float3 finalColor = diffuse;

fixed4 finalRGBA = fixed4(finalColor,1);

UNITY_APPLY_FOG(i.fogCoord, finalRGBA);

return finalRGBA;

}

ENDCG

}

Pass {

Name "FORWARD_DELTA"

Tags {

"LightMode"="ForwardAdd"

}

Blend One One





CGPROGRAM

#pragma vertex vert

#pragma fragment frag

#define UNITY_PASS_FORWARDADD

#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )

#include "UnityCG.cginc"

#include "AutoLight.cginc"

#include "Lighting.cginc"

#include "UnityPBSLighting.cginc"

#include "UnityStandardBRDF.cginc"

#pragma multi_compile_fwdadd_fullshadows

#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON

#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE

#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON

#pragma multi_compile_fog

#pragma exclude_renderers xbox360 ps3

#pragma target 2.0

uniform sampler2D __MainTex; uniform float4 __MainTex_ST;

uniform sampler2D __SplatMap; uniform float4 __SplatMap_ST;

uniform sampler2D __Texture1; uniform float4 __Texture1_ST;

uniform sampler2D __Texture2; uniform float4 __Texture2_ST;

uniform sampler2D __Texture3; uniform float4 __Texture3_ST;

uniform sampler2D __Texture4; uniform float4 __Texture4_ST;

struct VertexInput {

float4 vertex : POSITION;

float3 normal : NORMAL;

float4 tangent : TANGENT;

float2 texcoord0 : TEXCOORD0;

float2 texcoord1 : TEXCOORD1;

float2 texcoord2 : TEXCOORD2;

};

struct VertexOutput {

float4 pos : SV_POSITION;

float2 uv0 : TEXCOORD0;

float2 uv1 : TEXCOORD1;

float2 uv2 : TEXCOORD2;

float4 posWorld : TEXCOORD3;

float3 normalDir : TEXCOORD4;

float3 tangentDir : TEXCOORD5;

float3 bitangentDir : TEXCOORD6;

LIGHTING_COORDS(7,8)

};

VertexOutput vert (VertexInput v) {

VertexOutput o = (VertexOutput)0;

o.uv0 = v.texcoord0;

o.uv1 = v.texcoord1;

o.uv2 = v.texcoord2;

o.normalDir = UnityObjectToWorldNormal(v.normal);

o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );

o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);

o.posWorld = mul(_Object2World, v.vertex);

float3 lightColor = _LightColor0.rgb;

o.pos = mul(UNITY_MATRIX_MVP, v.vertex);

TRANSFER_VERTEX_TO_FRAGMENT(o)

return o;

}

float4 frag(VertexOutput i) : COLOR {

i.normalDir = normalize(i.normalDir);

float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);

/// Vectors:

float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);

float3 normalDirection = i.normalDir;

float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));

float3 lightColor = _LightColor0.rgb;

// Lighting:

float attenuation = LIGHT_ATTENUATION(i);

float3 attenColor = attenuation * _LightColor0.xyz;

float Pi = 3.141592654;

float InvPi = 0.31830988618;

/// Diffuse:

float NdotL = max(0.0,dot( normalDirection, lightDirection ));

float3 directDiffuse = max( 0.0, NdotL) * attenColor;

float4 __MainTex_var = tex2D(__MainTex,TRANSFORM_TEX(i.uv0, __MainTex));

float4 __Texture1_var = tex2D(__Texture1,TRANSFORM_TEX(i.uv0, __Texture1));

float4 __SplatMap_var = tex2D(__SplatMap,TRANSFORM_TEX(i.uv0, __SplatMap));

float4 __Texture2_var = tex2D(__Texture2,TRANSFORM_TEX(i.uv0, __Texture2));

float4 __Texture3_var = tex2D(__Texture3,TRANSFORM_TEX(i.uv0, __Texture3));

float4 __Texture4_var = tex2D(__Texture4,TRANSFORM_TEX(i.uv0, __Texture4));

float3 diffuseColor = lerp(lerp(lerp(lerp(__MainTex_var.rgb,__Texture1_var.rgb,__SplatMap_var.r),__Texture2_var.rgb,__SplatMap_var.g),__Texture3_var.rgb,__SplatMap_var.b),__Texture4_var.rgb,__SplatMap_var.a);

float3 diffuse = directDiffuse * diffuseColor;

// Final Color:

float3 finalColor = diffuse;

return fixed4(finalColor * 1,0);

}

ENDCG

}

Pass {

Name "Meta"

Tags {

"LightMode"="Meta"

}

Cull Off



CGPROGRAM

#pragma vertex vert

#pragma fragment frag

#define UNITY_PASS_META 1

#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )

#include "UnityCG.cginc"

#include "Lighting.cginc"

#include "UnityPBSLighting.cginc"

#include "UnityStandardBRDF.cginc"

#include "UnityMetaPass.cginc"

#pragma fragmentoption ARB_precision_hint_fastest

#pragma multi_compile_shadowcaster

#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON

#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE

#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON

#pragma multi_compile_fog

#pragma exclude_renderers xbox360 ps3

#pragma target 2.0

uniform sampler2D __MainTex; uniform float4 __MainTex_ST;

uniform sampler2D __SplatMap; uniform float4 __SplatMap_ST;

uniform sampler2D __Texture1; uniform float4 __Texture1_ST;

uniform sampler2D __Texture2; uniform float4 __Texture2_ST;

uniform sampler2D __Texture3; uniform float4 __Texture3_ST;

uniform sampler2D __Texture4; uniform float4 __Texture4_ST;

struct VertexInput {

float4 vertex : POSITION;

float2 texcoord0 : TEXCOORD0;

float2 texcoord1 : TEXCOORD1;

float2 texcoord2 : TEXCOORD2;

};

struct VertexOutput {

float4 pos : SV_POSITION;

float2 uv0 : TEXCOORD0;

float2 uv1 : TEXCOORD1;

float2 uv2 : TEXCOORD2;

float4 posWorld : TEXCOORD3;

};

VertexOutput vert (VertexInput v) {

VertexOutput o = (VertexOutput)0;

o.uv0 = v.texcoord0;

o.uv1 = v.texcoord1;

o.uv2 = v.texcoord2;

o.posWorld = mul(_Object2World, v.vertex);

o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );

return o;

}

float4 frag(VertexOutput i) : SV_Target {

/// Vectors:

float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);

UnityMetaInput o;

UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );



o.Emission = 0;



float4 __MainTex_var = tex2D(__MainTex,TRANSFORM_TEX(i.uv0, __MainTex));

float4 __Texture1_var = tex2D(__Texture1,TRANSFORM_TEX(i.uv0, __Texture1));

float4 __SplatMap_var = tex2D(__SplatMap,TRANSFORM_TEX(i.uv0, __SplatMap));

float4 __Texture2_var = tex2D(__Texture2,TRANSFORM_TEX(i.uv0, __Texture2));

float4 __Texture3_var = tex2D(__Texture3,TRANSFORM_TEX(i.uv0, __Texture3));

float4 __Texture4_var = tex2D(__Texture4,TRANSFORM_TEX(i.uv0, __Texture4));

float3 diffColor = lerp(lerp(lerp(lerp(__MainTex_var.rgb,__Texture1_var.rgb,__SplatMap_var.r),__Texture2_var.rgb,__SplatMap_var.g),__Texture3_var.rgb,__SplatMap_var.b),__Texture4_var.rgb,__SplatMap_var.a);

o.Albedo = diffColor;



return UnityMetaFragment( o );

}

ENDCG

}

}

FallBack "Diffuse"

CustomEditor "ShaderForgeMaterialInspector"

}


Antwort

Antwort
Not a bug
Ah, glad it worked out!
We are using 5 texture file for this texture. Android version is new one.
Wird überprüft
Odd, don't see anything wrong with it. It could simply be too expensive. Try making it simpler and simpler, and see when it starts working
We found problem. It's double underbar. __ is kinds of reserve key word. that's why fail to use this shader..
Antwort
Not a bug
Ah, glad it worked out!