Jase217
Member
I'm hoping this is only a simple thing to fix, In my 3D game I use the default GPU Fog to obscure things in the distance, I also use a shader to tint sections of rooms in my game with a certain colour to make it lighter or darker.
However if I use a shader on anything including just a normal passthrough shader, it will ignore the fog on whatever I use it on, leaving it fully visible in the distance. I'm guessing this is because the default shader doesn't take the fog into account? I'm still new to shaders so I'm not sure.
Is this something that can be fixed easily?
Here is the code for the shader I use to tint models.
Vertex:
Fragment:
Is there anybody here with experience in shaders that knows how to make it take the standard fog into account?
However if I use a shader on anything including just a normal passthrough shader, it will ignore the fog on whatever I use it on, leaving it fully visible in the distance. I'm guessing this is because the default shader doesn't take the fog into account? I'm still new to shaders so I'm not sure.
Is this something that can be fixed easily?
Here is the code for the shader I use to tint models.
Vertex:
Code:
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
Code:
//
// mask fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec4 f_ChannelMask;
void main()
{
gl_FragColor = (v_vColour * texture2D( gm_BaseTexture, v_vTexcoord )) * f_ChannelMask;
}