Ok, I thought I would try to make water to go in one of my levels and I wanted something other than a decal, so I tried the red eye and hockey kid's thing and I missed something. As you can see in the screenie, the water shader is not working. All of my other shaders are working, even the custom ones, but this one is not working for me. I saw that others have and thought that since this is part of my work in progress I would just ask "What is my problem here?" I did a test of 30 frames in blender for the water in the level and it works, but this looks just as good and easier. Help would be nice, Thanks.
THE(WATER)WASSER.FX
/******************************************************************************
* The following code was generated by the mental mill(tm) *
* *
* Copyright 1986-2007 by mental images GmbH, Fasanenstr. 81, D-10623 *
* Berlin, Germany. All rights reserved. *
/*****************************************************************************/
//
// Values for the light_type parameter of light shaders
//
#define LIGHT_POINT 0
#define LIGHT_SPOT 1
#define LIGHT_INFINITE 2
#define LIGHT_PLANAR 3
//
// The light iterator structure holds the return values resulting from
// evaluating a light.
//
struct Light_iterator {
float3 _point;
float4 contribution;
float raw_contribution;
float dot_nl;
float3 direction;
float distance;
float4 shadow;
int count;
};
struct Ray {
float3 origin;
float3 direction;
};
Ray __Ray_ctor(float3 o, float3 d)
{
Ray r;
r.origin = o;
r.direction = d;
return r;
}
float2 __float2_ctor(float v)
{
return v.xx;
}
float3 __float3_ctor(float v)
{
return v.xxx;
}
float4 __float4_ctor(float v)
{
return v.xxxx;
}
float4 __tex2D_flip_v(sampler2D samp, float2 uv)
{
return tex2D(samp, float2(uv.x, 1.0-uv.y));
}
float4 __tex2D_flip_v(sampler2D samp, float2 uv, float2 ddu, float2 ddv)
{
return tex2D(samp, float2(uv.x, 1.0-uv.y), ddu, ddv);
}
float mi_falloff(
float3 direction,
float3 normal,
float amount)
{
float f;
f = (saturate((dot((-direction), normal))));
f = (1.0 - (pow(f, (1.0 / amount))));
return f;
}
//
// The state structure is used internally within the fragment shader to
// commonly used values.
//
struct State
{
float4 tex_coord[4];
float3 position;
float3 normal;
float3 direction;
float ray_length;
float3x3 tangent_space[1];
float4 volume_input;
};
//
// The following are free parameters of the shader that should be set by the
// application at runtime.
//
texture __Environment_map_cubic_1_env_tex <
string UIName = "Environment_map_cubic_1_env_tex";
string ResourceName = "default_reflection_cubic.dds";
string ResourceType = "Cube";
>;
samplerCUBE Environment_map_cubic_1_env_tex = sampler_state {
Texture = <__Environment_map_cubic_1_env_tex>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
AddressW = Clamp;
};
float Environment_map_cubic_1_intensity
<
string UIName = "Intensity";
float UIMin = 0.000000;
float UIMax = 10.000000;
float UIStep = 0.01;
string UIWidget = "slider";
> = 0.750000;
float Volume_fog_linear_1_falloff_start
<
string UIName = "Falloff Start";
float UIMin = 999999.000000;
float UIMax = 999999.000000;
float UIStep = 0.01;
string UIWidget = "slider";
> = 999999.000000;
float Volume_fog_linear_1_falloff_end
<
string UIName = "Falloff Start";
float UIMin = 999999.000000;
float UIMax = 999999.000000;
float UIStep = 0.01;
string UIWidget = "slider";
> = 999999.000000;
float Volume_fog_linear_1_falloff_distance_scale
<
string UIName = "Falloff Distance Scale";
float UIMin = 0.001000;
float UIMax = 100.000000;
float UIStep = 0.01;
string UIWidget = "slider";
> = 1.000000;
float4 Volume_fog_linear_1_fog_color
<
string UIName = "Fog Color";
float4 UIMin = float4(0.000000, 0.000000, 0.000000, 0.000000);
float4 UIMax = float4(1.000000, 1.000000, 1.000000, 1.000000);
float UIStep = 0.01;
string UIWidget = "slider";
> = { 0.400000, 0.600000, 0.800000, 1.000000 };
texture __Generator_water_normal_1_noise_texture <
string UIName = "Generator_water_normal_1_noise_texture";
string ResourceName = "unfiltered_noise_normal.dds";
string ResourceType = "2D";
>;
sampler2D Generator_water_normal_1_noise_texture = sampler_state {
Texture = <__Generator_water_normal_1_noise_texture>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
float Generator_water_normal_1_wave_speed
<
string UIName = "Wave Speed";
float UIMin = 0.000000;
float UIMax = 0.500000;
float UIStep = 0.01;
string UIWidget = "slider";
> = 0.005000;
float Component_falloff_1_amount
<
string UIName = "Falloff Amount";
float UIMin = 0.000000;
float UIMax = 4.000000;
float UIStep = 0.01;
string UIWidget = "slider";
> = 1.000000;
//
// The following are parameters representing non-varying state variables
// referenced by the shader. These should be set by the application at runtime.
// Note that vector parameters should be provided in camera space.
//
float __refracted_ior = 1.010000;
float __incident_ior = 1.000000;
float __animation_time : Time
<
string Units = "seconds";
> = 0;
float4x4 __object_to_camera : WorldView
<
string UIWidget = "none";
>;
float4x4 __object_to_raster : WorldViewProjection
<
string UIWidget = "none";
>;
float4x4 __camera_to_world : ViewInverse
<
string UIWidget = "none";
>;
float4x4 __camera_to_object : WorldViewInverse
<
string UIWidget = "none";
>;
//
// The App2vert structure defines the vertex attributes used by the vertex
// shader. The application should supply a vertex stream containing these
// elements.
//
struct App2vert
{
float4 position : POSITION;
float3 normal : NORMAL;
float4 tex_coord0 : TEXCOORD0;
float4 tex_coord1 : TEXCOORD1;
float4 tex_coord2 : TEXCOORD2;
float4 tex_coord3 : TEXCOORD3;
float3 tex_tangent : TANGENT;
float3 tex_binormal : BINORMAL;
};
//
// The Vert2frag structure defines values used by the fragment shader and
// supplied by the vertex shader.
//
struct Vert2frag
{
float4 hpos : POSITION;
float4 tex_coord[4] : TEXCOORD0;
float3 tex_tangent[1] : TEXCOORD4;
float3 tex_binormal[1] : TEXCOORD5;
float3 position : TEXCOORD6;
float3 normal : TEXCOORD7;
};
//
// This function is the main method of the vertex shader.
//
Vert2frag vertex_main(
App2vert vs_in)
{
Vert2frag vs_out;
vs_out.hpos = mul(vs_in.position, __object_to_raster);
vs_out.position = mul(vs_in.position, __object_to_camera).xyz;
vs_out.normal = mul((float3x3)__camera_to_object, vs_in.normal);
vs_out.tex_coord[0] = vs_in.tex_coord0;
vs_out.tex_coord[1] = vs_in.tex_coord1;
vs_out.tex_coord[2] = vs_in.tex_coord2;
vs_out.tex_coord[3] = vs_in.tex_coord3;
vs_out.tex_tangent[0] = mul(vs_in.tex_tangent, (float3x3)__object_to_camera);
vs_out.tex_binormal[0] = mul(vs_in.tex_binormal, (float3x3)__object_to_camera);
return vs_out;
}
//
// The following functions are generated from the MetaSL implementation of
// the shaders that are part of the compiled shader graph.
//
void Environment_map_cubic_main(
samplerCUBE env_tex,
float intensity,
State state,
out float4 result)
{
{
float3 v = mul((state.direction), ((float3x3 )(__camera_to_world)));
result = (texCUBE(env_tex, v.xyz));
result *= intensity;
}
}
void Environment_map_cubic_1_main(
State state,
out float4 result)
{
{
Environment_map_cubic_main(Environment_map_cubic_1_env_tex, Environment_map_cubic_1_intensity, (state), result);
}
}
float4 __reflect_environment(
State state)
{
(state.direction) = (reflect((state.position), (state.normal)));
float4 result;
Environment_map_cubic_1_main((state), result);
return result;
}
float4 __refract_environment(
State state)
{
(state.direction) = (refract((state.position), (state.normal), ((__refracted_ior) / (__incident_ior))));
float4 result;
Environment_map_cubic_1_main((state), result);
return result;
}
float4 __trace_environment(
State state,
Ray ray)
{
(state.position) = ray.origin;
(state.direction) = ray.direction;
float4 result;
Environment_map_cubic_1_main((state), result);
return result;
}
void Volume_fog_linear_main(
float falloff_start,
float falloff_end,
float falloff_distance_scale,
float4 fog_color,
State state,
out float4 result)
{
{
float distance = state.ray_length;
float atten = ((distance / falloff_distance_scale) - falloff_start) / (falloff_end - falloff_start);
result = (lerp((state.volume_input), fog_color, (saturate(atten))));
}
}
void Volume_fog_linear_1_main(
State state,
out float4 result)
{
{
Volume_fog_linear_main(Volume_fog_linear_1_falloff_start, Volume_fog_linear_1_falloff_end, Volume_fog_linear_1_falloff_distance_scale, Volume_fog_linear_1_fog_color, (state), result);
}
}
void Generator_water_normal_main(
sampler2D noise_texture,
float wave_speed,
State state,
out float3 result)
{
{
float2 uv1 = (state.tex_coord)[0].xy;
float2 uv2 = float2(uv1.y, (-uv1.x));
float anim = (__animation_time) * wave_speed;
uv1.x += anim;
uv2.x += anim;
float4 wave1 = __tex2D_flip_v(noise_texture, uv1);
float4 wave2 = __tex2D_flip_v(noise_texture, uv2);
float3 n1 = ((wave1 - 0.5) * 2.0).xyz;
float3 n2 = ((wave2 - 0.5) * 2.0).xyz;
result = (normalize((mul((state.tangent_space)[0], (n1 + n2)))));
}
}
void Component_refraction_main(
State state,
out float4 result)
{
{
result = (__trace_environment((state), (__Ray_ctor((state.position), (refract((state.direction), (state.normal), ((__refracted_ior) / (__incident_ior))))))));
}
}
void Component_reflection_main(
State state,
out float4 result)
{
{
result = (__trace_environment((state), (__Ray_ctor((state.position), (reflect((state.direction), (state.normal)))))));
}
}
void Component_falloff_main(
float amount,
State state,
out float4 result)
{
{
float falloff = mi_falloff((state.direction), (state.normal), amount);
result = (float4(falloff, falloff, falloff, 1.0));
}
}
void Math_color_lerp_main(
float4 start,
float4 end,
float4 location,
State state,
out float4 result)
{
{
result = (lerp(start, end, location));
}
}
//
// The following method is the root function of the shader graph
//
float4 Math_color_lerp_1_eval(State state)
{
float4 result;
float3 Generator_water_normal_1_result = float3(0.000000, 0.000000, 0.000000);
Generator_water_normal_main(Generator_water_normal_1_noise_texture, Generator_water_normal_1_wave_speed, (state), Generator_water_normal_1_result);
float4 Component_refraction_1_result = float4(0.000000, 0.000000, 0.000000, 0.000000);
{
float3 temp0 = state.normal;
(state.normal) = Generator_water_normal_1_result;
Component_refraction_main((state), Component_refraction_1_result);
(state.normal) = temp0;
}
float4 Component_reflection_1_result = float4(0.000000, 0.000000, 0.000000, 0.000000);
{
float3 temp0 = state.normal;
(state.normal) = Generator_water_normal_1_result;
Component_reflection_main((state), Component_reflection_1_result);
(state.normal) = temp0;
}
float4 Component_falloff_1_result = float4(0.000000, 0.000000, 0.000000, 0.000000);
Component_falloff_main(Component_falloff_1_amount, (state), Component_falloff_1_result);
Math_color_lerp_main(Component_refraction_1_result, Component_reflection_1_result, Component_falloff_1_result, (state), result);
(state.volume_input) = result;
Volume_fog_linear_1_main((state), result);
return result;
}
//
// This function is the main method of the fragment shader. It initializes the
// values in the state structure that are used by nodes in the shader graph
// and produces the final result of the shader.
//
float4 fragment_main(
Vert2frag fs_in) : COLOR
{
State state;
state.position = fs_in.position;
state.normal = normalize(fs_in.normal);
state.tex_coord = fs_in.tex_coord;
state.ray_length = length(state.position);
state.direction = state.position/state.ray_length;
state.tangent_space[0] = transpose(float3x3(
normalize(fs_in.tex_tangent[0]),
normalize(fs_in.tex_binormal[0]),
state.normal));
state.volume_input = 0;
return Math_color_lerp_1_eval(state);
}
//
// The following define the default technique and pass of the effect.
//
technique T0
{
pass P0
{
ZEnable = true;
ZWriteEnable = true;
CullMode = none;
VertexShader = compile vs_3_0 vertex_main();
PixelShader = compile ps_3_0 fragment_main();
}
}
