feat: flash light effect
This commit is contained in:
1 parent
d196e6dce2
commit
763b9ff097
29 files changed
+167
-4
No files matched your search
@@ -8,7 +8,7 @@ import com.hinnka.mycamera.raw.RawToneMappingParameters
|
||||
|
||||
@Database(
|
||||
entities = [GalleryMediaEntity::class],
|
||||
version = 29,
|
||||
version = 30,
|
||||
exportSchema = false
|
||||
)
|
||||
@androidx.room.TypeConverters(GalleryConverters::class)
|
||||
@@ -242,6 +242,13 @@ abstract class GalleryDatabase : RoomDatabase() {
|
||||
}
|
||||
}
|
||||
|
||||
private val MIGRATION_29_30 = object : androidx.room.migration.Migration(29, 30) {
|
||||
override fun migrate(db: androidx.sqlite.db.SupportSQLiteDatabase) {
|
||||
db.execSQL("ALTER TABLE gallery_media ADD COLUMN recipe_flash REAL")
|
||||
db.execSQL("ALTER TABLE gallery_media ADD COLUMN baseline_recipe_flash REAL")
|
||||
}
|
||||
}
|
||||
|
||||
private fun rebuildGalleryMediaWithoutLegacyGoogleToneMapFlag(
|
||||
db: androidx.sqlite.db.SupportSQLiteDatabase
|
||||
) {
|
||||
@@ -602,7 +609,8 @@ abstract class GalleryDatabase : RoomDatabase() {
|
||||
MIGRATION_25_26,
|
||||
MIGRATION_26_27,
|
||||
MIGRATION_27_28,
|
||||
MIGRATION_28_29
|
||||
MIGRATION_28_29,
|
||||
MIGRATION_29_30
|
||||
)
|
||||
.fallbackToDestructiveMigrationOnDowngrade(false)
|
||||
.fallbackToDestructiveMigration(false)
|
||||
|
||||
@@ -72,6 +72,7 @@ object BakedLutExporter {
|
||||
return copy(
|
||||
filmGrain = 0f,
|
||||
vignette = 0f,
|
||||
flash = 0f,
|
||||
bloom = 0f,
|
||||
softLight = 0f,
|
||||
halation = 0f,
|
||||
|
||||
@@ -36,6 +36,7 @@ internal data class ColorPassLocations(
|
||||
val uBasicToneIntensityLocation: Int,
|
||||
val uFilmGrainLocation: Int,
|
||||
val uVignetteLocation: Int,
|
||||
val uFlashLocation: Int,
|
||||
val uBleachBypassLocation: Int,
|
||||
val uChromaticAberrationLocation: Int,
|
||||
val uNoiseLocation: Int,
|
||||
@@ -132,6 +133,7 @@ internal class PreviewColorProgramCache {
|
||||
uBasicToneIntensityLocation = GLES30.glGetUniformLocation(program, "uBasicToneIntensity"),
|
||||
uFilmGrainLocation = GLES30.glGetUniformLocation(program, "uFilmGrain"),
|
||||
uVignetteLocation = GLES30.glGetUniformLocation(program, "uVignette"),
|
||||
uFlashLocation = GLES30.glGetUniformLocation(program, "uFlash"),
|
||||
uBleachBypassLocation = GLES30.glGetUniformLocation(program, "uBleachBypass"),
|
||||
uChromaticAberrationLocation = GLES30.glGetUniformLocation(program, "uChromaticAberration"),
|
||||
uNoiseLocation = GLES30.glGetUniformLocation(program, "uNoise"),
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.hinnka.mycamera.lut
|
||||
|
||||
/**
|
||||
* 屏幕空间直闪模拟。
|
||||
*
|
||||
* 单张图像没有深度与遮挡信息,因此这里模拟与镜头同轴的照明分布:
|
||||
* 中央获得较高曝光增益,边缘快速衰减,并对原有高光做保护。
|
||||
*/
|
||||
internal object DirectFlashShader {
|
||||
val GLSL = """
|
||||
vec3 applyDirectFlash(
|
||||
vec3 srgbColor,
|
||||
vec2 uv,
|
||||
float aspectRatio,
|
||||
float strength
|
||||
) {
|
||||
float safeStrength = clamp(strength, 0.0, 1.0);
|
||||
if (safeStrength <= 0.0001) {
|
||||
return srgbColor;
|
||||
}
|
||||
|
||||
float safeAspect = max(aspectRatio, 0.001);
|
||||
vec2 centered = (uv - vec2(0.5)) * vec2(safeAspect, 1.0);
|
||||
float cornerRadius = length(vec2(0.5 * safeAspect, 0.5));
|
||||
float normalizedRadius = length(centered) / max(cornerRadius, 0.001);
|
||||
float radialCore = 1.0 - smoothstep(0.08, 1.0, normalizedRadius);
|
||||
float illumination = mix(0.10, 1.0, pow(radialCore, 1.35));
|
||||
|
||||
vec3 linearColor = max(srgbToLinear(max(srgbColor, vec3(0.0))), vec3(0.0));
|
||||
float linearLuma = dot(linearColor, vec3(0.2126, 0.7152, 0.0722));
|
||||
float highlightProtection = mix(
|
||||
1.0,
|
||||
0.35,
|
||||
smoothstep(0.45, 1.0, linearLuma)
|
||||
);
|
||||
float exposureEv = 1.65 * safeStrength * illumination * highlightProtection;
|
||||
float localStrength = safeStrength * illumination;
|
||||
vec3 flashWhite = mix(
|
||||
vec3(1.0),
|
||||
vec3(0.985, 1.0, 1.035),
|
||||
localStrength
|
||||
);
|
||||
|
||||
vec3 litLinear = linearColor * exp2(exposureEv) * flashWhite;
|
||||
float shoulder = 0.18 * localStrength;
|
||||
litLinear /= vec3(1.0) + litLinear * shoulder;
|
||||
return linearToSrgb(max(litLinear, vec3(0.0)));
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
@@ -1023,6 +1023,7 @@ class LutImageProcessor(context: Context? = null) {
|
||||
val tonePivot = effectiveRecipeParams?.tonePivot ?: 0f
|
||||
val filmGrain = effectiveRecipeParams?.filmGrain ?: 0f
|
||||
val vignette = effectiveRecipeParams?.vignette ?: 0f
|
||||
val flash = effectiveRecipeParams?.flash ?: 0f
|
||||
val bleachBypass = effectiveRecipeParams?.bleachBypass ?: 0f
|
||||
val bloom = effectiveRecipeParams?.bloom ?: 0f
|
||||
val halation = 0f
|
||||
@@ -1088,6 +1089,7 @@ class LutImageProcessor(context: Context? = null) {
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(program, "uTonePivot"), tonePivot)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(program, "uFilmGrain"), filmGrain)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(program, "uVignette"), vignette)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(program, "uFlash"), flash)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(program, "uBleachBypass"), bleachBypass)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(program, "uNoise"), noise)
|
||||
GLES30.glUniform1f(
|
||||
@@ -3551,6 +3553,7 @@ class LutImageProcessor(context: Context? = null) {
|
||||
uniform float uTonePivot; // -1.0 ~ +1.0 (曲线中点偏移)
|
||||
uniform float uFilmGrain; // 0.0 ~ 1.0 (颗粒强度)
|
||||
uniform float uVignette; // -1.0 ~ +1.0 (晕影)
|
||||
uniform float uFlash; // 0.0 ~ 1.0 (镜头轴向直闪模拟)
|
||||
uniform float uBleachBypass; // 0.0 ~ 1.0 (留银冲洗强度)
|
||||
uniform float uNoise; // 0.0 ~ 1.0 (噪点)
|
||||
uniform float uNoiseSeed; // 噪点随机种子
|
||||
@@ -3586,6 +3589,7 @@ class LutImageProcessor(context: Context? = null) {
|
||||
${PreviewColorShaderModules.COLOR_TRANSFER_CORE}
|
||||
${PreviewColorShaderModules.HLG_TO_LINEAR}
|
||||
${PreviewColorShaderModules.EXPOSURE}
|
||||
${DirectFlashShader.GLSL}
|
||||
${PreviewColorShaderModules.SANITIZE}
|
||||
${BasicToneLutShader.GLSL}
|
||||
|
||||
@@ -3811,6 +3815,11 @@ class LutImageProcessor(context: Context? = null) {
|
||||
color.rgb = mix(color.rgb, desaturated, uBleachBypass);
|
||||
}
|
||||
|
||||
if (uFlash > 0.001) {
|
||||
color.rgb = applyDirectFlash(color.rgb, uvCoord, uAspectRatio, uFlash);
|
||||
color.rgb = sanitizeColor(color.rgb);
|
||||
}
|
||||
|
||||
// 9. 晕影(Vignette - 边缘光线衰减/增强)
|
||||
if (abs(uVignette) > 0.0) {
|
||||
// 计算从中心到边缘的距离
|
||||
|
||||
@@ -47,7 +47,7 @@ class LutManager(private val context: Context) {
|
||||
"exposure", "contrast", "saturation", "temperature", "tint", "fade", "color",
|
||||
"highlights", "shadows", "toneToe", "toneShoulder", "tonePivot",
|
||||
"paletteX", "paletteY", "paletteDensity",
|
||||
"filmGrain", "vignette", "bleachBypass", "bloom", "softLight", "halation", "redHalation", "chromaticAberration",
|
||||
"filmGrain", "vignette", "flash", "bleachBypass", "bloom", "softLight", "halation", "redHalation", "chromaticAberration",
|
||||
"noise", "lowRes",
|
||||
"skinHue", "skinChroma", "skinLightness",
|
||||
"redHue", "redChroma", "redLightness",
|
||||
@@ -84,6 +84,7 @@ class LutManager(private val context: Context) {
|
||||
paletteDensity = f("paletteDensity", 1f),
|
||||
filmGrain = f("filmGrain"),
|
||||
vignette = f("vignette"),
|
||||
flash = f("flash"),
|
||||
bleachBypass = f("bleachBypass"),
|
||||
bloom = f("bloom"),
|
||||
softLight = f("softLight"),
|
||||
|
||||
@@ -418,6 +418,9 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
|
||||
@Volatile
|
||||
var vignette: Float = 0f // -1.0 ~ +1.0
|
||||
|
||||
@Volatile
|
||||
var flash: Float = 0f // 0.0 ~ 1.0
|
||||
|
||||
@Volatile
|
||||
var bleachBypass: Float = 0f // 0.0 ~ 1.0
|
||||
|
||||
@@ -1448,6 +1451,7 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
|
||||
GLES30.glUniform1f(locations.uTonePivotLocation, params.tonePivot)
|
||||
GLES30.glUniform1f(locations.uFilmGrainLocation, params.filmGrain)
|
||||
GLES30.glUniform1f(locations.uVignetteLocation, params.vignette)
|
||||
GLES30.glUniform1f(locations.uFlashLocation, params.flash)
|
||||
GLES30.glUniform1f(locations.uBleachBypassLocation, params.bleachBypass)
|
||||
GLES30.glUniform1f(locations.uNoiseLocation, params.noise)
|
||||
GLES30.glUniform1f(locations.uNoiseSeedLocation, (System.currentTimeMillis() % 10000) / 1000f)
|
||||
@@ -3900,6 +3904,7 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
|
||||
fade = fade,
|
||||
filmGrain = filmGrain,
|
||||
vignette = vignette,
|
||||
flash = flash,
|
||||
bleachBypass = bleachBypass,
|
||||
bloom = bloom,
|
||||
softLight = softLight,
|
||||
@@ -3981,6 +3986,7 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
|
||||
paletteDensity = params.paletteDensity
|
||||
filmGrain = params.filmGrain
|
||||
vignette = params.vignette
|
||||
flash = params.flash
|
||||
bleachBypass = params.bleachBypass
|
||||
bloom = params.bloom
|
||||
softLight = params.softLight
|
||||
|
||||
@@ -54,6 +54,7 @@ internal object PreviewColorShader {
|
||||
uniform float uTonePivot;
|
||||
uniform float uFilmGrain;
|
||||
uniform float uVignette;
|
||||
uniform float uFlash;
|
||||
uniform float uBleachBypass;
|
||||
uniform float uChromaticAberration;
|
||||
uniform float uNoise;
|
||||
@@ -73,6 +74,7 @@ internal object PreviewColorShader {
|
||||
${PreviewColorShaderModules.COLOR_TRANSFER_CORE}
|
||||
${if (variant.includeHlgInput) PreviewColorShaderModules.HLG_TO_LINEAR else PreviewColorShaderModules.HLG_TO_LINEAR_STUB}
|
||||
${PreviewColorShaderModules.EXPOSURE}
|
||||
${DirectFlashShader.GLSL}
|
||||
${PreviewColorShaderModules.SANITIZE}
|
||||
${BasicToneLutShader.GLSL}
|
||||
|
||||
@@ -224,6 +226,11 @@ internal object PreviewColorShader {
|
||||
color.rgb = sanitizeColor(color.rgb);
|
||||
}
|
||||
|
||||
if (uFlash > 0.001) {
|
||||
color.rgb = applyDirectFlash(color.rgb, vTexCoord, uAspectRatio, uFlash);
|
||||
color.rgb = sanitizeColor(color.rgb);
|
||||
}
|
||||
|
||||
if (abs(uVignette) > 0.001) {
|
||||
float dist = distance(vTexCoord, vec2(0.5));
|
||||
float vignetteMask = smoothstep(0.8, 0.3, dist);
|
||||
|
||||
@@ -108,6 +108,7 @@ private class VideoLutShaderProgram(
|
||||
uniform float uTonePivot; // -1.0 ~ +1.0
|
||||
uniform float uFilmGrain; // 0.0 ~ 1.0
|
||||
uniform float uVignette; // -1.0 ~ +1.0
|
||||
uniform float uFlash; // 0.0 ~ 1.0
|
||||
uniform float uBleachBypass; // 0.0 ~ 1.0
|
||||
uniform float uNoise; // 0.0 ~ 1.0
|
||||
uniform float uNoiseSeed; // 噪点随机种子
|
||||
@@ -173,6 +174,8 @@ private class VideoLutShaderProgram(
|
||||
return linearToSrgb(linearColor);
|
||||
}
|
||||
|
||||
${DirectFlashShader.GLSL}
|
||||
|
||||
float sanitizeFloat(float value) {
|
||||
if (value != value) return 0.0;
|
||||
return value;
|
||||
@@ -596,6 +599,11 @@ private class VideoLutShaderProgram(
|
||||
color.rgb = mix(color.rgb, desaturated, uBleachBypass);
|
||||
}
|
||||
|
||||
if (uFlash > 0.001) {
|
||||
color.rgb = applyDirectFlash(color.rgb, uvCoord, uAspectRatio, uFlash);
|
||||
color.rgb = sanitizeColor(color.rgb);
|
||||
}
|
||||
|
||||
if (abs(uVignette) > 0.0) {
|
||||
vec2 center = vec2(0.5, 0.5);
|
||||
float dist = distance(uvCoord, center);
|
||||
@@ -704,6 +712,8 @@ private class VideoLutShaderProgram(
|
||||
private var positionVbo = 0
|
||||
private var texCoordVbo = 0
|
||||
private var isGles3Context = false
|
||||
private var inputWidth = 1
|
||||
private var inputHeight = 1
|
||||
|
||||
private var lutTextureId = 0
|
||||
private var curveTextureId = 0
|
||||
@@ -740,6 +750,8 @@ private class VideoLutShaderProgram(
|
||||
|
||||
override fun configure(inputWidth: Int, inputHeight: Int): Size {
|
||||
PLog.d("VideoLutShaderProgram", "configure called, inputWidth: $inputWidth, inputHeight: $inputHeight")
|
||||
this.inputWidth = inputWidth.coerceAtLeast(1)
|
||||
this.inputHeight = inputHeight.coerceAtLeast(1)
|
||||
return Size(inputWidth, inputHeight)
|
||||
}
|
||||
|
||||
@@ -868,11 +880,15 @@ private class VideoLutShaderProgram(
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uTonePivot"), currentRecipeParams.tonePivot)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uFilmGrain"), currentRecipeParams.filmGrain)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uVignette"), currentRecipeParams.vignette)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uFlash"), currentRecipeParams.flash)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uBleachBypass"), currentRecipeParams.bleachBypass)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uNoise"), currentRecipeParams.noise)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uNoiseSeed"), (presentationTimeUs % 10000000L) / 1000000f)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uLowRes"), currentRecipeParams.lowRes)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uAspectRatio"), 16f / 9f)
|
||||
GLES30.glUniform1f(
|
||||
GLES30.glGetUniformLocation(programId, "uAspectRatio"),
|
||||
inputWidth.toFloat() / inputHeight.toFloat()
|
||||
)
|
||||
|
||||
// LCH 配方数组
|
||||
val lchHue = floatArrayOf(
|
||||
|
||||
@@ -204,6 +204,7 @@ class LutSynthesisViewModel(application: Application) : AndroidViewModel(applica
|
||||
val bakeableRecipe = recipe.copy(
|
||||
filmGrain = 0f,
|
||||
vignette = 0f,
|
||||
flash = 0f,
|
||||
bloom = 0f,
|
||||
halation = 0f,
|
||||
redHalation = 0f,
|
||||
@@ -277,6 +278,7 @@ class LutSynthesisViewModel(application: Application) : AndroidViewModel(applica
|
||||
val bakeableRecipe = recipe.copy(
|
||||
filmGrain = 0f,
|
||||
vignette = 0f,
|
||||
flash = 0f,
|
||||
bloom = 0f,
|
||||
halation = 0f,
|
||||
redHalation = 0f,
|
||||
|
||||
@@ -134,6 +134,7 @@ internal object CameraPresetJsonCodec {
|
||||
paletteDensity = obj.float("paletteDensity", default.paletteDensity),
|
||||
filmGrain = obj.float("filmGrain", default.filmGrain),
|
||||
vignette = obj.float("vignette", default.vignette),
|
||||
flash = obj.float("flash", default.flash),
|
||||
bleachBypass = obj.float("bleachBypass", default.bleachBypass),
|
||||
bloom = obj.float("bloom", default.bloom),
|
||||
softLight = obj.float("softLight", default.softLight),
|
||||
@@ -193,6 +194,7 @@ internal object CameraPresetJsonCodec {
|
||||
val default = EffectParams.DEFAULT
|
||||
return EffectParams(
|
||||
vignette = obj.float("vignette", default.vignette),
|
||||
flash = obj.float("flash", default.flash),
|
||||
filmGrain = obj.float("filmGrain", default.filmGrain),
|
||||
bloom = obj.float("bloom", default.bloom),
|
||||
softLight = obj.float("softLight", default.softLight),
|
||||
|
||||
@@ -28,6 +28,7 @@ data class ColorRecipeParams(
|
||||
val paletteDensity: Float = 1f, // 调色盘浓度
|
||||
val filmGrain: Float = 0f, // 0.0 ~ 1.0 (颗粒强度,0为无颗粒)
|
||||
val vignette: Float = 0f, // -1.0 ~ +1.0 (晕影,负值暗角,正值亮角)
|
||||
val flash: Float = 0f, // 0.0 ~ 1.0 (镜头轴向直闪模拟强度,0为无效果)
|
||||
val bleachBypass: Float = 0f, // 0.0 ~ 1.0 (留银冲洗强度,0为无效果)
|
||||
val bloom: Float = 0f, // 0.0 ~ 1.0 (Bevy Bloom 泛光强度,0为无效果)
|
||||
val softLight: Float = 0f, // 0.0 ~ 1.0 (柔光扩散强度,0为无效果)
|
||||
@@ -101,6 +102,7 @@ data class ColorRecipeParams(
|
||||
paletteDensity == 1f &&
|
||||
filmGrain == 0f &&
|
||||
vignette == 0f &&
|
||||
flash == 0f &&
|
||||
bleachBypass == 0f &&
|
||||
bloom == 0f &&
|
||||
softLight == 0f &&
|
||||
@@ -172,6 +174,7 @@ data class ColorRecipeParams(
|
||||
paletteDensity == other.paletteDensity &&
|
||||
filmGrain == other.filmGrain &&
|
||||
vignette == other.vignette &&
|
||||
flash == other.flash &&
|
||||
bleachBypass == other.bleachBypass &&
|
||||
bloom == other.bloom &&
|
||||
softLight == other.softLight &&
|
||||
@@ -267,6 +270,7 @@ enum class RecipeParam(
|
||||
SHADOWS(R.string.recipe_param_shadows, -1.0f, 1.0f, 0f),
|
||||
FILM_GRAIN(R.string.recipe_param_film_grain, 0.0f, 1.0f, 0f),
|
||||
VIGNETTE(R.string.recipe_param_vignette, -1.0f, 1.0f, 0f),
|
||||
FLASH(R.string.recipe_param_flash, 0.0f, 1.0f, 0f),
|
||||
BLEACH_BYPASS(R.string.recipe_param_bleach_bypass, 0.0f, 1.0f, 0f),
|
||||
BLOOM(R.string.recipe_param_bloom, 0.0f, 1.0f, 0f),
|
||||
SOFT_LIGHT(R.string.recipe_param_soft_light, 0.0f, 1.0f, 0f),
|
||||
@@ -336,6 +340,7 @@ enum class RecipeParam(
|
||||
SHADOWS -> params.shadows
|
||||
FILM_GRAIN -> params.filmGrain
|
||||
VIGNETTE -> params.vignette
|
||||
FLASH -> params.flash
|
||||
BLEACH_BYPASS -> params.bleachBypass
|
||||
BLOOM -> params.bloom
|
||||
SOFT_LIGHT -> params.softLight
|
||||
@@ -401,6 +406,7 @@ enum class RecipeParam(
|
||||
SHADOWS -> params.copy(shadows = clampedValue)
|
||||
FILM_GRAIN -> params.copy(filmGrain = clampedValue)
|
||||
VIGNETTE -> params.copy(vignette = clampedValue)
|
||||
FLASH -> params.copy(flash = clampedValue)
|
||||
BLEACH_BYPASS -> params.copy(bleachBypass = clampedValue)
|
||||
BLOOM -> params.copy(bloom = clampedValue)
|
||||
SOFT_LIGHT -> params.copy(softLight = clampedValue)
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.google.gson.Gson
|
||||
@Keep
|
||||
data class EffectParams(
|
||||
val vignette: Float = 0f, // 暗角 (-1.0 ~ 1.0)
|
||||
val flash: Float = 0f, // 镜头轴向直闪模拟 (0.0 ~ 1.0)
|
||||
val filmGrain: Float = 0f, // 胶片颗粒 (0.0 ~ 1.0)
|
||||
val bloom: Float = 0f, // Bevy Bloom 泛光 (0.0 ~ 1.0)
|
||||
val softLight: Float = 0f, // 柔光扩散 (0.0 ~ 1.0)
|
||||
@@ -23,6 +24,7 @@ data class EffectParams(
|
||||
*/
|
||||
fun isDefault(): Boolean {
|
||||
return vignette == 0f &&
|
||||
flash == 0f &&
|
||||
filmGrain == 0f &&
|
||||
bloom == 0f &&
|
||||
softLight == 0f &&
|
||||
@@ -39,6 +41,7 @@ data class EffectParams(
|
||||
fun applyTo(recipe: ColorRecipeParams): ColorRecipeParams {
|
||||
return recipe.copy(
|
||||
vignette = vignette,
|
||||
flash = flash,
|
||||
filmGrain = filmGrain,
|
||||
bloom = bloom,
|
||||
softLight = softLight,
|
||||
@@ -69,6 +72,7 @@ data class EffectParams(
|
||||
fun ColorRecipeParams.toEffectParams(): EffectParams {
|
||||
return EffectParams(
|
||||
vignette = vignette,
|
||||
flash = flash,
|
||||
filmGrain = filmGrain,
|
||||
bloom = bloom,
|
||||
softLight = softLight,
|
||||
|
||||
@@ -76,6 +76,7 @@ fun ColorRecipePanel(
|
||||
) {
|
||||
val isBakeable: (RecipeParam) -> Boolean = { param ->
|
||||
param != RecipeParam.VIGNETTE &&
|
||||
param != RecipeParam.FLASH &&
|
||||
param != RecipeParam.FILM_GRAIN &&
|
||||
param != RecipeParam.BLOOM &&
|
||||
param != RecipeParam.SOFT_LIGHT &&
|
||||
@@ -805,6 +806,7 @@ private fun formatParamValue(param: RecipeParam, value: Float): String {
|
||||
|
||||
RecipeParam.FADE,
|
||||
RecipeParam.FILM_GRAIN,
|
||||
RecipeParam.FLASH,
|
||||
RecipeParam.NOISE,
|
||||
RecipeParam.LOW_RES,
|
||||
RecipeParam.BLEACH_BYPASS,
|
||||
@@ -871,6 +873,7 @@ private fun getParamColor(param: RecipeParam): Color {
|
||||
RecipeParam.FILM_GRAIN -> Color(0xFF9E9E9E) // 灰色
|
||||
RecipeParam.NOISE -> Color(0xFFA1887F) // 浅棕色
|
||||
RecipeParam.VIGNETTE -> Color(0xFF795548) // 棕色
|
||||
RecipeParam.FLASH -> Color(0xFFE3F2FD) // 冷白色(直闪)
|
||||
RecipeParam.BLEACH_BYPASS -> Color(0xFF00BCD4) // 青色
|
||||
RecipeParam.BLOOM -> Color(0xFFFFD54F) // 泛光
|
||||
RecipeParam.SOFT_LIGHT -> Color(0xFFE8E1D4) // 柔光
|
||||
|
||||
@@ -30,6 +30,7 @@ enum class EffectType(
|
||||
) {
|
||||
FILM_GRAIN(RecipeParam.FILM_GRAIN, Color(0xFF9E9E9E), 0f, 1f, 0f),
|
||||
VIGNETTE(RecipeParam.VIGNETTE, Color(0xFF795548), -1f, 1f, 0f),
|
||||
FLASH(RecipeParam.FLASH, Color(0xFFE3F2FD), 0f, 1f, 0f),
|
||||
BLOOM(RecipeParam.BLOOM, Color(0xFFFFD54F), 0f, 1f, 0f),
|
||||
SOFT_LIGHT(RecipeParam.SOFT_LIGHT, Color(0xFFE8E1D4), 0f, 1f, 0f),
|
||||
HALATION(RecipeParam.HALATION, Color(0xFFFF7043), 0f, 1f, 0f),
|
||||
@@ -41,6 +42,7 @@ enum class EffectType(
|
||||
return when (this) {
|
||||
FILM_GRAIN -> params.filmGrain
|
||||
VIGNETTE -> params.vignette
|
||||
FLASH -> params.flash
|
||||
BLOOM -> params.bloom
|
||||
SOFT_LIGHT -> params.softLight
|
||||
HALATION -> params.halation
|
||||
@@ -55,6 +57,7 @@ enum class EffectType(
|
||||
return when (this) {
|
||||
FILM_GRAIN -> params.copy(filmGrain = clamped)
|
||||
VIGNETTE -> params.copy(vignette = clamped)
|
||||
FLASH -> params.copy(flash = clamped)
|
||||
BLOOM -> params.copy(bloom = clamped)
|
||||
SOFT_LIGHT -> params.copy(softLight = clamped)
|
||||
HALATION -> params.copy(halation = clamped)
|
||||
|
||||
@@ -421,6 +421,7 @@
|
||||
<string name="recipe_param_shadows">陰影</string>
|
||||
<string name="recipe_param_film_grain">顆粒</string>
|
||||
<string name="recipe_param_vignette">暈影</string>
|
||||
<string name="recipe_param_flash">閃光燈</string>
|
||||
<string name="recipe_param_bleach_bypass">留銀沖洗</string>
|
||||
<string name="recipe_param_bloom">泛光</string>
|
||||
<string name="recipe_param_soft_light">柔光</string>
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
<string name="recipe_param_shadows">Schatten</string>
|
||||
<string name="recipe_param_film_grain">Körnung</string>
|
||||
<string name="recipe_param_vignette">Vignettierung</string>
|
||||
<string name="recipe_param_flash">Blitz</string>
|
||||
<string name="recipe_param_bleach_bypass">Bleach Bypass</string>
|
||||
<string name="recipe_param_bloom">Bloom</string>
|
||||
<string name="recipe_param_soft_light">Weiches Licht</string>
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
<string name="recipe_param_shadows">Ombres</string>
|
||||
<string name="recipe_param_film_grain">Grain</string>
|
||||
<string name="recipe_param_vignette">Vignettage</string>
|
||||
<string name="recipe_param_flash">Flash</string>
|
||||
<string name="recipe_param_bleach_bypass">Bleach Bypass</string>
|
||||
<string name="recipe_param_bloom">Bloom</string>
|
||||
<string name="recipe_param_soft_light">Lumière douce</string>
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
<string name="recipe_param_shadows">Bayangan</string>
|
||||
<string name="recipe_param_film_grain">Grain</string>
|
||||
<string name="recipe_param_vignette">Vinyet</string>
|
||||
<string name="recipe_param_flash">Lampu Kilat</string>
|
||||
<string name="recipe_param_bleach_bypass">Bleach Bypass</string>
|
||||
<string name="recipe_param_bloom">Bloom</string>
|
||||
<string name="recipe_param_soft_light">Cahaya Lembut</string>
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
<string name="recipe_param_shadows">シャドウ</string>
|
||||
<string name="recipe_param_film_grain">粒子</string>
|
||||
<string name="recipe_param_vignette">周辺減光</string>
|
||||
<string name="recipe_param_flash">フラッシュ</string>
|
||||
<string name="recipe_param_bleach_bypass">銀残し</string>
|
||||
<string name="recipe_param_bloom">ブルーム</string>
|
||||
<string name="recipe_param_soft_light">ソフトライト</string>
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
<string name="recipe_param_shadows">어두운 영역</string>
|
||||
<string name="recipe_param_film_grain">그레인</string>
|
||||
<string name="recipe_param_vignette">비네팅</string>
|
||||
<string name="recipe_param_flash">플래시</string>
|
||||
<string name="recipe_param_bleach_bypass">블리치 바이패스</string>
|
||||
<string name="recipe_param_bloom">블룸</string>
|
||||
<string name="recipe_param_soft_light">소프트 라이트</string>
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
<string name="recipe_param_shadows">Sombras</string>
|
||||
<string name="recipe_param_film_grain">Grão</string>
|
||||
<string name="recipe_param_vignette">Vinheta</string>
|
||||
<string name="recipe_param_flash">Flash</string>
|
||||
<string name="recipe_param_bleach_bypass">Bleach Bypass</string>
|
||||
<string name="recipe_param_bloom">Bloom</string>
|
||||
<string name="recipe_param_soft_light">Luz suave</string>
|
||||
|
||||
@@ -301,6 +301,7 @@
|
||||
<string name="recipe_param_shadows">ส่วนมืด</string>
|
||||
<string name="recipe_param_film_grain">นอยซ์แบบฟิล์ม</string>
|
||||
<string name="recipe_param_vignette">ขอบมืด</string>
|
||||
<string name="recipe_param_flash">แฟลช</string>
|
||||
<string name="recipe_param_bleach_bypass">การข้ามกระบวนการล้าง (Bleach Bypass)</string>
|
||||
<string name="recipe_param_bloom">แสงฟุ้ง</string>
|
||||
<string name="recipe_param_soft_light">แสงนุ่ม</string>
|
||||
|
||||
@@ -421,6 +421,7 @@
|
||||
<string name="recipe_param_shadows">阴影</string>
|
||||
<string name="recipe_param_film_grain">颗粒</string>
|
||||
<string name="recipe_param_vignette">晕影</string>
|
||||
<string name="recipe_param_flash">闪光灯</string>
|
||||
<string name="recipe_param_bleach_bypass">留银冲洗</string>
|
||||
<string name="recipe_param_bloom">泛光</string>
|
||||
<string name="recipe_param_soft_light">柔光</string>
|
||||
|
||||
@@ -421,6 +421,7 @@
|
||||
<string name="recipe_param_shadows">陰影</string>
|
||||
<string name="recipe_param_film_grain">顆粒</string>
|
||||
<string name="recipe_param_vignette">暈影</string>
|
||||
<string name="recipe_param_flash">閃光燈</string>
|
||||
<string name="recipe_param_bleach_bypass">留銀沖洗</string>
|
||||
<string name="recipe_param_bloom">泛光</string>
|
||||
<string name="recipe_param_soft_light">柔光</string>
|
||||
|
||||
@@ -421,6 +421,7 @@
|
||||
<string name="recipe_param_shadows">陰影</string>
|
||||
<string name="recipe_param_film_grain">顆粒</string>
|
||||
<string name="recipe_param_vignette">暈影</string>
|
||||
<string name="recipe_param_flash">閃光燈</string>
|
||||
<string name="recipe_param_bleach_bypass">留銀沖洗</string>
|
||||
<string name="recipe_param_bloom">泛光</string>
|
||||
<string name="recipe_param_soft_light">柔光</string>
|
||||
|
||||
@@ -426,6 +426,7 @@
|
||||
<string name="recipe_param_shadows">Shadows</string>
|
||||
<string name="recipe_param_film_grain">Grain</string>
|
||||
<string name="recipe_param_vignette">Vignette</string>
|
||||
<string name="recipe_param_flash">Flash</string>
|
||||
<string name="recipe_param_bleach_bypass">Bleach Bypass</string>
|
||||
<string name="recipe_param_bloom">Bloom</string>
|
||||
<string name="recipe_param_soft_light">Soft Light</string>
|
||||
|
||||
@@ -142,10 +142,12 @@ class CameraPresetJsonCodecTest {
|
||||
"unknownFutureField": "ignored",
|
||||
"colorRecipe": {
|
||||
"exposure": 0.25,
|
||||
"flash": 0.15,
|
||||
"unknownColorField": 10
|
||||
},
|
||||
"effects": {
|
||||
"vignette": -0.2,
|
||||
"flash": 0.65,
|
||||
"hdf": 0.7
|
||||
}
|
||||
}
|
||||
@@ -166,7 +168,9 @@ class CameraPresetJsonCodecTest {
|
||||
assertEquals(1f, preset.colorRecipe.saturation, 0.0001f)
|
||||
assertEquals(0.5f, preset.colorRecipe.paletteX, 0.0001f)
|
||||
assertEquals(1f, preset.colorRecipe.lutIntensity, 0.0001f)
|
||||
assertEquals(0.15f, preset.colorRecipe.flash, 0.0001f)
|
||||
assertEquals(-0.2f, preset.effects.vignette, 0.0001f)
|
||||
assertEquals(0.65f, preset.effects.flash, 0.0001f)
|
||||
assertEquals(0f, preset.effects.hdf, 0.0001f)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.hinnka.mycamera.model
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class EffectParamsTest {
|
||||
@Test
|
||||
fun flash_roundTripsAndBridgesToColorRecipe() {
|
||||
val source = EffectParams.DEFAULT.copy(flash = 0.72f)
|
||||
|
||||
val restored = EffectParams.fromJson(source.toJson())
|
||||
val recipe = restored.applyTo(ColorRecipeParams.DEFAULT)
|
||||
|
||||
assertFalse(restored.isDefault())
|
||||
assertEquals(0.72f, restored.flash, 0.0001f)
|
||||
assertEquals(0.72f, recipe.flash, 0.0001f)
|
||||
assertEquals(restored, recipe.toEffectParams())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun defaultFlash_keepsEffectsDefault() {
|
||||
assertTrue(EffectParams.DEFAULT.isDefault())
|
||||
assertEquals(0f, ColorRecipeParams.DEFAULT.flash, 0.0001f)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user