$shadercPath = "..\tools\shaderc.exe"
$shadersDir = ".\game\shaders"
$outputBaseDir = ".\game\compiled-shaders"
$includeDir = ".\dependency\bgfx.cmake\bgfx\src"

function Process-Directory {
  param ([string]$DirectoryFull, [string]$DirectoryName)
  Write-Host "Dir: $DirectoryName"
  $outDir = "$outputBaseDir\dx11\$DirectoryName"
  New-Item -ItemType Directory -Path $outDir -Force -ErrorAction Stop | Out-Null
  Write-Host "Frag"
  & $shadercPath -f "$DirectoryFull\vert.sc" -o "$outDir\vert.bin" -i $includeDir --type v --platform windows --profile s_5_0
  Write-Host "Vert"
  & $shadercPath -f "$DirectoryFull\frag.sc" -o "$outDir\frag.bin" -i $includeDir --type f --platform windows --profile s_5_0
}

$subdirectories = Get-ChildItem -Path $shadersDir -Directory -Recurse -ErrorAction Stop
foreach ($subdirectory in $subdirectories) {
  Process-Directory -DirectoryFull $subdirectory.FullName -DirectoryName $subdirectory.Name
}
