#### Gun_Goose

##### Member

The current shader I am testing is one I found on the market place:

vertex:

Code:

```
//
// Simple passthrough vertex shader
//
attribute vec4 in_Position;
//attribute vec3 in_Normal;
attribute vec4 in_Colour;
attribute vec2 in_TextureCoord;
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
varying vec4 WorldPos;
void main()
{
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * in_Position;
WorldPos = gm_Matrices[MATRIX_WORLD] * in_Position;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
```

Code:

```
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
varying vec4 WorldPos;
uniform vec3 u_fog_colour; //Red, Green, Blue
uniform vec3 u_fog_height; //Z near, Z height, Falloff
uniform vec3 u_camera_position; //Cameras X, Y, Z
void main()
{
vec4 base = texture2D(gm_BaseTexture, v_vTexcoord);
float dist = length(WorldPos.xyz - u_camera_position);
float fog = u_fog_height.z * smoothstep(u_fog_colour.z, u_fog_height.x, u_fog_height.y - WorldPos.z);
float ext = exp2(-dist * fog);
vec3 finalColor = base.rgb * vec3(ext,ext,ext) + u_fog_colour.rgb * (1.0 - ext);
gl_FragColor = /*v_vColour * */vec4(finalColor, 1.0);
}
```

Code:

```
shader_set(sh_fog_try);
shader_color = shader_get_uniform(sh_fog_try, "u_fog_colour")
shader_height = shader_get_uniform(sh_fog_try, "u_fog_height")
shader_pos = shader_get_uniform(sh_fog_try, "u_camera_position")
shader_set_uniform_f(shader_color, 0, 0, 0);
shader_set_uniform_f(shader_height, 100, 25, 0.04);
shader_set_uniform_f(shader_pos, p_x, p_y, p_z);
draw_surface(application_surface,0,0)
shader_reset()
```