MaLiang-Data / code /ue_capture /run_all_v10.ps1
15y6u87's picture
Add code
39149b6 verified
Raw History Blame Contribute Delete
5.25 kB
param([int]$Frames=4800,[int]$Rounds=12,[string[]]$Roots=@('F:\GameCrafter_v10\raw','E:\GameCrafter_v10\raw','H:\GameCrafter_v10\raw','G:\GameCrafter_v10\raw'),
[datetime]$NoStartAfter=[datetime]'2026-10-23 18:00',[int]$MinFreeGB=30,[string[]]$Only=@(),[string]$TagPrefix='R10',[int]$SeedOffset=0,[string]$ExtraEngine='',[double]$LookSeconds=6)
# v10 real production ("realistic cinematic", same config as the approved v10real23 pilot): photoreal biome re-scatter on the scene's
# walkable ground, telephoto camera, player kept centred (no fight framing), a new look (biome variant, light preset, camera) every
# LookSeconds on the 96-frame cut grid so every 81-frame clip has one look. Per run: new seeds, random mirror X.
# After each run cond.png is written in the background. Stops at jobs\STOP_V10 or when no drive keeps MinFreeGB.
$ErrorActionPreference='Continue'
$cw='G:\GameCrafter\capture_work'; $rc=Join-Path $cw 'v6\run_capture_v6.ps1'; $py='E:\Anaconda3\python.exe'
$runlog="$cw\v10\out\run_all_v10.txt"
function Log([string]$m){ $line="$(Get-Date -Format o) $m"; Add-Content -Path $runlog -Value $line; Write-Output $line }
function PickRoot(){ foreach($r in $Roots){ $q=$r.Substring(0,1); $f=(Get-PSDrive -Name $q).Free/1GB; if($f -ge $MinFreeGB){ New-Item -ItemType Directory -Force -Path $r | Out-Null; return $r } }; return $null }
$scenes=@(Get-ChildItem $cw -Directory | Where-Object { $_.Name -match '^\d\d_' } | Sort-Object Name | ForEach-Object { $_.Name })
if($Only.Count){ $scenes=@($scenes | Where-Object { $Only -contains $_.Substring(0,2) }) }
$sig='[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);'
$power=Add-Type -MemberDefinition $sig -Name 'PowerV10' -Namespace 'GameCrafterV10' -PassThru
$ls=$LookSeconds.ToString('0.##',[Globalization.CultureInfo]::InvariantCulture)
Log "run_all_v10 start scenes=$($scenes.Count) rounds=$Rounds frames=$Frames look=${ls}s until $NoStartAfter prefix=$TagPrefix seedoffset=$SeedOffset extra=$ExtraEngine"
$warm=@{}
for($r=1;$r -le $Rounds;$r++){
foreach($s in $scenes){
[void]$power::SetThreadExecutionState([uint32]2147483649)
if(Test-Path (Join-Path $cw 'jobs\STOP_V10')){ Log 'stop flag found'; exit 0 }
if((Get-Date) -gt $NoStartAfter){ Log "past $NoStartAfter, not starting more runs"; exit 0 }
$root=PickRoot; if(-not $root){ Log 'no drive with enough free space, stopping'; exit 0 }
$i=[int]$s.Substring(0,2); $seed=$i*1000+500+$r+$SeedOffset
$rng=New-Object System.Random $seed
$mx=$rng.NextDouble() -lt 0.5; $my=$false # mirror Y was not part of the approved v10 real pilot; keep it off
$eng="DatasetArtPass,DatasetV8,DatasetV8Share=1.0,DatasetV9,DatasetV9NoFraming,DatasetV10Real,DatasetV9LookSeconds=$ls"; if($ExtraEngine){ $eng+=','+$ExtraEngine }
$tag="${TagPrefix}_s$seed"
$done=$false; foreach($rr in $Roots){ $res=Join-Path $rr "${s}_$tag\capture_result.json"; if(Test-Path $res){ try{ if([bool](Get-Content $res -Raw | ConvertFrom-Json).ok){ $done=$true } }catch{} } }
if($done){ Log "skip $s $tag"; continue }
$dir=Join-Path $root "${s}_$tag"
if(Test-Path $dir){ Rename-Item $dir "${s}_${tag}_failed_$(Get-Date -Format yyyyMMddHHmmss)" }
$a=@('-NoProfile','-ExecutionPolicy','Bypass','-File',$rc,'-Scene',$s,'-Frames',"$Frames",'-Tag',$tag,'-Seed',"$seed",'-LayoutSeed',"$($seed*7+3)",
'-Appearance','default','-AppearanceSeed',"$($seed*3+1)",'-OutRoot',$root,'-EngineArgs',$eng)
if($mx){ $a+='-Mirror' }; if($my){ $a+='-MirrorY' }
if(-not $warm[$s]){ # first run of a scene after the build: short warm-up so shaders / textures are cached
$w=@($a | ForEach-Object { $_ }); $w[$w.IndexOf('-Frames')+1]='32'; $w[$w.IndexOf('-Tag')+1]="${tag}_warm"; $w[$w.IndexOf('-OutRoot')+1]='H:\GameCrafter_v10\warm'
& powershell.exe @w | Out-Null; Log "warmup $s exit $LASTEXITCODE"; $warm[$s]=$true }
Log "capture $s $tag root=$root mx=$mx my=$my"
$t0=Get-Date; & powershell.exe @a | Out-Null; $ec=$LASTEXITCODE
$okRun=$false; $extra=''; $res=Join-Path $dir 'capture_result.json'
if(Test-Path $res){ try{ $j=Get-Content $res -Raw | ConvertFrom-Json; $okRun=[bool]$j.ok; $extra="looks=$($j.v9.looks) variants=$((@($j.v9.v10_real.variants_used) | Select-Object -Unique).Count) fight_blocks=$($j.fight_blocks)/$($j.total_blocks)" }catch{} }
if(-not $okRun){
Log "capture $s $tag exit $ec ok=False -> retry in 120 s"; Start-Sleep 120
if(Test-Path $dir){ Rename-Item $dir "${s}_${tag}_failed_$(Get-Date -Format yyyyMMddHHmmss)" }
& powershell.exe @a | Out-Null; $ec=$LASTEXITCODE
if(Test-Path $res){ try{ $j=Get-Content $res -Raw | ConvertFrom-Json; $okRun=[bool]$j.ok; $extra="looks=$($j.v9.looks) variants=$((@($j.v9.v10_real.variants_used) | Select-Object -Unique).Count) fight_blocks=$($j.fight_blocks)/$($j.total_blocks) (retry)" }catch{} }
}
Log "capture $s $tag exit $ec ok=$okRun secs=$([int]((Get-Date)-$t0).TotalSeconds) $extra"
if($okRun){ Start-Process -FilePath $py -ArgumentList @("$cw\v9\post\cond_v9.py",$dir) -WindowStyle Hidden -RedirectStandardOutput "$dir\cond_stdout.txt" -RedirectStandardError "$dir\cond_stderr.txt" | Out-Null }
}
}
Log 'run_all_v10 done'