mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-08 22:34:03 +09:00
bias lighting on smaller video dimension
This commit is contained in:
@@ -497,13 +497,30 @@ function getRGBfromScr(x, y) {
|
|||||||
|
|
||||||
function setBiasLighting() {
|
function setBiasLighting() {
|
||||||
let samples = []
|
let samples = []
|
||||||
for (let x = 8; x < 560; x+=32) {
|
|
||||||
samples.push(getRGBfromScr(x, 3))
|
// Get native resolution for centering calculation
|
||||||
samples.push(getRGBfromScr(x, 445))
|
let nativeWidth = graphics.getPixelDimension()[0]
|
||||||
|
let nativeHeight = graphics.getPixelDimension()[1]
|
||||||
|
|
||||||
|
// Calculate video position offset (centered)
|
||||||
|
let offsetX = Math.floor((nativeWidth - width) / 2)
|
||||||
|
let offsetY = Math.floor((nativeHeight - height) / 2)
|
||||||
|
|
||||||
|
// Sample from video borders, scaled to actual video dimensions
|
||||||
|
let sampleStepX = Math.max(8, Math.floor(width / 18)) // ~18 samples across width
|
||||||
|
let sampleStepY = Math.max(8, Math.floor(height / 17)) // ~17 samples across height
|
||||||
|
let borderMargin = Math.min(8, Math.floor(width / 70)) // Proportional border margin
|
||||||
|
|
||||||
|
// Sample top and bottom borders
|
||||||
|
for (let x = borderMargin; x < width - borderMargin; x += sampleStepX) {
|
||||||
|
samples.push(getRGBfromScr(x + offsetX, borderMargin + offsetY))
|
||||||
|
samples.push(getRGBfromScr(x + offsetX, height - borderMargin - 1 + offsetY))
|
||||||
}
|
}
|
||||||
for (let y = 29; y < 448; y+=26) {
|
|
||||||
samples.push(getRGBfromScr(8, y))
|
// Sample left and right borders
|
||||||
samples.push(getRGBfromScr(552, y))
|
for (let y = borderMargin; y < height - borderMargin; y += sampleStepY) {
|
||||||
|
samples.push(getRGBfromScr(borderMargin + offsetX, y + offsetY))
|
||||||
|
samples.push(getRGBfromScr(width - borderMargin - 1 + offsetX, y + offsetY))
|
||||||
}
|
}
|
||||||
|
|
||||||
let out = [0.0, 0.0, 0.0]
|
let out = [0.0, 0.0, 0.0]
|
||||||
|
|||||||
@@ -1325,15 +1325,8 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
// Calculate centering offset
|
// Calculate centering offset
|
||||||
val offsetX = (nativeWidth - width) / 2
|
val offsetX = (nativeWidth - width) / 2
|
||||||
val offsetY = (nativeHeight - height) / 2
|
val offsetY = (nativeHeight - height) / 2
|
||||||
|
|
||||||
// Clear framebuffer with transparent pixels first
|
|
||||||
val transparentRG = 0.toByte() // r=0, g=0
|
|
||||||
val transparentBA = 0.toByte() // b=0, a=0 (transparent)
|
|
||||||
|
|
||||||
// Fill entire framebuffer with transparent pixels
|
|
||||||
val totalNativePixels = (nativeWidth * nativeHeight).toLong()
|
val totalNativePixels = (nativeWidth * nativeHeight).toLong()
|
||||||
// UnsafeHelper.unsafe.setMemory(gpu.framebuffer.ptr, totalNativePixels, transparentRG)
|
|
||||||
// UnsafeHelper.unsafe.setMemory(gpu.framebuffer2!!.ptr, totalNativePixels, transparentBA)
|
|
||||||
|
|
||||||
// Process video pixels in 8KB chunks to balance memory usage and performance
|
// Process video pixels in 8KB chunks to balance memory usage and performance
|
||||||
val totalVideoPixels = width * height
|
val totalVideoPixels = width * height
|
||||||
|
|||||||
Reference in New Issue
Block a user