- Home /
Question by
xtian-diaz · May 02, 2016 at 08:31 PM ·
iosshadersshaderlab
Surface Shader optimization for iOS
Hello everyone,
using my basic knowledge in shader wrtting, I managed to write this shader that simulates a nice and simple transparent water effect :
Shader "darkroom/Animated Liquid Surface"
{
Properties
{
_BumpMap ("Normal Map 1", 2D) = "white" {}
_NoiseMap ("Noise Map", 2D) = "black" {}
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" "IgnoreProjector"="True" }
Blend SrcAlpha One
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _BumpMap;
sampler2D _NoiseMap;
half4 _ReflectColor;
struct Input
{
float2 uv_BumpMap;
};
void surf (Input IN, inout SurfaceOutput o)
{
half3 noise = tex2D(_NoiseMap, IN.uv_BumpMap);
half f = frac(_Time[1] * 0.05 + noise.r * 0.5);
half n1 = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap + half3(1.0 - f,0,0)));
half n2 = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap + half3(f,0,0)));
o.Emission = lerp(n1, n2, f) * _ReflectColor;
}
ENDCG
}
FallBack "Reflective/Bumped Specular"
}
I'm currently getting decent performance using it in an iPad 2 (~35 fps), but I need to improve it significantly, for which I'm hoping to get from you some neat hints.
This is a preview of how it looks and tells about my current setup. The liquid must be transparent so to show the underlying gameplay area. Also, the scene is lit, that's why I'm using a surface type of shader.
Thanks in advance for any help.
screen-shot-2016-05-02-at-110123-pm.png
(367.8 kB)
Comment
Your answer
