Less shader boilerplate
This commit is contained in:
@@ -63,13 +63,14 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
|
||||
depthMask(false);
|
||||
|
||||
useProgram(rasterShader->program);
|
||||
rasterShader->setMatrix(matrix);
|
||||
rasterShader->setBuffer(0);
|
||||
rasterShader->setOpacity(properties.opacity);
|
||||
rasterShader->setBrightness(properties.brightness[0], properties.brightness[1]);
|
||||
rasterShader->setSaturation(properties.saturation);
|
||||
rasterShader->setContrast(properties.contrast);
|
||||
rasterShader->setSpin(spinWeights(properties.hue_rotate));
|
||||
rasterShader->u_matrix = matrix;
|
||||
rasterShader->u_buffer = 0;
|
||||
rasterShader->u_opacity = properties.opacity;
|
||||
rasterShader->u_brightness_low = properties.brightness[0];
|
||||
rasterShader->u_brightness_high = properties.brightness[1];
|
||||
rasterShader->u_saturation_factor = saturationFactor(properties.saturation);
|
||||
rasterShader->u_contrast_factor = contrastFactor(properties.contrast);
|
||||
rasterShader->u_spin_weights = spinWeights(properties.hue_rotate);
|
||||
|
||||
depthRange(strata + strata_epsilon, 1.0f);
|
||||
|
||||
@@ -80,6 +81,22 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
|
||||
|
||||
}
|
||||
|
||||
float Painter::saturationFactor(float saturation) {
|
||||
if (saturation > 0) {
|
||||
return 1 - 1 / (1.001 - saturation);
|
||||
} else {
|
||||
return -saturation;
|
||||
}
|
||||
}
|
||||
|
||||
float Painter::contrastFactor(float contrast) {
|
||||
if (contrast > 0) {
|
||||
return 1 / (1 - contrast);
|
||||
} else {
|
||||
return 1 + contrast;
|
||||
}
|
||||
}
|
||||
|
||||
std::array<float, 3> Painter::spinWeights(float spin) {
|
||||
spin *= M_PI / 180;
|
||||
float s = std::sin(spin);
|
||||
|
||||
Reference in New Issue
Block a user