I have searched for a long time and just cant find it. Was hoping one can help me out…
I am looking for a simple water shader that distorts a maintexture to get a refraction effect like:
I don’t need reflections, specular etc, just a slight transparent plane with a texture that gets distorted with a certain speed so it fakes little waves (moving) water…
I tried to use the refraction shader, but when I applied it to a material, it just made the material purple. No refraction or distortion going on. Wat do?
More info: Click on shader, says Shader has errors or not compatible with GPU. I doubt it’s compatibility as my PC is beast. It says surface shader: no. Then also it says error: parse error: syntax error.
Code where error is = line 8.
// Upgrade NOTE: replaced 'PositionFog()' with multiply of UNITY_MATRIX_MVP by position
// Upgrade NOTE: replaced 'V2F_POS_FOG' with 'float4 pos : SV_POSITION'
// Upgrade NOTE: replaced 'glstate.matrix.mvp' with 'UNITY_MATRIX_MVP'
// Upgrade NOTE: replaced 'glstate.matrix.texture[0]' with 'UNITY_MATRIX_TEXTURE0'
// Upgrade NOTE: replaced 'samplerRECT' with 'sampler2D'
// Upgrade NOTE: replaced 'texRECTproj' with 'tex2Dproj'
// Uses geometry normals to distort the image behind, and
// an additional texture to tint the color.
Shader "FX/Refraction Distort" {
Properties {
_BumpAmt ("Distortion", range (0,128)) = 10.0
_MainTex ("Tint Color (RGB)", 2D) = "white" {}
}
I had some ellow errors too, so I changed:
CGPROGRAM
// profiles arbfp1
// vertex vert
// fragment frag
// fragmentoption ARB_precision_hint_fastest
// fragmentoption ARB_fog_exp2
to
CGPROGRAM
// profiles arbfp1
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#pragma fragmentoption ARB_fog_exp2
It said I should use ‘#pragma target’ instead of ‘profiles’, but I couldn’t do ‘#pragma target arbfp1’, so I don’t know. The red error persist. I have no idea what I’m doing. I suck at shaders. This shader doesn’t work.
You know what, you’re absolutely right, I didn’t check the wiki version, it’s absolutely ancient.
Just try the version that comes with Unity. (Assets > Import Package > Glass Refraction (Pro Only)). That one definitely works.
Well… yeah, Render Textures are kind of important to create refraction effects, because you need to move pixel colors from the original scene around, which is hard if you can’t store the data you need to modify. I believe there are some tools available on the Asset Store that create similar effects using the CPU, but I can’t really help you with that.
Even the wiki example uses GrabPass, which requires RenderTexture support.