feat: new bloom and soft light
This commit is contained in:
1 parent
d239826631
commit
b311d4a93f
27 files changed
+1272
-72
No files matched your search
+2
-1
@@ -13,4 +13,5 @@ app/release.jks
|
||||
.gradle-home
|
||||
/MGC
|
||||
/AGC
|
||||
/agc-photon-lut
|
||||
/agc-photon-lut
|
||||
/third_party
|
||||
@@ -7,7 +7,7 @@ import androidx.room.RoomDatabase
|
||||
|
||||
@Database(
|
||||
entities = [GalleryMediaEntity::class],
|
||||
version = 5,
|
||||
version = 7,
|
||||
exportSchema = false
|
||||
)
|
||||
@androidx.room.TypeConverters(GalleryConverters::class)
|
||||
@@ -46,6 +46,20 @@ abstract class GalleryDatabase : RoomDatabase() {
|
||||
}
|
||||
}
|
||||
|
||||
private val MIGRATION_5_6 = object : androidx.room.migration.Migration(5, 6) {
|
||||
override fun migrate(db: androidx.sqlite.db.SupportSQLiteDatabase) {
|
||||
db.execSQL("ALTER TABLE gallery_media ADD COLUMN recipe_bloom REAL")
|
||||
db.execSQL("ALTER TABLE gallery_media ADD COLUMN baseline_recipe_bloom REAL")
|
||||
}
|
||||
}
|
||||
|
||||
private val MIGRATION_6_7 = object : androidx.room.migration.Migration(6, 7) {
|
||||
override fun migrate(db: androidx.sqlite.db.SupportSQLiteDatabase) {
|
||||
db.execSQL("ALTER TABLE gallery_media ADD COLUMN recipe_softLight REAL")
|
||||
db.execSQL("ALTER TABLE gallery_media ADD COLUMN baseline_recipe_softLight REAL")
|
||||
}
|
||||
}
|
||||
|
||||
fun getInstance(context: Context): GalleryDatabase {
|
||||
return INSTANCE ?: synchronized(this) {
|
||||
INSTANCE ?: Room.databaseBuilder(
|
||||
@@ -53,7 +67,14 @@ abstract class GalleryDatabase : RoomDatabase() {
|
||||
GalleryDatabase::class.java,
|
||||
"gallery_media.db"
|
||||
)
|
||||
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5)
|
||||
.addMigrations(
|
||||
MIGRATION_1_2,
|
||||
MIGRATION_2_3,
|
||||
MIGRATION_3_4,
|
||||
MIGRATION_4_5,
|
||||
MIGRATION_5_6,
|
||||
MIGRATION_6_7
|
||||
)
|
||||
.build()
|
||||
.also { INSTANCE = it }
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ object BakedLutExporter {
|
||||
return copy(
|
||||
filmGrain = 0f,
|
||||
vignette = 0f,
|
||||
bloom = 0f,
|
||||
softLight = 0f,
|
||||
halation = 0f,
|
||||
redHalation = 0f,
|
||||
chromaticAberration = 0f,
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.hinnka.mycamera.lut
|
||||
|
||||
internal object BloomLdrSettings {
|
||||
const val MAX_MIP_DIMENSION = 512
|
||||
const val MIP_COUNT = 10
|
||||
|
||||
private const val HIGHLIGHT_THRESHOLD = 0.9f
|
||||
private const val HIGHLIGHT_THRESHOLD_SOFTNESS = 0.2f
|
||||
private const val MAX_COMPOSITE_STRENGTH = 0.8f
|
||||
|
||||
fun thresholdPrecomputations(): FloatArray {
|
||||
val knee = HIGHLIGHT_THRESHOLD * HIGHLIGHT_THRESHOLD_SOFTNESS.coerceIn(0f, 1f)
|
||||
return floatArrayOf(
|
||||
HIGHLIGHT_THRESHOLD,
|
||||
HIGHLIGHT_THRESHOLD - knee,
|
||||
2.0f * knee,
|
||||
0.25f / (knee + 0.00001f)
|
||||
)
|
||||
}
|
||||
|
||||
fun mipAddWeight(sourceMip: Int, mipCount: Int, bloom: Float): Float {
|
||||
if (mipCount <= 1) return 1f
|
||||
val radius = smooth01(bloom.coerceIn(0f, 1f))
|
||||
val mipPosition = sourceMip.toFloat() / (mipCount - 1).toFloat()
|
||||
val localDamping = 0.45f + mipPosition * 0.75f
|
||||
val radiusBoost = 0.7f + radius * 0.8f
|
||||
return (localDamping * radiusBoost).coerceIn(0.25f, 1.5f)
|
||||
}
|
||||
|
||||
fun compositeMipLowerIndex(mipCount: Int, bloom: Float): Int {
|
||||
return compositeMipPosition(mipCount, bloom).toInt()
|
||||
}
|
||||
|
||||
fun compositeMipUpperIndex(mipCount: Int, bloom: Float): Int {
|
||||
val lower = compositeMipLowerIndex(mipCount, bloom)
|
||||
val maxMip = (mipCount - 1).coerceAtLeast(0)
|
||||
return (lower + 1).coerceAtMost(maxMip)
|
||||
}
|
||||
|
||||
fun compositeMipBlend(mipCount: Int, bloom: Float): Float {
|
||||
val position = compositeMipPosition(mipCount, bloom)
|
||||
return (position - position.toInt().toFloat()).coerceIn(0f, 1f)
|
||||
}
|
||||
|
||||
fun compositeStrength(bloom: Float): Float {
|
||||
val strength = bloom.coerceIn(0f, 1f)
|
||||
return (strength * strength * MAX_COMPOSITE_STRENGTH).coerceIn(0f, 1f)
|
||||
}
|
||||
|
||||
private fun compositeMipPosition(mipCount: Int, bloom: Float): Float {
|
||||
val maxMip = (mipCount - 1).coerceAtLeast(0)
|
||||
if (maxMip == 0) return 0f
|
||||
val maxSelectableMip = minOf(maxMip, 5)
|
||||
val radius = smooth01(bloom.coerceIn(0f, 1f))
|
||||
return radius * maxSelectableMip.toFloat()
|
||||
}
|
||||
|
||||
private fun smooth01(value: Float): Float {
|
||||
return value * value * (3f - 2f * value)
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,11 @@ class LutImageProcessor {
|
||||
private var hdfFboId = IntArray(2) // 1/4 分辨率模糊 FBO
|
||||
private var hdfWidth = 0
|
||||
private var hdfHeight = 0
|
||||
private var softLightBlurHProgram = 0
|
||||
private var softLightTexId = IntArray(2)
|
||||
private var softLightFboId = IntArray(2)
|
||||
private var softLightWidth = 0
|
||||
private var softLightHeight = 0
|
||||
|
||||
// Halation (胶片红晕) 效果资源
|
||||
private var halationExtractBlurHProgram = 0
|
||||
@@ -94,6 +99,21 @@ class LutImageProcessor {
|
||||
private var halationFboId = IntArray(2)
|
||||
private var halationWidth = 0
|
||||
private var halationHeight = 0
|
||||
private var bloomDownsampleFirstProgram = 0
|
||||
private var bloomDownsampleProgram = 0
|
||||
private var bloomUpsampleProgram = 0
|
||||
private var bloomCompositeProgram = 0
|
||||
private var bloomTexId = IntArray(0)
|
||||
private var bloomFboId = IntArray(0)
|
||||
private var bloomMipWidths = IntArray(0)
|
||||
private var bloomMipHeights = IntArray(0)
|
||||
private var bloomMipCount = 0
|
||||
private var bloomSourceWidth = 0
|
||||
private var bloomSourceHeight = 0
|
||||
private var bloomOutputTextureId = 0
|
||||
private var bloomOutputFboId = 0
|
||||
private var bloomOutputWidth = 0
|
||||
private var bloomOutputHeight = 0
|
||||
|
||||
private var isInitialized = false
|
||||
|
||||
@@ -261,7 +281,8 @@ class LutImageProcessor {
|
||||
|
||||
// 提取色彩配方参数
|
||||
val effectiveRecipeParams = colorRecipeParams?.let(ColorPaletteMapper::mergeIntoEffectiveParams)
|
||||
val halation = effectiveRecipeParams?.halation ?: 0f
|
||||
val halation = 0f
|
||||
val softLight = effectiveRecipeParams?.softLight ?: 0f
|
||||
val redHalation = effectiveRecipeParams?.redHalation ?: 0f
|
||||
|
||||
// 后期处理参数
|
||||
@@ -307,6 +328,10 @@ class LutImageProcessor {
|
||||
renderHDFBlur(inputTexId, width, height, halation)
|
||||
currentCoroutineContext().ensureActive()
|
||||
}
|
||||
if (softLight > 0f) {
|
||||
renderSoftLightBlur(inputTexId, width, height)
|
||||
currentCoroutineContext().ensureActive()
|
||||
}
|
||||
if (redHalation > 0f) {
|
||||
renderHalationBlur(inputTexId, width, height, redHalation)
|
||||
currentCoroutineContext().ensureActive()
|
||||
@@ -417,7 +442,8 @@ class LutImageProcessor {
|
||||
|
||||
// 提取色彩配方参数
|
||||
val effectiveRecipeParams = colorRecipeParams?.let(ColorPaletteMapper::mergeIntoEffectiveParams)
|
||||
val halation = effectiveRecipeParams?.halation ?: 0f
|
||||
val halation = 0f
|
||||
val softLight = effectiveRecipeParams?.softLight ?: 0f
|
||||
val redHalation = effectiveRecipeParams?.redHalation ?: 0f
|
||||
|
||||
// 后期处理参数(仅在软件处理模式下生效)
|
||||
@@ -466,6 +492,10 @@ class LutImageProcessor {
|
||||
renderHDFBlur(inputTexId, width, height, halation)
|
||||
currentCoroutineContext().ensureActive()
|
||||
}
|
||||
if (softLight > 0f) {
|
||||
renderSoftLightBlur(inputTexId, width, height)
|
||||
currentCoroutineContext().ensureActive()
|
||||
}
|
||||
if (redHalation > 0f) {
|
||||
renderHalationBlur(inputTexId, width, height, redHalation)
|
||||
currentCoroutineContext().ensureActive()
|
||||
@@ -644,7 +674,9 @@ class LutImageProcessor {
|
||||
val filmGrain = effectiveRecipeParams?.filmGrain ?: 0f
|
||||
val vignette = effectiveRecipeParams?.vignette ?: 0f
|
||||
val bleachBypass = effectiveRecipeParams?.bleachBypass ?: 0f
|
||||
val halation = effectiveRecipeParams?.halation ?: 0f
|
||||
val bloom = effectiveRecipeParams?.bloom ?: 0f
|
||||
val halation = 0f
|
||||
val softLight = effectiveRecipeParams?.softLight ?: 0f
|
||||
val redHalation = effectiveRecipeParams?.redHalation ?: 0f
|
||||
val chromaticAberration = effectiveRecipeParams?.chromaticAberration ?: 0f
|
||||
val noise = effectiveRecipeParams?.noise ?: 0f
|
||||
@@ -752,6 +784,10 @@ class LutImageProcessor {
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, hdfTexId[1])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(program, "uHdfTexture"), 2)
|
||||
}
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(program, "uSoftLight"), softLight)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE5)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, if (softLight > 0f) softLightTexId[1] else 0)
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(program, "uSoftLightTexture"), 5)
|
||||
|
||||
// 设置 Halation 参数
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(program, "uRedHalation"), redHalation)
|
||||
@@ -800,6 +836,13 @@ class LutImageProcessor {
|
||||
if (positionHandle >= 0) GLES30.glDisableVertexAttribArray(positionHandle)
|
||||
if (texCoordHandle >= 0) GLES30.glDisableVertexAttribArray(texCoordHandle)
|
||||
|
||||
val readFramebufferId = if (bloom > 0.001f && renderLdrBloom(outputTextureId, width, height, bloom)) {
|
||||
bloomOutputFboId
|
||||
} else {
|
||||
framebufferId
|
||||
}
|
||||
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, readFramebufferId)
|
||||
val pixelSize = width * height * 4
|
||||
val pixelBuffer = obtainReadbackBuffer(pixelSize)
|
||||
GLES30.glBindBuffer(GLES30.GL_PIXEL_PACK_BUFFER, 0)
|
||||
@@ -1082,16 +1125,24 @@ class LutImageProcessor {
|
||||
return program
|
||||
}
|
||||
|
||||
val vShader = compileShader(GLES30.GL_VERTEX_SHADER, IMAGE_VERTEX_SHADER)
|
||||
hdfExtractBlurHProgram = createProgram(vShader, HDF_EXTRACT_BLUR_H_SHADER)
|
||||
hdfBlurVProgram = createProgram(vShader, HDF_BLUR_V_SHADER)
|
||||
halationExtractBlurHProgram = createProgram(vShader, HALATION_EXTRACT_BLUR_H_SHADER)
|
||||
halationBlurVProgram = createProgram(vShader, HDF_BLUR_V_SHADER)
|
||||
GLES30.glDeleteShader(vShader)
|
||||
val imageVShader = compileShader(GLES30.GL_VERTEX_SHADER, IMAGE_VERTEX_SHADER)
|
||||
hdfExtractBlurHProgram = createProgram(imageVShader, HDF_EXTRACT_BLUR_H_SHADER)
|
||||
hdfBlurVProgram = createProgram(imageVShader, HDF_BLUR_V_SHADER)
|
||||
softLightBlurHProgram = createProgram(imageVShader, Shaders.SOFT_LIGHT_PREVIEW_BLUR_H)
|
||||
halationExtractBlurHProgram = createProgram(imageVShader, HALATION_EXTRACT_BLUR_H_SHADER)
|
||||
halationBlurVProgram = createProgram(imageVShader, HDF_BLUR_V_SHADER)
|
||||
GLES30.glDeleteShader(imageVShader)
|
||||
|
||||
val simpleVShader = compileShader(GLES30.GL_VERTEX_SHADER, Shaders.SIMPLE_VERTEX_SHADER)
|
||||
bloomDownsampleFirstProgram = createProgram(simpleVShader, Shaders.BEVY_BLOOM_DOWNSAMPLE_FIRST)
|
||||
bloomDownsampleProgram = createProgram(simpleVShader, Shaders.BEVY_BLOOM_DOWNSAMPLE)
|
||||
bloomUpsampleProgram = createProgram(simpleVShader, Shaders.BEVY_BLOOM_UPSAMPLE)
|
||||
bloomCompositeProgram = createProgram(simpleVShader, Shaders.BEVY_BLOOM_COMPOSITE)
|
||||
GLES30.glDeleteShader(simpleVShader)
|
||||
|
||||
PLog.d(
|
||||
TAG,
|
||||
"HDF/Halation programs initialized"
|
||||
"HDF/Halation/Bloom/SoftLight programs initialized"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1566,6 +1617,46 @@ class LutImageProcessor {
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun setupSoftLightFramebuffers(width: Int, height: Int) {
|
||||
val dsW = max(1, width / 4)
|
||||
val dsH = max(1, height / 4)
|
||||
if (softLightWidth == dsW && softLightHeight == dsH && softLightTexId[0] != 0) return
|
||||
softLightWidth = dsW
|
||||
softLightHeight = dsH
|
||||
|
||||
for (i in 0..1) {
|
||||
if (softLightTexId[i] != 0) GLES30.glDeleteTextures(1, intArrayOf(softLightTexId[i]), 0)
|
||||
if (softLightFboId[i] != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(softLightFboId[i]), 0)
|
||||
}
|
||||
|
||||
for (i in 0..1) {
|
||||
val t = IntArray(1)
|
||||
val f = IntArray(1)
|
||||
GLES30.glGenTextures(1, t, 0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, t[0])
|
||||
GLES30.glTexImage2D(
|
||||
GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA16F,
|
||||
dsW, dsH, 0,
|
||||
GLES30.GL_RGBA, GLES30.GL_HALF_FLOAT, null
|
||||
)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glGenFramebuffers(1, f, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, f[0])
|
||||
GLES30.glFramebufferTexture2D(
|
||||
GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0,
|
||||
GLES30.GL_TEXTURE_2D, t[0], 0
|
||||
)
|
||||
softLightTexId[i] = t[0]
|
||||
softLightFboId[i] = f[0]
|
||||
}
|
||||
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun setupHalationFramebuffers(width: Int, height: Int) {
|
||||
val dsW = width / 4
|
||||
val dsH = height / 4
|
||||
@@ -1601,6 +1692,50 @@ class LutImageProcessor {
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun renderSoftLightBlur(
|
||||
sourceTexId: Int,
|
||||
width: Int,
|
||||
height: Int
|
||||
) {
|
||||
setupSoftLightFramebuffers(width, height)
|
||||
if (softLightBlurHProgram == 0 || hdfBlurVProgram == 0) return
|
||||
|
||||
val dsW = softLightWidth
|
||||
val dsH = softLightHeight
|
||||
val texelW = 1.0f / dsW
|
||||
val texelH = 1.0f / dsH
|
||||
|
||||
val identityMatrix = FloatArray(16)
|
||||
android.opengl.Matrix.setIdentityM(identityMatrix, 0)
|
||||
|
||||
GLES30.glUseProgram(softLightBlurHProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, softLightFboId[0])
|
||||
GLES30.glViewport(0, 0, dsW, dsH)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, sourceTexId)
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(softLightBlurHProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(GLES30.glGetUniformLocation(softLightBlurHProgram, "uTexelSize"), texelW, texelH)
|
||||
GLES30.glUniformMatrix4fv(
|
||||
GLES30.glGetUniformLocation(softLightBlurHProgram, "uMVPMatrix"), 1, false, identityMatrix, 0
|
||||
)
|
||||
drawQuad(softLightBlurHProgram)
|
||||
|
||||
GLES30.glUseProgram(hdfBlurVProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, softLightFboId[1])
|
||||
GLES30.glViewport(0, 0, dsW, dsH)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, softLightTexId[0])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(hdfBlurVProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(GLES30.glGetUniformLocation(hdfBlurVProgram, "uTexelSize"), texelW, texelH)
|
||||
GLES30.glUniformMatrix4fv(
|
||||
GLES30.glGetUniformLocation(hdfBlurVProgram, "uMVPMatrix"), 1, false, identityMatrix, 0
|
||||
)
|
||||
drawQuad(hdfBlurVProgram)
|
||||
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
checkGlError("renderSoftLightBlur")
|
||||
}
|
||||
|
||||
private fun renderHalationBlur(
|
||||
sourceTexId: Int,
|
||||
width: Int,
|
||||
@@ -1710,6 +1845,228 @@ class LutImageProcessor {
|
||||
checkGlError("renderHDFBlur")
|
||||
}
|
||||
|
||||
private fun setupBloomOutputFramebuffer(width: Int, height: Int): Boolean {
|
||||
if (bloomOutputFboId != 0 &&
|
||||
bloomOutputTextureId != 0 &&
|
||||
bloomOutputWidth == width &&
|
||||
bloomOutputHeight == height
|
||||
) {
|
||||
return true
|
||||
}
|
||||
if (bloomOutputFboId != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(bloomOutputFboId), 0)
|
||||
if (bloomOutputTextureId != 0) GLES30.glDeleteTextures(1, intArrayOf(bloomOutputTextureId), 0)
|
||||
val f = IntArray(1)
|
||||
val t = IntArray(1)
|
||||
GLES30.glGenTextures(1, t, 0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, t[0])
|
||||
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA, width, height, 0, GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, null)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glGenFramebuffers(1, f, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, f[0])
|
||||
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, t[0], 0)
|
||||
val status = GLES30.glCheckFramebufferStatus(GLES30.GL_FRAMEBUFFER)
|
||||
if (status != GLES30.GL_FRAMEBUFFER_COMPLETE) {
|
||||
PLog.e(TAG, "Bloom output framebuffer not complete: $status")
|
||||
if (f[0] != 0) GLES30.glDeleteFramebuffers(1, f, 0)
|
||||
if (t[0] != 0) GLES30.glDeleteTextures(1, t, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
return false
|
||||
}
|
||||
bloomOutputTextureId = t[0]
|
||||
bloomOutputFboId = f[0]
|
||||
bloomOutputWidth = width
|
||||
bloomOutputHeight = height
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
return true
|
||||
}
|
||||
|
||||
private fun setupBloomFramebuffers(width: Int, height: Int): Boolean {
|
||||
val maxMipDimension = BloomLdrSettings.MAX_MIP_DIMENSION
|
||||
val scale = maxMipDimension.toFloat() / maxOf(1, height).toFloat()
|
||||
var mipWidth = (width * scale).toInt().coerceAtLeast(1)
|
||||
var mipHeight = (height * scale).toInt().coerceAtLeast(1)
|
||||
val widths = mutableListOf<Int>()
|
||||
val heights = mutableListOf<Int>()
|
||||
repeat(BloomLdrSettings.MIP_COUNT) {
|
||||
widths += mipWidth
|
||||
heights += mipHeight
|
||||
mipWidth = maxOf(1, mipWidth / 2)
|
||||
mipHeight = maxOf(1, mipHeight / 2)
|
||||
}
|
||||
val nextWidths = widths.toIntArray()
|
||||
val nextHeights = heights.toIntArray()
|
||||
if (bloomSourceWidth == width &&
|
||||
bloomSourceHeight == height &&
|
||||
bloomTexId.isNotEmpty() &&
|
||||
bloomMipWidths.contentEquals(nextWidths) &&
|
||||
bloomMipHeights.contentEquals(nextHeights)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
releaseBloomFramebuffers()
|
||||
bloomSourceWidth = width
|
||||
bloomSourceHeight = height
|
||||
bloomMipCount = nextWidths.size
|
||||
bloomMipWidths = nextWidths
|
||||
bloomMipHeights = nextHeights
|
||||
bloomTexId = IntArray(bloomMipCount)
|
||||
bloomFboId = IntArray(bloomMipCount)
|
||||
for (i in 0 until bloomMipCount) {
|
||||
val t = IntArray(1)
|
||||
val f = IntArray(1)
|
||||
GLES30.glGenTextures(1, t, 0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, t[0])
|
||||
GLES30.glTexImage2D(
|
||||
GLES30.GL_TEXTURE_2D,
|
||||
0,
|
||||
GLES30.GL_RGBA16F,
|
||||
bloomMipWidths[i],
|
||||
bloomMipHeights[i],
|
||||
0,
|
||||
GLES30.GL_RGBA,
|
||||
GLES30.GL_HALF_FLOAT,
|
||||
null
|
||||
)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glGenFramebuffers(1, f, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, f[0])
|
||||
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, t[0], 0)
|
||||
bloomTexId[i] = t[0]
|
||||
bloomFboId[i] = f[0]
|
||||
val status = GLES30.glCheckFramebufferStatus(GLES30.GL_FRAMEBUFFER)
|
||||
if (status != GLES30.GL_FRAMEBUFFER_COMPLETE) {
|
||||
PLog.e(TAG, "Bloom mip framebuffer[$i] not complete: $status")
|
||||
releaseBloomFramebuffers()
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
return false
|
||||
}
|
||||
}
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
return true
|
||||
}
|
||||
|
||||
private fun releaseBloomFramebuffers() {
|
||||
for (textureId in bloomTexId) {
|
||||
if (textureId != 0) GLES30.glDeleteTextures(1, intArrayOf(textureId), 0)
|
||||
}
|
||||
for (fboId in bloomFboId) {
|
||||
if (fboId != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(fboId), 0)
|
||||
}
|
||||
bloomTexId = IntArray(0)
|
||||
bloomFboId = IntArray(0)
|
||||
bloomMipWidths = IntArray(0)
|
||||
bloomMipHeights = IntArray(0)
|
||||
bloomMipCount = 0
|
||||
bloomSourceWidth = 0
|
||||
bloomSourceHeight = 0
|
||||
}
|
||||
|
||||
private fun renderLdrBloom(sourceTextureId: Int, width: Int, height: Int, bloomStrength: Float): Boolean {
|
||||
if (!setupBloomFramebuffers(width, height)) {
|
||||
return false
|
||||
}
|
||||
if (!setupBloomOutputFramebuffer(width, height)) {
|
||||
return false
|
||||
}
|
||||
if (bloomMipCount <= 0 || bloomDownsampleFirstProgram == 0 || bloomDownsampleProgram == 0 || bloomUpsampleProgram == 0 || bloomCompositeProgram == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
GLES30.glDisable(GLES30.GL_BLEND)
|
||||
GLES30.glUseProgram(bloomDownsampleFirstProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, bloomFboId[0])
|
||||
GLES30.glViewport(0, 0, bloomMipWidths[0], bloomMipHeights[0])
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, sourceTextureId)
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomDownsampleFirstProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(GLES30.glGetUniformLocation(bloomDownsampleFirstProgram, "uInputTexelSize"), 1f / width, 1f / height)
|
||||
val thresholdPrecomputations = BloomLdrSettings.thresholdPrecomputations()
|
||||
GLES30.glUniform4f(
|
||||
GLES30.glGetUniformLocation(bloomDownsampleFirstProgram, "uThreshold"),
|
||||
thresholdPrecomputations[0],
|
||||
thresholdPrecomputations[1],
|
||||
thresholdPrecomputations[2],
|
||||
thresholdPrecomputations[3]
|
||||
)
|
||||
drawQuad(bloomDownsampleFirstProgram)
|
||||
|
||||
for (mip in 1 until bloomMipCount) {
|
||||
GLES30.glUseProgram(bloomDownsampleProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, bloomFboId[mip])
|
||||
GLES30.glViewport(0, 0, bloomMipWidths[mip], bloomMipHeights[mip])
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, bloomTexId[mip - 1])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomDownsampleProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(GLES30.glGetUniformLocation(bloomDownsampleProgram, "uInputTexelSize"), 1f / bloomMipWidths[mip - 1], 1f / bloomMipHeights[mip - 1])
|
||||
drawQuad(bloomDownsampleProgram)
|
||||
}
|
||||
|
||||
GLES30.glEnable(GLES30.GL_BLEND)
|
||||
GLES30.glBlendEquation(GLES30.GL_FUNC_ADD)
|
||||
GLES30.glBlendFunc(GLES30.GL_CONSTANT_COLOR, GLES30.GL_ONE)
|
||||
GLES30.glUseProgram(bloomUpsampleProgram)
|
||||
for (mip in bloomMipCount - 1 downTo 1) {
|
||||
val blend = BloomLdrSettings.mipAddWeight(mip, bloomMipCount, bloomStrength)
|
||||
GLES30.glBlendColor(blend, blend, blend, blend)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, bloomFboId[mip - 1])
|
||||
GLES30.glViewport(0, 0, bloomMipWidths[mip - 1], bloomMipHeights[mip - 1])
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, bloomTexId[mip])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomUpsampleProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(GLES30.glGetUniformLocation(bloomUpsampleProgram, "uInputTexelSize"), 1f / bloomMipWidths[mip], 1f / bloomMipHeights[mip])
|
||||
drawQuad(bloomUpsampleProgram)
|
||||
}
|
||||
GLES30.glDisable(GLES30.GL_BLEND)
|
||||
|
||||
val finalBlend = BloomLdrSettings.compositeStrength(bloomStrength)
|
||||
val compositeMipLower = BloomLdrSettings.compositeMipLowerIndex(bloomMipCount, bloomStrength)
|
||||
val compositeMipUpper = BloomLdrSettings.compositeMipUpperIndex(bloomMipCount, bloomStrength)
|
||||
val compositeMipBlend = BloomLdrSettings.compositeMipBlend(bloomMipCount, bloomStrength)
|
||||
if (bitmapDenoisePassthroughProgram == 0) {
|
||||
return false
|
||||
}
|
||||
renderTexturePassthrough(sourceTextureId, bloomOutputFboId, width, height)
|
||||
GLES30.glEnable(GLES30.GL_BLEND)
|
||||
GLES30.glBlendEquation(GLES30.GL_FUNC_ADD)
|
||||
GLES30.glBlendFunc(GLES30.GL_ONE, GLES30.GL_ONE)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, bloomOutputFboId)
|
||||
GLES30.glViewport(0, 0, width, height)
|
||||
GLES30.glUseProgram(bloomCompositeProgram)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, bloomTexId[compositeMipLower])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomCompositeProgram, "uBloomTexture"), 0)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE1)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, bloomTexId[compositeMipUpper])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomCompositeProgram, "uBloomTextureNext"), 1)
|
||||
GLES30.glUniform2f(
|
||||
GLES30.glGetUniformLocation(bloomCompositeProgram, "uBloomTexelSize"),
|
||||
1f / bloomMipWidths[compositeMipLower],
|
||||
1f / bloomMipHeights[compositeMipLower]
|
||||
)
|
||||
GLES30.glUniform2f(
|
||||
GLES30.glGetUniformLocation(bloomCompositeProgram, "uBloomTexelSizeNext"),
|
||||
1f / bloomMipWidths[compositeMipUpper],
|
||||
1f / bloomMipHeights[compositeMipUpper]
|
||||
)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(bloomCompositeProgram, "uBlend"), finalBlend)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(bloomCompositeProgram, "uMipBlend"), compositeMipBlend)
|
||||
drawQuad(bloomCompositeProgram)
|
||||
GLES30.glDisable(GLES30.GL_BLEND)
|
||||
val error = GLES30.glGetError()
|
||||
if (error != GLES30.GL_NO_ERROR) {
|
||||
PLog.e(TAG, "renderLdrBloom final composite glError $error")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun checkGlError(op: String) {
|
||||
val error = GLES30.glGetError()
|
||||
if (error != GLES30.GL_NO_ERROR) {
|
||||
@@ -1884,9 +2241,12 @@ class LutImageProcessor {
|
||||
// 释放 HDF 资源
|
||||
if (hdfExtractBlurHProgram != 0) GLES30.glDeleteProgram(hdfExtractBlurHProgram)
|
||||
if (hdfBlurVProgram != 0) GLES30.glDeleteProgram(hdfBlurVProgram)
|
||||
if (softLightBlurHProgram != 0) GLES30.glDeleteProgram(softLightBlurHProgram)
|
||||
for (i in 0..1) {
|
||||
if (hdfTexId[i] != 0) GLES30.glDeleteTextures(1, intArrayOf(hdfTexId[i]), 0)
|
||||
if (hdfFboId[i] != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(hdfFboId[i]), 0)
|
||||
if (softLightTexId[i] != 0) GLES30.glDeleteTextures(1, intArrayOf(softLightTexId[i]), 0)
|
||||
if (softLightFboId[i] != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(softLightFboId[i]), 0)
|
||||
}
|
||||
|
||||
if (halationExtractBlurHProgram != 0) GLES30.glDeleteProgram(halationExtractBlurHProgram)
|
||||
@@ -1895,6 +2255,13 @@ class LutImageProcessor {
|
||||
if (halationTexId[i] != 0) GLES30.glDeleteTextures(1, intArrayOf(halationTexId[i]), 0)
|
||||
if (halationFboId[i] != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(halationFboId[i]), 0)
|
||||
}
|
||||
if (bloomDownsampleFirstProgram != 0) GLES30.glDeleteProgram(bloomDownsampleFirstProgram)
|
||||
if (bloomDownsampleProgram != 0) GLES30.glDeleteProgram(bloomDownsampleProgram)
|
||||
if (bloomUpsampleProgram != 0) GLES30.glDeleteProgram(bloomUpsampleProgram)
|
||||
if (bloomCompositeProgram != 0) GLES30.glDeleteProgram(bloomCompositeProgram)
|
||||
releaseBloomFramebuffers()
|
||||
if (bloomOutputFboId != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(bloomOutputFboId), 0)
|
||||
if (bloomOutputTextureId != 0) GLES30.glDeleteTextures(1, intArrayOf(bloomOutputTextureId), 0)
|
||||
|
||||
EGL14.eglMakeCurrent(eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT)
|
||||
EGL14.eglDestroySurface(eglDisplay, eglSurface)
|
||||
@@ -1992,6 +2359,8 @@ class LutImageProcessor {
|
||||
// HDF 光晕效果
|
||||
uniform float uHalation; // 0.0 ~ 1.0 (光晕强度)
|
||||
uniform sampler2D uHdfTexture; // 光晕合成纹理
|
||||
uniform float uSoftLight; // 0.0 ~ 1.0 (柔光扩散强度)
|
||||
uniform sampler2D uSoftLightTexture; // 柔光扩散纹理
|
||||
uniform float uRedHalation; // 0.0 ~ 1.0 (胶片红晕强度)
|
||||
uniform sampler2D uRedHalationTexture; // 胶片红晕合成纹理
|
||||
|
||||
@@ -2688,11 +3057,22 @@ class LutImageProcessor {
|
||||
if (isP3) {
|
||||
// 混合完成后的 sRGB 颜色转回 P3
|
||||
vec3 linearSrgbOut = srgbToLinear(color.rgb);
|
||||
color.rgb = linearToSrgb(mat3(0.875905, 0.035332, 0.016382, 0.122070, 0.964542, 0.063767, 0.002025, 0.000126, 0.919851) * linearSrgbOut);
|
||||
}
|
||||
color.rgb = linearToSrgb(mat3(0.875905, 0.035332, 0.016382, 0.122070, 0.964542, 0.063767, 0.002025, 0.000126, 0.919851) * linearSrgbOut);
|
||||
}
|
||||
}
|
||||
|
||||
// === 柔光效果(LUT 之后,保持和实时预览一致) ===
|
||||
if (uSoftLight > 0.0) {
|
||||
vec3 softBlur = texture(uSoftLightTexture, uvCoord).rgb;
|
||||
vec3 screen = vec3(1.0) - (vec3(1.0) - color.rgb) * (vec3(1.0) - softBlur);
|
||||
vec3 softGlow = mix(color.rgb, screen, 0.42);
|
||||
color.rgb = mix(color.rgb, softGlow, uSoftLight * 0.75);
|
||||
float softLuma = dot(softBlur, vec3(0.2126, 0.7152, 0.0722));
|
||||
color.rgb += vec3(softLuma) * (uSoftLight * 0.025);
|
||||
color.rgb = (color.rgb - 0.5) * (1.0 - uSoftLight * 0.05) + 0.5;
|
||||
}
|
||||
|
||||
// --- 4. 锐化 ---
|
||||
|
||||
// --- 4. 锐化 ---
|
||||
if (uSharpening > 0.0) {
|
||||
// 使用基于亮度的 Unsharp Mask,避免色彩污染
|
||||
vec3 inputColor = sampleImage(uvCoord).rgb;
|
||||
|
||||
@@ -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", "halation", "redHalation", "chromaticAberration",
|
||||
"filmGrain", "vignette", "bleachBypass", "bloom", "softLight", "halation", "redHalation", "chromaticAberration",
|
||||
"noise", "lowRes",
|
||||
"skinHue", "skinChroma", "skinLightness",
|
||||
"redHue", "redChroma", "redLightness",
|
||||
@@ -85,7 +85,9 @@ class LutManager(private val context: Context) {
|
||||
filmGrain = f("filmGrain"),
|
||||
vignette = f("vignette"),
|
||||
bleachBypass = f("bleachBypass"),
|
||||
halation = f("halation"),
|
||||
bloom = f("bloom"),
|
||||
softLight = f("softLight"),
|
||||
halation = 0f,
|
||||
redHalation = f("redHalation"),
|
||||
chromaticAberration = f("chromaticAberration"),
|
||||
noise = f("noise"),
|
||||
|
||||
@@ -256,16 +256,36 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
private var hdfExtractBlurHProgram: Int = 0
|
||||
private var hdfBlurVProgram: Int = 0
|
||||
private var hdfCompositeProgram: Int = 0
|
||||
private var softLightBlurHProgram: Int = 0
|
||||
private var hdfTexId = IntArray(2)
|
||||
private var hdfFboId = IntArray(2)
|
||||
private var hdfWidth: Int = 0
|
||||
private var hdfHeight: Int = 0
|
||||
private var softLightTexId = IntArray(2)
|
||||
private var softLightFboId = IntArray(2)
|
||||
private var softLightWidth: Int = 0
|
||||
private var softLightHeight: Int = 0
|
||||
private var halationExtractBlurHProgram: Int = 0
|
||||
private var halationBlurVProgram: Int = 0
|
||||
private var halationTexId = IntArray(2)
|
||||
private var halationFboId = IntArray(2)
|
||||
private var halationWidth: Int = 0
|
||||
private var halationHeight: Int = 0
|
||||
private var bloomDownsampleFirstProgram: Int = 0
|
||||
private var bloomDownsampleProgram: Int = 0
|
||||
private var bloomUpsampleProgram: Int = 0
|
||||
private var bloomCompositeProgram: Int = 0
|
||||
private var bloomTexId = IntArray(0)
|
||||
private var bloomFboId = IntArray(0)
|
||||
private var bloomMipWidths = IntArray(0)
|
||||
private var bloomMipHeights = IntArray(0)
|
||||
private var bloomMipCount: Int = 0
|
||||
private var bloomSourceWidth: Int = 0
|
||||
private var bloomSourceHeight: Int = 0
|
||||
private var postProcessScratchFboId: Int = 0
|
||||
private var postProcessScratchTextureId: Int = 0
|
||||
private var postProcessScratchWidth: Int = 0
|
||||
private var postProcessScratchHeight: Int = 0
|
||||
|
||||
// Bokeh 实时预览资源
|
||||
private var bokehProgramId: Int = 0
|
||||
@@ -413,6 +433,12 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
@Volatile
|
||||
var bleachBypass: Float = 0f // 0.0 ~ 1.0
|
||||
|
||||
@Volatile
|
||||
var bloom: Float = 0f // 0.0 ~ 1.0
|
||||
|
||||
@Volatile
|
||||
var softLight: Float = 0f // 0.0 ~ 1.0
|
||||
|
||||
@Volatile
|
||||
var chromaticAberration: Float = 0f // 0.0 ~ 1.0
|
||||
|
||||
@@ -593,16 +619,36 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
hdfExtractBlurHProgram = 0
|
||||
hdfBlurVProgram = 0
|
||||
hdfCompositeProgram = 0
|
||||
softLightBlurHProgram = 0
|
||||
hdfTexId = IntArray(2)
|
||||
hdfFboId = IntArray(2)
|
||||
hdfWidth = 0
|
||||
hdfHeight = 0
|
||||
softLightTexId = IntArray(2)
|
||||
softLightFboId = IntArray(2)
|
||||
softLightWidth = 0
|
||||
softLightHeight = 0
|
||||
halationExtractBlurHProgram = 0
|
||||
halationBlurVProgram = 0
|
||||
halationTexId = IntArray(2)
|
||||
halationFboId = IntArray(2)
|
||||
halationWidth = 0
|
||||
halationHeight = 0
|
||||
bloomDownsampleFirstProgram = 0
|
||||
bloomDownsampleProgram = 0
|
||||
bloomUpsampleProgram = 0
|
||||
bloomCompositeProgram = 0
|
||||
bloomTexId = IntArray(0)
|
||||
bloomFboId = IntArray(0)
|
||||
bloomMipWidths = IntArray(0)
|
||||
bloomMipHeights = IntArray(0)
|
||||
bloomMipCount = 0
|
||||
bloomSourceWidth = 0
|
||||
bloomSourceHeight = 0
|
||||
postProcessScratchFboId = 0
|
||||
postProcessScratchTextureId = 0
|
||||
postProcessScratchWidth = 0
|
||||
postProcessScratchHeight = 0
|
||||
bokehProgramId = 0
|
||||
depthTextureId = 0
|
||||
lastDepthMap = null
|
||||
@@ -953,7 +999,9 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
}
|
||||
val hdfEnabled = halation > 0.001f
|
||||
val halationEnabled = redHalation > 0.001f
|
||||
val postProcessEffectEnabled = hdfEnabled || halationEnabled
|
||||
val bloomEnabled = bloom > 0.001f
|
||||
val softLightEnabled = softLight > 0.001f
|
||||
val postProcessEffectEnabled = hdfEnabled || halationEnabled || bloomEnabled || softLightEnabled
|
||||
val bokehNeeded = aperture > 0f && depthMap != null
|
||||
val aiFocusInputNeeded = onAiFocusInputAvailable != null && isAutoFocus && !isAiFocusBusy
|
||||
val suppressBaselineLayerForVideoLog = videoLogProfile.isEnabled
|
||||
@@ -1033,15 +1081,7 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
currentHeight = viewportHeight
|
||||
}
|
||||
|
||||
// 3. HDF 多 Pass 处理
|
||||
var outputTexId = currentTexId
|
||||
if (hdfEnabled) {
|
||||
renderHdfPreviewBlur(currentTexId, currentWidth, currentHeight)
|
||||
}
|
||||
if (halationEnabled) {
|
||||
renderHalationPreviewBlur(currentTexId, currentWidth, currentHeight)
|
||||
}
|
||||
|
||||
val outputTexId = currentTexId
|
||||
|
||||
// 确保 FBO 内容已刷入显存
|
||||
GLES30.glFlush()
|
||||
@@ -1078,7 +1118,7 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
ensureRecordFbo(targetSize.width, targetSize.height)
|
||||
if (recordFboId != 0 && recordTextureId != 0) {
|
||||
if (postProcessEffectEnabled) {
|
||||
drawPostProcessComposite(recordFboId, targetSize.width, targetSize.height, currentTexId)
|
||||
drawPostProcessEffects(recordFboId, targetSize.width, targetSize.height, currentTexId)
|
||||
} else if (bokehNeeded) {
|
||||
drawFboToScreen(recordFboId, targetSize.width, targetSize.height, currentTexId)
|
||||
} else {
|
||||
@@ -1114,7 +1154,7 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
|
||||
// 6. 显示到屏幕
|
||||
if (postProcessEffectEnabled) {
|
||||
drawPostProcessComposite(0, viewportWidth, viewportHeight, currentTexId)
|
||||
drawPostProcessEffects(0, viewportWidth, viewportHeight, currentTexId)
|
||||
} else {
|
||||
drawFboToScreen(0, viewportWidth, viewportHeight, currentTexId)
|
||||
}
|
||||
@@ -1468,6 +1508,9 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
val blurVFs = GlUtils.compileShader(GLES30.GL_FRAGMENT_SHADER, Shaders.HDF_PREVIEW_BLUR_V)
|
||||
hdfBlurVProgram = GlUtils.linkProgram(simpleVs, blurVFs)
|
||||
GLES30.glDeleteShader(blurVFs)
|
||||
val softLightBlurHFs = GlUtils.compileShader(GLES30.GL_FRAGMENT_SHADER, Shaders.SOFT_LIGHT_PREVIEW_BLUR_H)
|
||||
softLightBlurHProgram = GlUtils.linkProgram(simpleVs, softLightBlurHFs)
|
||||
GLES30.glDeleteShader(softLightBlurHFs)
|
||||
// Composite
|
||||
val compositeFs = GlUtils.compileShader(GLES30.GL_FRAGMENT_SHADER, Shaders.HDF_PREVIEW_COMPOSITE)
|
||||
hdfCompositeProgram = GlUtils.linkProgram(simpleVs, compositeFs)
|
||||
@@ -1478,9 +1521,24 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
halationBlurVProgram = GlUtils.linkProgram(simpleVs, halationBlurVFs)
|
||||
GLES30.glDeleteShader(halationExtractHFs)
|
||||
GLES30.glDeleteShader(halationBlurVFs)
|
||||
val bloomDownsampleFirstFs = GlUtils.compileShader(GLES30.GL_FRAGMENT_SHADER, Shaders.BEVY_BLOOM_DOWNSAMPLE_FIRST)
|
||||
val bloomDownsampleFs = GlUtils.compileShader(GLES30.GL_FRAGMENT_SHADER, Shaders.BEVY_BLOOM_DOWNSAMPLE)
|
||||
val bloomUpsampleFs = GlUtils.compileShader(GLES30.GL_FRAGMENT_SHADER, Shaders.BEVY_BLOOM_UPSAMPLE)
|
||||
val bloomCompositeFs = GlUtils.compileShader(GLES30.GL_FRAGMENT_SHADER, Shaders.BEVY_BLOOM_COMPOSITE)
|
||||
bloomDownsampleFirstProgram = GlUtils.linkProgram(simpleVs, bloomDownsampleFirstFs)
|
||||
bloomDownsampleProgram = GlUtils.linkProgram(simpleVs, bloomDownsampleFs)
|
||||
bloomUpsampleProgram = GlUtils.linkProgram(simpleVs, bloomUpsampleFs)
|
||||
bloomCompositeProgram = GlUtils.linkProgram(simpleVs, bloomCompositeFs)
|
||||
GLES30.glDeleteShader(bloomDownsampleFirstFs)
|
||||
GLES30.glDeleteShader(bloomDownsampleFs)
|
||||
GLES30.glDeleteShader(bloomUpsampleFs)
|
||||
GLES30.glDeleteShader(bloomCompositeFs)
|
||||
GLES30.glDeleteShader(simpleVs)
|
||||
|
||||
if (hdfExtractBlurHProgram == 0 || hdfBlurVProgram == 0 || hdfCompositeProgram == 0 || halationExtractBlurHProgram == 0 || halationBlurVProgram == 0) {
|
||||
if (hdfExtractBlurHProgram == 0 || hdfBlurVProgram == 0 || hdfCompositeProgram == 0 || softLightBlurHProgram == 0 ||
|
||||
halationExtractBlurHProgram == 0 || halationBlurVProgram == 0 ||
|
||||
bloomDownsampleFirstProgram == 0 || bloomDownsampleProgram == 0 || bloomUpsampleProgram == 0 || bloomCompositeProgram == 0
|
||||
) {
|
||||
PLog.e(TAG, "Failed to link HDF preview programs")
|
||||
}
|
||||
}
|
||||
@@ -1549,6 +1607,50 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun setupSoftLightFbos(width: Int, height: Int) {
|
||||
val dsW = maxOf(1, width / 4)
|
||||
val dsH = maxOf(1, height / 4)
|
||||
if (softLightWidth == dsW && softLightHeight == dsH && softLightTexId[0] != 0) return
|
||||
softLightWidth = dsW
|
||||
softLightHeight = dsH
|
||||
for (i in 0..1) {
|
||||
if (softLightTexId[i] != 0) GLES30.glDeleteTextures(1, intArrayOf(softLightTexId[i]), 0)
|
||||
if (softLightFboId[i] != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(softLightFboId[i]), 0)
|
||||
val t = IntArray(1)
|
||||
val f = IntArray(1)
|
||||
GLES30.glGenTextures(1, t, 0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, t[0])
|
||||
GLES30.glTexImage2D(
|
||||
GLES30.GL_TEXTURE_2D,
|
||||
0,
|
||||
GLES30.GL_RGBA16F,
|
||||
dsW,
|
||||
dsH,
|
||||
0,
|
||||
GLES30.GL_RGBA,
|
||||
GLES30.GL_HALF_FLOAT,
|
||||
null
|
||||
)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glGenFramebuffers(1, f, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, f[0])
|
||||
GLES30.glFramebufferTexture2D(
|
||||
GLES30.GL_FRAMEBUFFER,
|
||||
GLES30.GL_COLOR_ATTACHMENT0,
|
||||
GLES30.GL_TEXTURE_2D,
|
||||
t[0],
|
||||
0
|
||||
)
|
||||
softLightTexId[i] = t[0]
|
||||
softLightFboId[i] = f[0]
|
||||
}
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun renderHdfPreviewBlur(sourceTexId: Int, width: Int, height: Int) {
|
||||
if (!ensureHdfPrograms()) return
|
||||
setupHdfFbos(width, height)
|
||||
@@ -1582,6 +1684,36 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun renderSoftLightPreviewBlur(sourceTexId: Int, width: Int, height: Int) {
|
||||
if (!ensureHdfPrograms()) return
|
||||
setupSoftLightFbos(width, height)
|
||||
if (softLightBlurHProgram == 0 || hdfBlurVProgram == 0) return
|
||||
val dsW = softLightWidth.coerceAtLeast(1)
|
||||
val dsH = softLightHeight.coerceAtLeast(1)
|
||||
val spatialScale = getPreviewSpatialEffectScale(width, height)
|
||||
val texelW = spatialScale / dsW
|
||||
val texelH = spatialScale / dsH
|
||||
|
||||
GLES30.glUseProgram(softLightBlurHProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, softLightFboId[0])
|
||||
GLES30.glViewport(0, 0, dsW, dsH)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, sourceTexId)
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(softLightBlurHProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(GLES30.glGetUniformLocation(softLightBlurHProgram, "uTexelSize"), texelW, texelH)
|
||||
drawSimpleQuad(softLightBlurHProgram)
|
||||
|
||||
GLES30.glUseProgram(hdfBlurVProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, softLightFboId[1])
|
||||
GLES30.glViewport(0, 0, dsW, dsH)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, softLightTexId[0])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(hdfBlurVProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(GLES30.glGetUniformLocation(hdfBlurVProgram, "uTexelSize"), texelW, texelH)
|
||||
drawSimpleQuad(hdfBlurVProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun renderHalationPreviewBlur(sourceTexId: Int, width: Int, height: Int) {
|
||||
if (!ensureHdfPrograms()) return
|
||||
setupHalationFbos(width, height)
|
||||
@@ -1613,6 +1745,269 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun setupBloomFbos(width: Int, height: Int): Boolean {
|
||||
val maxMipDimension = BloomLdrSettings.MAX_MIP_DIMENSION
|
||||
val scale = maxMipDimension.toFloat() / maxOf(1, height).toFloat()
|
||||
var mipWidth = (width * scale).toInt().coerceAtLeast(1)
|
||||
var mipHeight = (height * scale).toInt().coerceAtLeast(1)
|
||||
val widths = mutableListOf<Int>()
|
||||
val heights = mutableListOf<Int>()
|
||||
repeat(BloomLdrSettings.MIP_COUNT) {
|
||||
widths += mipWidth
|
||||
heights += mipHeight
|
||||
mipWidth = maxOf(1, mipWidth / 2)
|
||||
mipHeight = maxOf(1, mipHeight / 2)
|
||||
}
|
||||
val count = widths.size
|
||||
if (bloomSourceWidth == width &&
|
||||
bloomSourceHeight == height &&
|
||||
bloomMipCount == count &&
|
||||
bloomTexId.isNotEmpty() &&
|
||||
bloomMipWidths.contentEquals(widths.toIntArray()) &&
|
||||
bloomMipHeights.contentEquals(heights.toIntArray())
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
releaseBloomFbos()
|
||||
bloomSourceWidth = width
|
||||
bloomSourceHeight = height
|
||||
bloomMipCount = count
|
||||
bloomMipWidths = widths.toIntArray()
|
||||
bloomMipHeights = heights.toIntArray()
|
||||
bloomTexId = IntArray(count)
|
||||
bloomFboId = IntArray(count)
|
||||
|
||||
for (i in 0 until count) {
|
||||
val t = IntArray(1)
|
||||
val f = IntArray(1)
|
||||
GLES30.glGenTextures(1, t, 0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, t[0])
|
||||
GLES30.glTexImage2D(
|
||||
GLES30.GL_TEXTURE_2D,
|
||||
0,
|
||||
GLES30.GL_RGBA16F,
|
||||
bloomMipWidths[i],
|
||||
bloomMipHeights[i],
|
||||
0,
|
||||
GLES30.GL_RGBA,
|
||||
GLES30.GL_HALF_FLOAT,
|
||||
null
|
||||
)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glGenFramebuffers(1, f, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, f[0])
|
||||
GLES30.glFramebufferTexture2D(
|
||||
GLES30.GL_FRAMEBUFFER,
|
||||
GLES30.GL_COLOR_ATTACHMENT0,
|
||||
GLES30.GL_TEXTURE_2D,
|
||||
t[0],
|
||||
0
|
||||
)
|
||||
bloomTexId[i] = t[0]
|
||||
bloomFboId[i] = f[0]
|
||||
val status = GLES30.glCheckFramebufferStatus(GLES30.GL_FRAMEBUFFER)
|
||||
if (status != GLES30.GL_FRAMEBUFFER_COMPLETE) {
|
||||
PLog.e(TAG, "Bloom mip framebuffer[$i] not complete: $status")
|
||||
releaseBloomFbos()
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
return false
|
||||
}
|
||||
}
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
return true
|
||||
}
|
||||
|
||||
private fun releaseBloomFbos() {
|
||||
for (textureId in bloomTexId) {
|
||||
if (textureId != 0) GLES30.glDeleteTextures(1, intArrayOf(textureId), 0)
|
||||
}
|
||||
for (fboId in bloomFboId) {
|
||||
if (fboId != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(fboId), 0)
|
||||
}
|
||||
bloomTexId = IntArray(0)
|
||||
bloomFboId = IntArray(0)
|
||||
bloomMipWidths = IntArray(0)
|
||||
bloomMipHeights = IntArray(0)
|
||||
bloomMipCount = 0
|
||||
bloomSourceWidth = 0
|
||||
bloomSourceHeight = 0
|
||||
}
|
||||
|
||||
private fun renderLdrBloom(targetFboId: Int, width: Int, height: Int, sourceTexId: Int) {
|
||||
if (!ensureHdfPrograms()) {
|
||||
drawFboToScreen(targetFboId, width, height, sourceTexId)
|
||||
return
|
||||
}
|
||||
if (bloom <= 0.001f || bloomDownsampleFirstProgram == 0 || bloomDownsampleProgram == 0 ||
|
||||
bloomUpsampleProgram == 0 || bloomCompositeProgram == 0
|
||||
) {
|
||||
drawFboToScreen(targetFboId, width, height, sourceTexId)
|
||||
return
|
||||
}
|
||||
if (!setupBloomFbos(width, height)) {
|
||||
drawFboToScreen(targetFboId, width, height, sourceTexId)
|
||||
return
|
||||
}
|
||||
if (bloomMipCount <= 0) {
|
||||
drawFboToScreen(targetFboId, width, height, sourceTexId)
|
||||
return
|
||||
}
|
||||
|
||||
val thresholdPrecomputations = BloomLdrSettings.thresholdPrecomputations()
|
||||
|
||||
GLES30.glDisable(GLES30.GL_BLEND)
|
||||
GLES30.glUseProgram(bloomDownsampleFirstProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, bloomFboId[0])
|
||||
GLES30.glViewport(0, 0, bloomMipWidths[0], bloomMipHeights[0])
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, sourceTexId)
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomDownsampleFirstProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(GLES30.glGetUniformLocation(bloomDownsampleFirstProgram, "uInputTexelSize"), 1f / width, 1f / height)
|
||||
GLES30.glUniform4f(
|
||||
GLES30.glGetUniformLocation(bloomDownsampleFirstProgram, "uThreshold"),
|
||||
thresholdPrecomputations[0],
|
||||
thresholdPrecomputations[1],
|
||||
thresholdPrecomputations[2],
|
||||
thresholdPrecomputations[3]
|
||||
)
|
||||
drawSimpleQuad(bloomDownsampleFirstProgram)
|
||||
|
||||
for (mip in 1 until bloomMipCount) {
|
||||
GLES30.glUseProgram(bloomDownsampleProgram)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, bloomFboId[mip])
|
||||
GLES30.glViewport(0, 0, bloomMipWidths[mip], bloomMipHeights[mip])
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, bloomTexId[mip - 1])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomDownsampleProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(
|
||||
GLES30.glGetUniformLocation(bloomDownsampleProgram, "uInputTexelSize"),
|
||||
1f / bloomMipWidths[mip - 1],
|
||||
1f / bloomMipHeights[mip - 1]
|
||||
)
|
||||
drawSimpleQuad(bloomDownsampleProgram)
|
||||
}
|
||||
|
||||
GLES30.glEnable(GLES30.GL_BLEND)
|
||||
GLES30.glBlendEquation(GLES30.GL_FUNC_ADD)
|
||||
GLES30.glBlendFunc(GLES30.GL_CONSTANT_COLOR, GLES30.GL_ONE)
|
||||
GLES30.glUseProgram(bloomUpsampleProgram)
|
||||
for (mip in bloomMipCount - 1 downTo 1) {
|
||||
val blend = BloomLdrSettings.mipAddWeight(mip, bloomMipCount, bloom)
|
||||
GLES30.glBlendColor(blend, blend, blend, blend)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, bloomFboId[mip - 1])
|
||||
GLES30.glViewport(0, 0, bloomMipWidths[mip - 1], bloomMipHeights[mip - 1])
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, bloomTexId[mip])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomUpsampleProgram, "uInputTexture"), 0)
|
||||
GLES30.glUniform2f(
|
||||
GLES30.glGetUniformLocation(bloomUpsampleProgram, "uInputTexelSize"),
|
||||
1f / bloomMipWidths[mip],
|
||||
1f / bloomMipHeights[mip]
|
||||
)
|
||||
drawSimpleQuad(bloomUpsampleProgram)
|
||||
}
|
||||
GLES30.glDisable(GLES30.GL_BLEND)
|
||||
|
||||
val finalBlend = BloomLdrSettings.compositeStrength(bloom)
|
||||
val compositeMipLower = BloomLdrSettings.compositeMipLowerIndex(bloomMipCount, bloom)
|
||||
val compositeMipUpper = BloomLdrSettings.compositeMipUpperIndex(bloomMipCount, bloom)
|
||||
val compositeMipBlend = BloomLdrSettings.compositeMipBlend(bloomMipCount, bloom)
|
||||
drawFboToScreen(targetFboId, width, height, sourceTexId)
|
||||
GLES30.glEnable(GLES30.GL_BLEND)
|
||||
GLES30.glBlendEquation(GLES30.GL_FUNC_ADD)
|
||||
GLES30.glBlendFunc(GLES30.GL_ONE, GLES30.GL_ONE)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, targetFboId)
|
||||
GLES30.glViewport(0, 0, width, height)
|
||||
GLES30.glUseProgram(bloomCompositeProgram)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, bloomTexId[compositeMipLower])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomCompositeProgram, "uBloomTexture"), 0)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE1)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, bloomTexId[compositeMipUpper])
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(bloomCompositeProgram, "uBloomTextureNext"), 1)
|
||||
GLES30.glUniform2f(
|
||||
GLES30.glGetUniformLocation(bloomCompositeProgram, "uBloomTexelSize"),
|
||||
1f / bloomMipWidths[compositeMipLower],
|
||||
1f / bloomMipHeights[compositeMipLower]
|
||||
)
|
||||
GLES30.glUniform2f(
|
||||
GLES30.glGetUniformLocation(bloomCompositeProgram, "uBloomTexelSizeNext"),
|
||||
1f / bloomMipWidths[compositeMipUpper],
|
||||
1f / bloomMipHeights[compositeMipUpper]
|
||||
)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(bloomCompositeProgram, "uBlend"), finalBlend)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(bloomCompositeProgram, "uMipBlend"), compositeMipBlend)
|
||||
drawSimpleQuad(bloomCompositeProgram)
|
||||
GLES30.glDisable(GLES30.GL_BLEND)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun setupPostProcessScratchFbo(width: Int, height: Int) {
|
||||
if (postProcessScratchFboId != 0 &&
|
||||
postProcessScratchTextureId != 0 &&
|
||||
postProcessScratchWidth == width &&
|
||||
postProcessScratchHeight == height
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (postProcessScratchFboId != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(postProcessScratchFboId), 0)
|
||||
if (postProcessScratchTextureId != 0) GLES30.glDeleteTextures(1, intArrayOf(postProcessScratchTextureId), 0)
|
||||
val f = IntArray(1)
|
||||
val t = IntArray(1)
|
||||
GLES30.glGenTextures(1, t, 0)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, t[0])
|
||||
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA, width, height, 0, GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, null)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE)
|
||||
GLES30.glGenFramebuffers(1, f, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, f[0])
|
||||
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, t[0], 0)
|
||||
postProcessScratchFboId = f[0]
|
||||
postProcessScratchTextureId = t[0]
|
||||
postProcessScratchWidth = width
|
||||
postProcessScratchHeight = height
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0)
|
||||
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
|
||||
}
|
||||
|
||||
private fun drawPostProcessEffects(targetFboId: Int, width: Int, height: Int, sourceTextureId: Int) {
|
||||
val hdfEnabled = halation > 0.001f
|
||||
val halationEnabled = redHalation > 0.001f
|
||||
val bloomEnabled = bloom > 0.001f
|
||||
val softLightEnabled = softLight > 0.001f
|
||||
val compositeEnabled = hdfEnabled || halationEnabled || softLightEnabled
|
||||
|
||||
if (hdfEnabled) {
|
||||
renderHdfPreviewBlur(sourceTextureId, width, height)
|
||||
}
|
||||
if (softLightEnabled) {
|
||||
renderSoftLightPreviewBlur(sourceTextureId, width, height)
|
||||
}
|
||||
if (halationEnabled) {
|
||||
renderHalationPreviewBlur(sourceTextureId, width, height)
|
||||
}
|
||||
|
||||
if (compositeEnabled && bloomEnabled) {
|
||||
setupPostProcessScratchFbo(width, height)
|
||||
drawPostProcessComposite(postProcessScratchFboId, width, height, sourceTextureId)
|
||||
renderLdrBloom(targetFboId, width, height, postProcessScratchTextureId)
|
||||
} else if (bloomEnabled) {
|
||||
renderLdrBloom(targetFboId, width, height, sourceTextureId)
|
||||
} else if (compositeEnabled) {
|
||||
drawPostProcessComposite(targetFboId, width, height, sourceTextureId)
|
||||
} else {
|
||||
drawFboToScreen(targetFboId, width, height, sourceTextureId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawPostProcessComposite(targetFboId: Int, width: Int, height: Int, sourceTextureId: Int) {
|
||||
if (!ensureHdfPrograms()) return
|
||||
if (hdfCompositeProgram == 0) return
|
||||
@@ -1632,6 +2027,10 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, if (redHalation > 0f) halationTexId[1] else 0)
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(hdfCompositeProgram, "uRedHalationTexture"), 2)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(hdfCompositeProgram, "uRedHalation"), redHalation)
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE3)
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, if (softLight > 0f) softLightTexId[1] else 0)
|
||||
GLES30.glUniform1i(GLES30.glGetUniformLocation(hdfCompositeProgram, "uSoftLightTexture"), 3)
|
||||
GLES30.glUniform1f(GLES30.glGetUniformLocation(hdfCompositeProgram, "uSoftLight"), softLight)
|
||||
drawSimpleQuad(hdfCompositeProgram)
|
||||
}
|
||||
|
||||
@@ -2235,7 +2634,7 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
|
||||
if (sourceTextureId != null && sourceTextureId != 0) {
|
||||
if (compositeWithHdf) {
|
||||
drawPostProcessComposite(captureFboId, captureWidth, captureHeight, sourceTextureId)
|
||||
drawPostProcessEffects(captureFboId, captureWidth, captureHeight, sourceTextureId)
|
||||
} else {
|
||||
drawFboToScreen(
|
||||
fboId = captureFboId,
|
||||
@@ -2315,7 +2714,7 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
|
||||
if (sourceTextureId != null && sourceTextureId != 0) {
|
||||
if (compositeWithHdf) {
|
||||
drawPostProcessComposite(meteringFboId, METERING_SIZE, METERING_SIZE, sourceTextureId)
|
||||
drawPostProcessEffects(meteringFboId, METERING_SIZE, METERING_SIZE, sourceTextureId)
|
||||
} else {
|
||||
drawFboToScreen(
|
||||
fboId = meteringFboId,
|
||||
@@ -2738,13 +3137,37 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
if (hdfExtractBlurHProgram != 0) GLES30.glDeleteProgram(hdfExtractBlurHProgram)
|
||||
if (hdfBlurVProgram != 0) GLES30.glDeleteProgram(hdfBlurVProgram)
|
||||
if (hdfCompositeProgram != 0) GLES30.glDeleteProgram(hdfCompositeProgram)
|
||||
hdfExtractBlurHProgram = 0; hdfBlurVProgram = 0; hdfCompositeProgram = 0
|
||||
if (softLightBlurHProgram != 0) GLES30.glDeleteProgram(softLightBlurHProgram)
|
||||
hdfExtractBlurHProgram = 0; hdfBlurVProgram = 0; hdfCompositeProgram = 0; softLightBlurHProgram = 0
|
||||
for (i in 0..1) {
|
||||
if (hdfTexId[i] != 0) GLES30.glDeleteTextures(1, intArrayOf(hdfTexId[i]), 0)
|
||||
if (hdfFboId[i] != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(hdfFboId[i]), 0)
|
||||
if (softLightTexId[i] != 0) GLES30.glDeleteTextures(1, intArrayOf(softLightTexId[i]), 0)
|
||||
if (softLightFboId[i] != 0) GLES30.glDeleteFramebuffers(1, intArrayOf(softLightFboId[i]), 0)
|
||||
}
|
||||
hdfTexId = IntArray(2); hdfFboId = IntArray(2)
|
||||
softLightTexId = IntArray(2); softLightFboId = IntArray(2)
|
||||
hdfWidth = 0; hdfHeight = 0
|
||||
softLightWidth = 0; softLightHeight = 0
|
||||
if (bloomDownsampleFirstProgram != 0) GLES30.glDeleteProgram(bloomDownsampleFirstProgram)
|
||||
if (bloomDownsampleProgram != 0) GLES30.glDeleteProgram(bloomDownsampleProgram)
|
||||
if (bloomUpsampleProgram != 0) GLES30.glDeleteProgram(bloomUpsampleProgram)
|
||||
if (bloomCompositeProgram != 0) GLES30.glDeleteProgram(bloomCompositeProgram)
|
||||
bloomDownsampleFirstProgram = 0
|
||||
bloomDownsampleProgram = 0
|
||||
bloomUpsampleProgram = 0
|
||||
bloomCompositeProgram = 0
|
||||
releaseBloomFbos()
|
||||
if (postProcessScratchFboId != 0) {
|
||||
GLES30.glDeleteFramebuffers(1, intArrayOf(postProcessScratchFboId), 0)
|
||||
postProcessScratchFboId = 0
|
||||
}
|
||||
if (postProcessScratchTextureId != 0) {
|
||||
GLES30.glDeleteTextures(1, intArrayOf(postProcessScratchTextureId), 0)
|
||||
postProcessScratchTextureId = 0
|
||||
}
|
||||
postProcessScratchWidth = 0
|
||||
postProcessScratchHeight = 0
|
||||
|
||||
// 删除缓冲
|
||||
if (vertexBufferId != 0) {
|
||||
@@ -2883,8 +3306,11 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
filmGrain = filmGrain,
|
||||
vignette = vignette,
|
||||
bleachBypass = bleachBypass,
|
||||
bloom = bloom,
|
||||
softLight = softLight,
|
||||
chromaticAberration = chromaticAberration,
|
||||
halation = halation,
|
||||
redHalation = redHalation,
|
||||
noise = noise,
|
||||
lowRes = lowRes,
|
||||
skinHue = lchHueAdjustments[0],
|
||||
@@ -2980,8 +3406,10 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
filmGrain = params.filmGrain
|
||||
vignette = params.vignette
|
||||
bleachBypass = params.bleachBypass
|
||||
bloom = params.bloom
|
||||
softLight = params.softLight
|
||||
chromaticAberration = params.chromaticAberration
|
||||
halation = params.halation
|
||||
halation = 0f
|
||||
redHalation = params.redHalation
|
||||
noise = params.noise
|
||||
lowRes = params.lowRes
|
||||
@@ -3064,8 +3492,13 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
if (hdfExtractBlurHProgram != 0 &&
|
||||
hdfBlurVProgram != 0 &&
|
||||
hdfCompositeProgram != 0 &&
|
||||
softLightBlurHProgram != 0 &&
|
||||
halationExtractBlurHProgram != 0 &&
|
||||
halationBlurVProgram != 0
|
||||
halationBlurVProgram != 0 &&
|
||||
bloomDownsampleFirstProgram != 0 &&
|
||||
bloomDownsampleProgram != 0 &&
|
||||
bloomUpsampleProgram != 0 &&
|
||||
bloomCompositeProgram != 0
|
||||
) {
|
||||
return true
|
||||
}
|
||||
@@ -3073,8 +3506,13 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
return hdfExtractBlurHProgram != 0 &&
|
||||
hdfBlurVProgram != 0 &&
|
||||
hdfCompositeProgram != 0 &&
|
||||
softLightBlurHProgram != 0 &&
|
||||
halationExtractBlurHProgram != 0 &&
|
||||
halationBlurVProgram != 0
|
||||
halationBlurVProgram != 0 &&
|
||||
bloomDownsampleFirstProgram != 0 &&
|
||||
bloomDownsampleProgram != 0 &&
|
||||
bloomUpsampleProgram != 0 &&
|
||||
bloomCompositeProgram != 0
|
||||
}
|
||||
|
||||
private fun ensureBokehProgram(): Boolean {
|
||||
|
||||
@@ -147,6 +147,27 @@ object Shaders {
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
/** Soft Light Pass 1: 整图柔焦水平模糊,用于镜头柔光扩散 */
|
||||
val SOFT_LIGHT_PREVIEW_BLUR_H = """
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
in vec2 vTexCoord;
|
||||
out vec4 fragColor;
|
||||
uniform sampler2D uInputTexture;
|
||||
uniform vec2 uTexelSize;
|
||||
void main() {
|
||||
vec3 sum = texture(uInputTexture, vTexCoord).rgb * 0.204164;
|
||||
float blurOffsets[4] = float[](1.407333, 3.294215, 5.176470, 7.058823);
|
||||
float blurWeights[4] = float[](0.304005, 0.093910, 0.010416, 0.000005);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
float off = blurOffsets[i] * uTexelSize.x * 2.8;
|
||||
sum += texture(uInputTexture, vTexCoord + vec2(off, 0.0)).rgb * blurWeights[i];
|
||||
sum += texture(uInputTexture, vTexCoord - vec2(off, 0.0)).rgb * blurWeights[i];
|
||||
}
|
||||
fragColor = vec4(sum, 1.0);
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
/** HDF 合成:原图 + HDF 扩散 + spektrafilm 风格红色 halation */
|
||||
val HDF_PREVIEW_COMPOSITE = """
|
||||
#version 300 es
|
||||
@@ -158,10 +179,22 @@ object Shaders {
|
||||
uniform float uHalation;
|
||||
uniform sampler2D uRedHalationTexture;
|
||||
uniform float uRedHalation;
|
||||
uniform sampler2D uSoftLightTexture;
|
||||
uniform float uSoftLight;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(uOriginalTexture, vTexCoord);
|
||||
|
||||
if (uSoftLight > 0.0) {
|
||||
vec3 softBlur = texture(uSoftLightTexture, vTexCoord).rgb;
|
||||
vec3 screen = vec3(1.0) - (vec3(1.0) - color.rgb) * (vec3(1.0) - softBlur);
|
||||
vec3 softGlow = mix(color.rgb, screen, 0.42);
|
||||
color.rgb = mix(color.rgb, softGlow, uSoftLight * 0.75);
|
||||
float softLuma = dot(softBlur, vec3(0.2126, 0.7152, 0.0722));
|
||||
color.rgb += vec3(softLuma) * (uSoftLight * 0.025);
|
||||
color.rgb = (color.rgb - 0.5) * (1.0 - uSoftLight * 0.05) + 0.5;
|
||||
}
|
||||
|
||||
if (uHalation > 0.0) {
|
||||
vec3 bloom = texture(uBloomTexture, vTexCoord).rgb;
|
||||
float bLuma = dot(bloom, vec3(0.2126, 0.7152, 0.0722));
|
||||
@@ -184,6 +217,206 @@ object Shaders {
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
/** Bevy Bloom: first downsample pass with Karis firefly reduction and soft threshold. */
|
||||
val BEVY_BLOOM_DOWNSAMPLE_FIRST = """
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
in vec2 vTexCoord;
|
||||
out vec4 fragColor;
|
||||
uniform sampler2D uInputTexture;
|
||||
uniform vec2 uInputTexelSize;
|
||||
uniform vec4 uThreshold;
|
||||
|
||||
float tonemappingLuminance(vec3 v) {
|
||||
return dot(v, vec3(0.2126, 0.7152, 0.0722));
|
||||
}
|
||||
|
||||
float karisAverage(vec3 color) {
|
||||
float luma = tonemappingLuminance(pow(max(color, vec3(0.0)), vec3(1.0 / 2.2))) / 4.0;
|
||||
return 1.0 / (1.0 + luma);
|
||||
}
|
||||
|
||||
vec3 thresholdHighlight(vec3 color) {
|
||||
float luma = tonemappingLuminance(color);
|
||||
float mask = 0.0;
|
||||
if (uThreshold.z > 0.0) {
|
||||
mask = smoothstep(uThreshold.y, uThreshold.y + uThreshold.z, luma);
|
||||
} else {
|
||||
mask = step(uThreshold.x, luma);
|
||||
}
|
||||
return color * mask;
|
||||
}
|
||||
|
||||
vec3 sampleInput(vec2 uv) {
|
||||
vec3 color = texture(uInputTexture, uv).rgb;
|
||||
if (uThreshold.x > 0.0 || uThreshold.z > 0.0) {
|
||||
color = thresholdHighlight(color);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 sample13Tap(vec2 uv) {
|
||||
vec2 ps = uInputTexelSize;
|
||||
vec2 pl = 2.0 * ps;
|
||||
vec2 ns = -ps;
|
||||
vec2 nl = -pl;
|
||||
vec3 a = sampleInput(uv + vec2(nl.x, pl.y));
|
||||
vec3 b = sampleInput(uv + vec2(0.0, pl.y));
|
||||
vec3 c = sampleInput(uv + vec2(pl.x, pl.y));
|
||||
vec3 d = sampleInput(uv + vec2(nl.x, 0.0));
|
||||
vec3 e = sampleInput(uv);
|
||||
vec3 f = sampleInput(uv + vec2(pl.x, 0.0));
|
||||
vec3 g = sampleInput(uv + vec2(nl.x, nl.y));
|
||||
vec3 h = sampleInput(uv + vec2(0.0, nl.y));
|
||||
vec3 i = sampleInput(uv + vec2(pl.x, nl.y));
|
||||
vec3 j = sampleInput(uv + vec2(ns.x, ps.y));
|
||||
vec3 k = sampleInput(uv + vec2(ps.x, ps.y));
|
||||
vec3 l = sampleInput(uv + vec2(ns.x, ns.y));
|
||||
vec3 m = sampleInput(uv + vec2(ps.x, ns.y));
|
||||
|
||||
vec3 group0 = (a + b + d + e) * (0.125 / 4.0);
|
||||
vec3 group1 = (b + c + e + f) * (0.125 / 4.0);
|
||||
vec3 group2 = (d + e + g + h) * (0.125 / 4.0);
|
||||
vec3 group3 = (e + f + h + i) * (0.125 / 4.0);
|
||||
vec3 group4 = (j + k + l + m) * (0.5 / 4.0);
|
||||
group0 *= karisAverage(group0);
|
||||
group1 *= karisAverage(group1);
|
||||
group2 *= karisAverage(group2);
|
||||
group3 *= karisAverage(group3);
|
||||
group4 *= karisAverage(group4);
|
||||
return group0 + group1 + group2 + group3 + group4;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 sampleColor = sample13Tap(vTexCoord);
|
||||
fragColor = vec4(clamp(sampleColor, vec3(0.0), vec3(1.0)), 1.0);
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
/** Bevy Bloom: subsequent 13-tap downsample passes. */
|
||||
val BEVY_BLOOM_DOWNSAMPLE = """
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
in vec2 vTexCoord;
|
||||
out vec4 fragColor;
|
||||
uniform sampler2D uInputTexture;
|
||||
uniform vec2 uInputTexelSize;
|
||||
|
||||
vec3 sample13Tap(vec2 uv) {
|
||||
vec2 ps = uInputTexelSize;
|
||||
vec2 pl = 2.0 * ps;
|
||||
vec2 ns = -ps;
|
||||
vec2 nl = -pl;
|
||||
vec3 a = texture(uInputTexture, uv + vec2(nl.x, pl.y)).rgb;
|
||||
vec3 b = texture(uInputTexture, uv + vec2(0.0, pl.y)).rgb;
|
||||
vec3 c = texture(uInputTexture, uv + vec2(pl.x, pl.y)).rgb;
|
||||
vec3 d = texture(uInputTexture, uv + vec2(nl.x, 0.0)).rgb;
|
||||
vec3 e = texture(uInputTexture, uv).rgb;
|
||||
vec3 f = texture(uInputTexture, uv + vec2(pl.x, 0.0)).rgb;
|
||||
vec3 g = texture(uInputTexture, uv + vec2(nl.x, nl.y)).rgb;
|
||||
vec3 h = texture(uInputTexture, uv + vec2(0.0, nl.y)).rgb;
|
||||
vec3 i = texture(uInputTexture, uv + vec2(pl.x, nl.y)).rgb;
|
||||
vec3 j = texture(uInputTexture, uv + vec2(ns.x, ps.y)).rgb;
|
||||
vec3 k = texture(uInputTexture, uv + vec2(ps.x, ps.y)).rgb;
|
||||
vec3 l = texture(uInputTexture, uv + vec2(ns.x, ns.y)).rgb;
|
||||
vec3 m = texture(uInputTexture, uv + vec2(ps.x, ns.y)).rgb;
|
||||
vec3 sampleColor = (a + c + g + i) * 0.03125;
|
||||
sampleColor += (b + d + f + h) * 0.0625;
|
||||
sampleColor += (e + j + k + l + m) * 0.125;
|
||||
return sampleColor;
|
||||
}
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(sample13Tap(vTexCoord), 1.0);
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
/** Bevy Bloom: 3x3 tent upsample pass. */
|
||||
val BEVY_BLOOM_UPSAMPLE = """
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
in vec2 vTexCoord;
|
||||
out vec4 fragColor;
|
||||
uniform sampler2D uInputTexture;
|
||||
uniform vec2 uInputTexelSize;
|
||||
|
||||
void main() {
|
||||
float x = uInputTexelSize.x;
|
||||
float y = uInputTexelSize.y;
|
||||
vec2 uv = vTexCoord;
|
||||
vec3 a = texture(uInputTexture, vec2(uv.x - x, uv.y + y)).rgb;
|
||||
vec3 b = texture(uInputTexture, vec2(uv.x, uv.y + y)).rgb;
|
||||
vec3 c = texture(uInputTexture, vec2(uv.x + x, uv.y + y)).rgb;
|
||||
vec3 d = texture(uInputTexture, vec2(uv.x - x, uv.y)).rgb;
|
||||
vec3 e = texture(uInputTexture, vec2(uv.x, uv.y)).rgb;
|
||||
vec3 f = texture(uInputTexture, vec2(uv.x + x, uv.y)).rgb;
|
||||
vec3 g = texture(uInputTexture, vec2(uv.x - x, uv.y - y)).rgb;
|
||||
vec3 h = texture(uInputTexture, vec2(uv.x, uv.y - y)).rgb;
|
||||
vec3 i = texture(uInputTexture, vec2(uv.x + x, uv.y - y)).rgb;
|
||||
vec3 sampleColor = e * 0.25;
|
||||
sampleColor += (b + d + f + h) * 0.125;
|
||||
sampleColor += (a + c + g + i) * 0.0625;
|
||||
fragColor = vec4(sampleColor, 1.0);
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
/** LDR Bloom: final blurred highlight contribution. */
|
||||
val BEVY_BLOOM_COMPOSITE = """
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
in vec2 vTexCoord;
|
||||
out vec4 fragColor;
|
||||
uniform sampler2D uBloomTexture;
|
||||
uniform sampler2D uBloomTextureNext;
|
||||
uniform vec2 uBloomTexelSize;
|
||||
uniform vec2 uBloomTexelSizeNext;
|
||||
uniform float uBlend;
|
||||
uniform float uMipBlend;
|
||||
|
||||
vec3 sampleTentLower(vec2 uv) {
|
||||
float x = uBloomTexelSize.x;
|
||||
float y = uBloomTexelSize.y;
|
||||
vec3 a = texture(uBloomTexture, vec2(uv.x - x, uv.y + y)).rgb;
|
||||
vec3 b = texture(uBloomTexture, vec2(uv.x, uv.y + y)).rgb;
|
||||
vec3 c = texture(uBloomTexture, vec2(uv.x + x, uv.y + y)).rgb;
|
||||
vec3 d = texture(uBloomTexture, vec2(uv.x - x, uv.y)).rgb;
|
||||
vec3 e = texture(uBloomTexture, vec2(uv.x, uv.y)).rgb;
|
||||
vec3 f = texture(uBloomTexture, vec2(uv.x + x, uv.y)).rgb;
|
||||
vec3 g = texture(uBloomTexture, vec2(uv.x - x, uv.y - y)).rgb;
|
||||
vec3 h = texture(uBloomTexture, vec2(uv.x, uv.y - y)).rgb;
|
||||
vec3 i = texture(uBloomTexture, vec2(uv.x + x, uv.y - y)).rgb;
|
||||
vec3 sampleColor = e * 0.25;
|
||||
sampleColor += (b + d + f + h) * 0.125;
|
||||
sampleColor += (a + c + g + i) * 0.0625;
|
||||
return sampleColor;
|
||||
}
|
||||
|
||||
vec3 sampleTentUpper(vec2 uv) {
|
||||
float x = uBloomTexelSizeNext.x;
|
||||
float y = uBloomTexelSizeNext.y;
|
||||
vec3 a = texture(uBloomTextureNext, vec2(uv.x - x, uv.y + y)).rgb;
|
||||
vec3 b = texture(uBloomTextureNext, vec2(uv.x, uv.y + y)).rgb;
|
||||
vec3 c = texture(uBloomTextureNext, vec2(uv.x + x, uv.y + y)).rgb;
|
||||
vec3 d = texture(uBloomTextureNext, vec2(uv.x - x, uv.y)).rgb;
|
||||
vec3 e = texture(uBloomTextureNext, vec2(uv.x, uv.y)).rgb;
|
||||
vec3 f = texture(uBloomTextureNext, vec2(uv.x + x, uv.y)).rgb;
|
||||
vec3 g = texture(uBloomTextureNext, vec2(uv.x - x, uv.y - y)).rgb;
|
||||
vec3 h = texture(uBloomTextureNext, vec2(uv.x, uv.y - y)).rgb;
|
||||
vec3 i = texture(uBloomTextureNext, vec2(uv.x + x, uv.y - y)).rgb;
|
||||
vec3 sampleColor = e * 0.25;
|
||||
sampleColor += (b + d + f + h) * 0.125;
|
||||
sampleColor += (a + c + g + i) * 0.0625;
|
||||
return sampleColor;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 lowerBloom = sampleTentLower(vTexCoord);
|
||||
vec3 upperBloom = sampleTentUpper(vTexCoord);
|
||||
vec3 bloom = mix(lowerBloom, upperBloom, uMipBlend) * uBlend;
|
||||
fragColor = vec4(clamp(bloom, 0.0, 1.0), 1.0);
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
/** Halation Pass 1: 高光重建 + 暖红背反射种子 + 水平高斯模糊 */
|
||||
val HALATION_PREVIEW_EXTRACT_BLUR_H = """
|
||||
#version 300 es
|
||||
|
||||
@@ -204,6 +204,7 @@ class LutSynthesisViewModel(application: Application) : AndroidViewModel(applica
|
||||
val bakeableRecipe = recipe.copy(
|
||||
filmGrain = 0f,
|
||||
vignette = 0f,
|
||||
bloom = 0f,
|
||||
halation = 0f,
|
||||
redHalation = 0f,
|
||||
chromaticAberration = 0f,
|
||||
@@ -276,6 +277,7 @@ class LutSynthesisViewModel(application: Application) : AndroidViewModel(applica
|
||||
val bakeableRecipe = recipe.copy(
|
||||
filmGrain = 0f,
|
||||
vignette = 0f,
|
||||
bloom = 0f,
|
||||
halation = 0f,
|
||||
redHalation = 0f,
|
||||
chromaticAberration = 0f,
|
||||
|
||||
@@ -33,7 +33,14 @@ data class CameraPreset(
|
||||
// 是否为内置预设
|
||||
val isBuiltIn: Boolean = false
|
||||
) {
|
||||
fun toJson(): String = gson.toJson(this)
|
||||
fun toJson(): String = gson.toJson(withoutLegacyHdf())
|
||||
|
||||
fun withoutLegacyHdf(): CameraPreset {
|
||||
return copy(
|
||||
colorRecipe = colorRecipe.copy(halation = 0f),
|
||||
effects = effects.copy(hdf = 0f)
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val gson = Gson()
|
||||
@@ -123,7 +130,6 @@ data class CameraPreset(
|
||||
effects = EffectParams.DEFAULT.copy(
|
||||
vignette = -0.25f,
|
||||
filmGrain = 0.25f,
|
||||
hdf = 0.25f,
|
||||
halation = 0.25f,
|
||||
),
|
||||
frameId = "time",
|
||||
@@ -154,7 +160,7 @@ data class CameraPreset(
|
||||
|
||||
fun fromJson(json: String): CameraPreset? {
|
||||
return try {
|
||||
gson.fromJson(json, CameraPreset::class.java)
|
||||
gson.fromJson(json, CameraPreset::class.java)?.withoutLegacyHdf()
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
@@ -164,12 +170,12 @@ data class CameraPreset(
|
||||
if (json.isEmpty()) return emptyList()
|
||||
return try {
|
||||
val type = object : TypeToken<List<CameraPreset>>() {}.type
|
||||
gson.fromJson(json, type) ?: emptyList()
|
||||
(gson.fromJson(json, type) ?: emptyList<CameraPreset>()).map { it.withoutLegacyHdf() }
|
||||
} catch (e: Exception) {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
fun listToJson(list: List<CameraPreset>): String = gson.toJson(list)
|
||||
fun listToJson(list: List<CameraPreset>): String = gson.toJson(list.map { it.withoutLegacyHdf() })
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ data class ColorRecipeParams(
|
||||
val filmGrain: Float = 0f, // 0.0 ~ 1.0 (颗粒强度,0为无颗粒)
|
||||
val vignette: Float = 0f, // -1.0 ~ +1.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为无效果)
|
||||
val halation: Float = 0f, // 0.0 ~ 1.0 (高光扩散强度,0为无效果,模拟 GR3 HDF)
|
||||
val redHalation: Float = 0f, // 0.0 ~ 1.0 (胶片暖红色边缘光晕强度,0为无效果)
|
||||
val chromaticAberration: Float = 0f, // 0.0 ~ 1.0 (色散/边缘溢色强度,0为无效果)
|
||||
@@ -100,7 +102,8 @@ data class ColorRecipeParams(
|
||||
filmGrain == 0f &&
|
||||
vignette == 0f &&
|
||||
bleachBypass == 0f &&
|
||||
halation == 0f &&
|
||||
bloom == 0f &&
|
||||
softLight == 0f &&
|
||||
redHalation == 0f &&
|
||||
chromaticAberration == 0f &&
|
||||
noise == 0f &&
|
||||
@@ -170,7 +173,8 @@ data class ColorRecipeParams(
|
||||
filmGrain == other.filmGrain &&
|
||||
vignette == other.vignette &&
|
||||
bleachBypass == other.bleachBypass &&
|
||||
halation == other.halation &&
|
||||
bloom == other.bloom &&
|
||||
softLight == other.softLight &&
|
||||
redHalation == other.redHalation &&
|
||||
chromaticAberration == other.chromaticAberration &&
|
||||
noise == other.noise &&
|
||||
@@ -222,7 +226,7 @@ data class ColorRecipeParams(
|
||||
/**
|
||||
* 序列化为 JSON 字符串
|
||||
*/
|
||||
fun toJson(): String = gson.toJson(this)
|
||||
fun toJson(): String = gson.toJson(copy(halation = 0f))
|
||||
|
||||
companion object {
|
||||
private val gson = Gson()
|
||||
@@ -231,7 +235,7 @@ data class ColorRecipeParams(
|
||||
* 从 JSON 字符串反序列化
|
||||
*/
|
||||
fun fromJson(json: String): ColorRecipeParams {
|
||||
return gson.fromJson(json, ColorRecipeParams::class.java) ?: return DEFAULT
|
||||
return gson.fromJson(json, ColorRecipeParams::class.java)?.copy(halation = 0f) ?: return DEFAULT
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,6 +268,8 @@ enum class RecipeParam(
|
||||
FILM_GRAIN(R.string.recipe_param_film_grain, 0.0f, 1.0f, 0f),
|
||||
VIGNETTE(R.string.recipe_param_vignette, -1.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),
|
||||
HDF(R.string.recipe_param_hdf, 0.0f, 1.0f, 0f),
|
||||
HALATION(R.string.recipe_param_halation, 0.0f, 1.0f, 0f),
|
||||
CHROMATIC_ABERRATION(R.string.recipe_param_chromatic_aberration, 0.0f, 1.0f, 0f),
|
||||
@@ -331,6 +337,8 @@ enum class RecipeParam(
|
||||
FILM_GRAIN -> params.filmGrain
|
||||
VIGNETTE -> params.vignette
|
||||
BLEACH_BYPASS -> params.bleachBypass
|
||||
BLOOM -> params.bloom
|
||||
SOFT_LIGHT -> params.softLight
|
||||
HDF -> params.halation
|
||||
HALATION -> params.redHalation
|
||||
CHROMATIC_ABERRATION -> params.chromaticAberration
|
||||
@@ -394,6 +402,8 @@ enum class RecipeParam(
|
||||
FILM_GRAIN -> params.copy(filmGrain = clampedValue)
|
||||
VIGNETTE -> params.copy(vignette = clampedValue)
|
||||
BLEACH_BYPASS -> params.copy(bleachBypass = clampedValue)
|
||||
BLOOM -> params.copy(bloom = clampedValue)
|
||||
SOFT_LIGHT -> params.copy(softLight = clampedValue)
|
||||
HDF -> params.copy(halation = clampedValue)
|
||||
HALATION -> params.copy(redHalation = clampedValue)
|
||||
CHROMATIC_ABERRATION -> params.copy(chromaticAberration = clampedValue)
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.google.gson.Gson
|
||||
data class EffectParams(
|
||||
val vignette: Float = 0f, // 暗角 (-1.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)
|
||||
val hdf: Float = 0f, // 高光扩散 HDF (0.0 ~ 1.0)
|
||||
val halation: Float = 0f, // 边缘红晕 Halation (0.0 ~ 1.0)
|
||||
val chromaticAberration: Float = 0f, // 色散 (0.0 ~ 1.0)
|
||||
@@ -22,7 +24,8 @@ data class EffectParams(
|
||||
fun isDefault(): Boolean {
|
||||
return vignette == 0f &&
|
||||
filmGrain == 0f &&
|
||||
hdf == 0f &&
|
||||
bloom == 0f &&
|
||||
softLight == 0f &&
|
||||
halation == 0f &&
|
||||
chromaticAberration == 0f &&
|
||||
noise == 0f &&
|
||||
@@ -37,7 +40,9 @@ data class EffectParams(
|
||||
return recipe.copy(
|
||||
vignette = vignette,
|
||||
filmGrain = filmGrain,
|
||||
halation = hdf, // 底层 halation 属性对应 HDF
|
||||
bloom = bloom,
|
||||
softLight = softLight,
|
||||
halation = 0f, // 旧 HDF 已移除 UI 入口,强制归零以避免旧值继续生效
|
||||
redHalation = halation, // 底层 redHalation 属性对应 Halation
|
||||
chromaticAberration = chromaticAberration,
|
||||
noise = noise,
|
||||
@@ -45,7 +50,7 @@ data class EffectParams(
|
||||
)
|
||||
}
|
||||
|
||||
fun toJson(): String = gson.toJson(this)
|
||||
fun toJson(): String = gson.toJson(copy(hdf = 0f))
|
||||
|
||||
companion object {
|
||||
private val gson = Gson()
|
||||
@@ -53,10 +58,24 @@ data class EffectParams(
|
||||
|
||||
fun fromJson(json: String): EffectParams {
|
||||
return try {
|
||||
gson.fromJson(json, EffectParams::class.java) ?: DEFAULT
|
||||
gson.fromJson(json, EffectParams::class.java)?.copy(hdf = 0f) ?: DEFAULT
|
||||
} catch (e: Exception) {
|
||||
DEFAULT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun ColorRecipeParams.toEffectParams(): EffectParams {
|
||||
return EffectParams(
|
||||
vignette = vignette,
|
||||
filmGrain = filmGrain,
|
||||
bloom = bloom,
|
||||
softLight = softLight,
|
||||
hdf = 0f,
|
||||
halation = redHalation,
|
||||
chromaticAberration = chromaticAberration,
|
||||
noise = noise,
|
||||
lowRes = lowRes
|
||||
)
|
||||
}
|
||||
@@ -56,6 +56,8 @@ fun ColorRecipePanel(
|
||||
val isBakeable: (RecipeParam) -> Boolean = { param ->
|
||||
param != RecipeParam.VIGNETTE &&
|
||||
param != RecipeParam.FILM_GRAIN &&
|
||||
param != RecipeParam.BLOOM &&
|
||||
param != RecipeParam.SOFT_LIGHT &&
|
||||
param != RecipeParam.HDF &&
|
||||
param != RecipeParam.HALATION &&
|
||||
param != RecipeParam.CHROMATIC_ABERRATION &&
|
||||
@@ -103,7 +105,6 @@ fun ColorRecipePanel(
|
||||
RecipeParam.BLEACH_BYPASS,
|
||||
),
|
||||
listOf( // 7 lens
|
||||
RecipeParam.HDF,
|
||||
RecipeParam.HALATION,
|
||||
RecipeParam.CHROMATIC_ABERRATION,
|
||||
RecipeParam.NOISE,
|
||||
@@ -691,6 +692,8 @@ private fun formatParamValue(param: RecipeParam, value: Float): String {
|
||||
RecipeParam.NOISE,
|
||||
RecipeParam.LOW_RES,
|
||||
RecipeParam.BLEACH_BYPASS,
|
||||
RecipeParam.BLOOM,
|
||||
RecipeParam.SOFT_LIGHT,
|
||||
RecipeParam.HDF,
|
||||
RecipeParam.HALATION,
|
||||
RecipeParam.CHROMATIC_ABERRATION -> String.format("%.2f", value)
|
||||
@@ -753,6 +756,8 @@ private fun getParamColor(param: RecipeParam): Color {
|
||||
RecipeParam.NOISE -> Color(0xFFA1887F) // 浅棕色
|
||||
RecipeParam.VIGNETTE -> Color(0xFF795548) // 棕色
|
||||
RecipeParam.BLEACH_BYPASS -> Color(0xFF00BCD4) // 青色
|
||||
RecipeParam.BLOOM -> Color(0xFFFFD54F) // 泛光
|
||||
RecipeParam.SOFT_LIGHT -> Color(0xFFE8E1D4) // 柔光
|
||||
RecipeParam.HDF -> Color(0xFFFFC107) // 暖黄色(高光扩散)
|
||||
RecipeParam.HALATION -> Color(0xFFFF7043) // 暖橙色(胶片光晕)
|
||||
RecipeParam.CHROMATIC_ABERRATION -> Color(0xFFAB47BC) // 紫色(色散)
|
||||
|
||||
@@ -39,7 +39,8 @@ enum class EffectType(
|
||||
) {
|
||||
FILM_GRAIN(RecipeParam.FILM_GRAIN, Color(0xFF9E9E9E), 0f, 1f, 0f),
|
||||
VIGNETTE(RecipeParam.VIGNETTE, Color(0xFF795548), -1f, 1f, 0f),
|
||||
HDF(RecipeParam.HDF, Color(0xFFFFC107), 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),
|
||||
CHROMATIC_ABERRATION(RecipeParam.CHROMATIC_ABERRATION, Color(0xFFAB47BC), 0f, 1f, 0f),
|
||||
NOISE(RecipeParam.NOISE, Color(0xFFA1887F), 0f, 1f, 0f),
|
||||
@@ -49,7 +50,8 @@ enum class EffectType(
|
||||
return when (this) {
|
||||
FILM_GRAIN -> params.filmGrain
|
||||
VIGNETTE -> params.vignette
|
||||
HDF -> params.hdf
|
||||
BLOOM -> params.bloom
|
||||
SOFT_LIGHT -> params.softLight
|
||||
HALATION -> params.halation
|
||||
CHROMATIC_ABERRATION -> params.chromaticAberration
|
||||
NOISE -> params.noise
|
||||
@@ -62,7 +64,8 @@ enum class EffectType(
|
||||
return when (this) {
|
||||
FILM_GRAIN -> params.copy(filmGrain = clamped)
|
||||
VIGNETTE -> params.copy(vignette = clamped)
|
||||
HDF -> params.copy(hdf = clamped)
|
||||
BLOOM -> params.copy(bloom = clamped)
|
||||
SOFT_LIGHT -> params.copy(softLight = clamped)
|
||||
HALATION -> params.copy(halation = clamped)
|
||||
CHROMATIC_ABERRATION -> params.copy(chromaticAberration = clamped)
|
||||
NOISE -> params.copy(noise = clamped)
|
||||
|
||||
@@ -56,7 +56,7 @@ import me.saket.telephoto.zoomable.rememberZoomableImageState
|
||||
import me.saket.telephoto.zoomable.rememberZoomableState
|
||||
import com.hinnka.mycamera.gallery.MediaData
|
||||
import com.hinnka.mycamera.model.ColorRecipeParams
|
||||
import com.hinnka.mycamera.model.EffectParams
|
||||
import com.hinnka.mycamera.model.toEffectParams
|
||||
import com.hinnka.mycamera.raw.SpectralFilmSelection
|
||||
import com.hinnka.mycamera.raw.SpectralFilmTuning
|
||||
import com.hinnka.mycamera.ui.camera.LutEditBottomSheet
|
||||
@@ -1188,21 +1188,12 @@ fun GalleryEditScreen(
|
||||
}
|
||||
|
||||
if (showEffectsSheet) {
|
||||
val currentRecipe = editPhotoRecipeParams ?: editLutRecipeParams
|
||||
val currentEffectParams = EffectParams(
|
||||
vignette = currentRecipe.vignette,
|
||||
filmGrain = currentRecipe.filmGrain,
|
||||
hdf = currentRecipe.halation,
|
||||
halation = currentRecipe.redHalation,
|
||||
chromaticAberration = currentRecipe.chromaticAberration,
|
||||
noise = currentRecipe.noise,
|
||||
lowRes = currentRecipe.lowRes
|
||||
)
|
||||
val currentRecipe = previewRecipeParamsOverride ?: editPhotoRecipeParams ?: editLutRecipeParams
|
||||
val currentEffectParams = currentRecipe.toEffectParams()
|
||||
EffectsBottomSheet(
|
||||
currentParams = currentEffectParams,
|
||||
onParamsChange = { newParams ->
|
||||
val updatedRecipe = newParams.applyTo(currentRecipe)
|
||||
viewModel.setPhotoRecipeParams(updatedRecipe)
|
||||
viewModel.setPhotoEffectParams(newParams, currentRecipe)
|
||||
},
|
||||
onDismiss = { showEffectsSheet = false },
|
||||
containerColor = Color(0x151A1A1A)
|
||||
|
||||
@@ -2738,7 +2738,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
|
||||
suspend fun applyLut(bitmap: Bitmap): Bitmap = withContext(Dispatchers.IO) {
|
||||
currentLutConfig?.let { lut ->
|
||||
val params = contentRepository.lutManager.loadColorRecipeParams(currentLutId.value)
|
||||
val params = getMergedRecipeParams(contentRepository.lutManager.loadColorRecipeParams(currentLutId.value))
|
||||
contentRepository.imageProcessor.applyLut(
|
||||
bitmap = bitmap,
|
||||
isHlgInput = shouldTreatPreviewAsHlgInput(state.value),
|
||||
@@ -3736,7 +3736,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
val metadata = MediaMetadata(
|
||||
lutId = currentLutId.value,
|
||||
frameId = currentFrameId,
|
||||
colorRecipeParams = currentRecipeParams.value,
|
||||
colorRecipeParams = getMergedRecipeParams(),
|
||||
baselineTarget = baselineMetadata?.first,
|
||||
baselineLutId = baselineMetadata?.second,
|
||||
baselineColorRecipeParams = baselineMetadata?.third,
|
||||
@@ -3885,7 +3885,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
val metadata = MediaMetadata(
|
||||
lutId = lutIdToSave,
|
||||
frameId = frameIdToSave,
|
||||
colorRecipeParams = currentRecipeParams.value,
|
||||
colorRecipeParams = getMergedRecipeParams(),
|
||||
baselineTarget = baselineMetadata?.first,
|
||||
baselineLutId = baselineMetadata?.second,
|
||||
baselineColorRecipeParams = baselineMetadata?.third,
|
||||
@@ -4046,7 +4046,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
val metadata = MediaMetadata(
|
||||
lutId = lutIdToSave,
|
||||
frameId = frameIdToSave,
|
||||
colorRecipeParams = currentRecipeParams.value,
|
||||
colorRecipeParams = getMergedRecipeParams(),
|
||||
baselineTarget = baselineMetadata?.first,
|
||||
baselineLutId = baselineMetadata?.second,
|
||||
baselineColorRecipeParams = baselineMetadata?.third,
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.hinnka.mycamera.lut.PhotoTransformation
|
||||
import com.hinnka.mycamera.lut.exportVideoWithEffects
|
||||
import com.hinnka.mycamera.lut.creator.OpenAIApiClient
|
||||
import com.hinnka.mycamera.model.ColorRecipeParams
|
||||
import com.hinnka.mycamera.model.EffectParams
|
||||
import com.hinnka.mycamera.raw.DcpInfo
|
||||
import com.hinnka.mycamera.raw.RawProcessingPreferences
|
||||
import com.hinnka.mycamera.raw.SpectralFilmSelection
|
||||
@@ -1731,6 +1732,11 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
editPhotoRecipeParams.value = params
|
||||
}
|
||||
|
||||
fun setPhotoEffectParams(params: EffectParams, baseRecipeOverride: ColorRecipeParams? = null) {
|
||||
val baseRecipe = baseRecipeOverride ?: editPhotoRecipeParams.value ?: editLutRecipeParams.value
|
||||
editPhotoRecipeParams.value = params.applyTo(baseRecipe)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 LUT
|
||||
*/
|
||||
|
||||
@@ -163,6 +163,8 @@
|
||||
<string name="recipe_param_film_grain">Körnung</string>
|
||||
<string name="recipe_param_vignette">Vignettierung</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>
|
||||
<string name="recipe_param_halation">Halation</string>
|
||||
<string name="recipe_param_lut_intensity">LUT</string>
|
||||
|
||||
|
||||
@@ -163,6 +163,8 @@
|
||||
<string name="recipe_param_film_grain">Grain</string>
|
||||
<string name="recipe_param_vignette">Vignettage</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>
|
||||
<string name="recipe_param_halation">Halation</string>
|
||||
<string name="recipe_param_lut_intensity">LUT</string>
|
||||
|
||||
|
||||
@@ -163,6 +163,8 @@
|
||||
<string name="recipe_param_film_grain">Grain</string>
|
||||
<string name="recipe_param_vignette">Vinyet</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>
|
||||
<string name="recipe_param_halation">Halasi</string>
|
||||
<string name="recipe_param_lut_intensity">LUT</string>
|
||||
|
||||
|
||||
@@ -163,6 +163,8 @@
|
||||
<string name="recipe_param_film_grain">粒子</string>
|
||||
<string name="recipe_param_vignette">周辺減光</string>
|
||||
<string name="recipe_param_bleach_bypass">銀残し</string>
|
||||
<string name="recipe_param_bloom">ブルーム</string>
|
||||
<string name="recipe_param_soft_light">ソフトライト</string>
|
||||
<string name="recipe_param_halation">ハレーション</string>
|
||||
<string name="recipe_param_lut_intensity">LUT</string>
|
||||
|
||||
|
||||
@@ -164,6 +164,8 @@
|
||||
<string name="recipe_param_film_grain">그레인</string>
|
||||
<string name="recipe_param_vignette">비네팅</string>
|
||||
<string name="recipe_param_bleach_bypass">블리치 바이패스</string>
|
||||
<string name="recipe_param_bloom">블룸</string>
|
||||
<string name="recipe_param_soft_light">소프트 라이트</string>
|
||||
<string name="recipe_param_halation">할레이션</string>
|
||||
<string name="recipe_param_lut_intensity">LUT</string>
|
||||
|
||||
|
||||
@@ -164,6 +164,8 @@
|
||||
<string name="recipe_param_film_grain">Grão</string>
|
||||
<string name="recipe_param_vignette">Vinheta</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>
|
||||
<string name="recipe_param_halation">Halação</string>
|
||||
<string name="recipe_param_lut_intensity">LUT</string>
|
||||
|
||||
|
||||
@@ -306,6 +306,8 @@
|
||||
<string name="recipe_param_film_grain">นอยซ์แบบฟิล์ม</string>
|
||||
<string name="recipe_param_vignette">ขอบมืด</string>
|
||||
<string name="recipe_param_bleach_bypass">การข้ามกระบวนการล้าง (Bleach Bypass)</string>
|
||||
<string name="recipe_param_bloom">แสงฟุ้ง</string>
|
||||
<string name="recipe_param_soft_light">แสงนุ่ม</string>
|
||||
<string name="recipe_param_hdf">HDF</string>
|
||||
<string name="recipe_param_halation">แสงเรืองรอง (Halation)</string>
|
||||
<string name="recipe_param_chromatic_aberration">การกระจายตัว (CA)</string>
|
||||
|
||||
@@ -308,6 +308,8 @@
|
||||
<string name="recipe_param_film_grain">颗粒</string>
|
||||
<string name="recipe_param_vignette">晕影</string>
|
||||
<string name="recipe_param_bleach_bypass">留银冲洗</string>
|
||||
<string name="recipe_param_bloom">泛光</string>
|
||||
<string name="recipe_param_soft_light">柔光</string>
|
||||
<string name="recipe_param_hdf">HDF</string>
|
||||
<string name="recipe_param_halation">光晕</string>
|
||||
<string name="recipe_param_chromatic_aberration">色散(CA)</string>
|
||||
|
||||
@@ -221,6 +221,8 @@
|
||||
<string name="recipe_param_film_grain">顆粒</string>
|
||||
<string name="recipe_param_vignette">暈影</string>
|
||||
<string name="recipe_param_bleach_bypass">留銀沖洗</string>
|
||||
<string name="recipe_param_bloom">泛光</string>
|
||||
<string name="recipe_param_soft_light">柔光</string>
|
||||
<string name="recipe_param_hdf">HDF</string>
|
||||
<string name="recipe_param_halation">光暈</string>
|
||||
<string name="recipe_param_chromatic_aberration">色散(CA)</string>
|
||||
|
||||
@@ -313,6 +313,8 @@
|
||||
<string name="recipe_param_film_grain">Grain</string>
|
||||
<string name="recipe_param_vignette">Vignette</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>
|
||||
<string name="recipe_param_hdf">HDF</string>
|
||||
<string name="recipe_param_halation">Halation</string>
|
||||
<string name="recipe_param_chromatic_aberration">CA</string>
|
||||
|
||||
Reference in new issue
Block a user