submap.frag¶
ogre_media/materials/glsl120/submap.frag is the GLSL 120 fragment shader that renders a submap slice texture into the scene.
#version 120
varying vec2 out_submap_texture_coordinate;
uniform sampler2D u_submap;
uniform float u_alpha;
void main()
{
vec2 texture_value = texture2D(u_submap, out_submap_texture_coordinate).rg;
float value = u_alpha * texture_value.r;
float alpha = u_alpha * texture_value.g;
gl_FragColor = vec4(value, value, value, alpha);
}
The shader reads the red and green channels of the submap texture: the red channel carries the grayscale occupancy intensity, and the green channel carries the pre-multiplied alpha. The u_alpha uniform (set per-slice by OgreSlice::SetAlpha) scales both, and the result is written as a grayscale color with pre-multiplied alpha:
value = u_alpha * intensityalpha = u_alpha * alpha_channeloutput
(value, value, value, alpha)
This is what produces the transparent “X-ray” look when many submaps are composited with the SBF_ONE, SBF_ONE_MINUS_SOURCE_ALPHA blend mode configured in ogre_slice.cpp.