Suite à mon souci de portage sur iOS (cf ici) j'ai pu obtenir quelques infos et il semblerait que le plus gros souci vienne du shader ci-dessous.
N'y connaissant pas grand chose en shaders pour le moment, quelqu'un d'expérimenté pourrait-il m'indiquer à première vue ce qui pourrait être bloquant pour un fonctionnement correct sur iOS ?
Et éventuellement me rediriger vers quelques sources d'informations adéquates (j'ai déjà trouvé quelques liens, mais c'est un sujet tellement vaste, qu'un peu de débroussaillage d'une personne avisée ne serait pas de refus )
Code : Tout sélectionner
Shader "Puffy_Smoke/FakedVolumetric 2 details" {
Properties {
_ShadowColor ("Shadow Color", Color) = (0.0,0.5,0.5,1)
_MainTex ("Particle Texture", 2D) = "white" {}
_DetailTex ("Particle start details", 2D) = "white" {}
_DetailTex2 ("Particle end details", 2D) = "white" {}
_FadeIn ("Fade in", Range(0.0,1.0)) = 0.1
_Opacity ("Opacity", Range(0.0,1.0)) = 0.5
_Scattering ("Scattering", Range(0.0,1.0)) = 1
_Density ("Density", Range(0.0,1.0)) = 0
_EmissiveDensity ("Emissive Density", Range(0.0,1.0)) = 0.1
_Sharpness ("Sharpness", Range(0.0,5.0)) = 0
_DetailsSpeed ("Details Speed", Range(0.0,5.0)) = 0.2
}
Category {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest Greater 0.01
ColorMask RGB
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "texcoord", texcoord0
Bind "texcoord1", texcoord1
}
//Subshader{
// UsePass "VertexLit/SHADOWCOLLECTOR"
// UsePass "VertexLit/SHADOWCASTER"
//}
// ---- Fragment program cards
SubShader {
Pass {
CGPROGRAM
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _DetailTex;
sampler2D _DetailTex2;
sampler2D _CameraDepthTexture;
fixed4 _ShadowColor;
fixed4 _AmbientColor;
fixed4 _LightColor;
float4 _MainTex_ST;
float4 _DetailTex_ST;
float _FadeIn;
float _Density;
float _DetailsSpeed;
float _Sharpness;
float _Scattering;
float _Opacity;
float _details;
float _LightIntensity;
float _InvFade;
float _EmissiveDensity;
struct vertexInput {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
float3 normal : NORMAL;
};
struct vertexOutput {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
float3 normal : TEXCOORD2;
};
vertexOutput vert (vertexInput input)
{
vertexOutput output;
output.vertex = mul(UNITY_MATRIX_MVP, input.vertex);
output.color = input.color;
output.texcoord = TRANSFORM_TEX(input.texcoord,_MainTex);
output.texcoord1 = TRANSFORM_TEX(input.texcoord1,_DetailTex);
output.normal = input.normal;
return output;
}
fixed4 frag (vertexOutput i) : COLOR
{
// get main texture color and alpha
float4 _sampled = tex2D(_MainTex, i.texcoord);
float _old = i.normal.x;
float _young = 1 - _old;
float _emissive = i.normal.y;
// particle base color
float4 _particlecolor = i.color;
_particlecolor.r *= (max(0,_LightColor.r - _emissive) * _LightIntensity) + _emissive;
_particlecolor.g *= (max(0,_LightColor.g - _emissive) * _LightIntensity) + _emissive;
_particlecolor.b *= (max(0,_LightColor.b - _emissive) * _LightIntensity) + _emissive;
// emissive particles are less transparent
_sampled.a *= i.color.a * (1+_emissive*_emissive*2);
// mix light color and shadow color
float4 _finalcolor = lerp(_ShadowColor , _particlecolor , clamp(_sampled.r + _emissive,0,1)) + (_AmbientColor * (1-_emissive));
// older particles receive more light color
if(_Scattering > 0) _finalcolor.rgb = lerp(_finalcolor.rgb , lerp(_finalcolor.rgb , _particlecolor.rgb + _AmbientColor.rgb , _old), _Scattering);
if(_Density < 1){
// animated noise
_details = lerp(tex2D(_DetailTex, i.texcoord1 + (_young * _DetailsSpeed)).r , tex2D(_DetailTex2, i.texcoord1 + (_young * _DetailsSpeed)).r,_old);
_details = clamp(lerp((0.5+_details) * 0.5, _details , _old*_Sharpness) + _Density,0,1);
_sampled.a *= _details + _emissive * _EmissiveDensity; // emissive particles have less visible details, fixed here to 10% of the emissive value
}
// main alpha
_finalcolor.a = _Opacity * _sampled.a * _young;
if(_FadeIn>0) _finalcolor.a *= clamp(_old / _FadeIn,0,1);
return _finalcolor;
}
ENDCG
}
}
// ---- Dual texture cards
SubShader {
Pass {
SetTexture [_MainTex] {
constantColor [_TintColor]
Combine texture * constant DOUBLE, texture * primary
}
SetTexture [_DetailTex] {
Combine previous,previous * texture
}
}
}
// ---- Single texture cards (does not do color tint)
SubShader {
Pass {
SetTexture [_MainTex] {
combine texture * primary
}
}
}
}
}