void CheckAndChangeDepthShader(int kinectIndex)
{
bool colorize = false;
bool scale = false;
if (server.serverMasterOptions.kinectOptionsList[kinectIndex].version == KinectVersion.KinectV1)
{
colorize = ((KinectV1Wrapper.Settings)server.serverMasterOptions.kinectOptionsList[kinectIndex]).colorizeDepth;
scale = ((KinectV1Wrapper.Settings)server.serverMasterOptions.kinectOptionsList[kinectIndex]).scaleDepthToReliableRange;
}
else if (server.serverMasterOptions.kinectOptionsList[kinectIndex].version == KinectVersion.KinectV2)
{
colorize = ((KinectV2Wrapper.Settings)server.serverMasterOptions.kinectOptionsList[kinectIndex]).colorizeDepth;
scale = ((KinectV2Wrapper.Settings)server.serverMasterOptions.kinectOptionsList[kinectIndex]).scaleDepthToReliableRange;
}
//If the options have changed for the shader, we need to setup the new shader
if (scale != scaleDepth || colorize != colorDepth)
{
//Set the variables so we can check if the shader is set right later
scaleDepth = scale;
colorDepth = colorize;
if (scale && colorize)
{
Shaders.ColorScaleEffect effect = new Shaders.ColorScaleEffect();
effect.Minimum = depthMin;
effect.Maximum = depthMax;
depthEffect = effect;
}
else if (scale && !colorize)
{
Shaders.DepthScalingEffect effect = new Shaders.DepthScalingEffect();
effect.Minimum = depthMin;
effect.Maximum = depthMax;
depthEffect = effect;
}
else if (!scale && colorize)
{
Shaders.ColorDepthEffect effect = new Shaders.ColorDepthEffect();
effect.Minimum = depthMin;
effect.Maximum = depthMax;
depthEffect = effect;
}
else //Convert from the bgr32 back to a gray16, but don't do any shading otherwise
{
depthEffect = new Shaders.NoScalingEffect();
}
DepthImage.Effect = depthEffect;
}
}