remove scripts

This commit is contained in:
2021-02-25 22:43:28 +01:00
parent 8735f2d409
commit 45286b8178
5 changed files with 35 additions and 43 deletions

View File

@@ -1,2 +0,0 @@
for %%i in (*.frag) do glslangValidator -V %%i -o %%i.spv
for %%i in (*.vert) do glslangValidator -V %%i -o %%i.spv

View File

@@ -1,33 +0,0 @@
$compileHashFile = "compilehashes.xml"
if (Get-ChildItem -File $compileHashFile -ErrorAction SilentlyContinue) {
$hashes = Import-Clixml $compileHashFile
} else {
$hashes = @{}
}
function CompileShader($fileName) {
$spvFileName = "$fileName.spv"
$newHash = Get-FileHash -Path $fileName -Algorithm SHA1
$spvExists = $false
if (Get-ChildItem -File $spvFileName -ErrorAction SilentlyContinue) {
$spvExists = $true
}
if ($spvExists -and $hashes.ContainsKey($fileName) -and $hashes[$fileName] -eq $newHash.Hash) {
Write-Output "Skipping $fileName"
} else {
glslangValidator -V $fileName -o $spvFileName
$hashes.$fileName = $newHash.Hash
}
}
Get-ChildItem -Filter *.vert | ForEach-Object {
CompileShader $_.Name
}
Get-ChildItem -Filter *.frag | ForEach-Object {
CompileShader $_.Name
}
Export-Clixml -Path $compileHashFile -InputObject $hashes

View File

@@ -26,7 +26,7 @@ void main() {
normal_cam_u = normalize(tbn * normal_cam_u); normal_cam_u = normalize(tbn * normal_cam_u);
// vec3 light_direction_cam_u = normalize(ubo.light_position - position_wld); // vec3 light_direction_cam_u = normalize(ubo.light_position - position_wld);
vec3 light_direction_cam_u = normalize(vec3(sin(ubo.time), 1.0, cos(ubo.time))); vec3 light_direction_cam_u = normalize(vec3(1.0, 1.0, 1.0));
float ambient_strength = 0.1; float ambient_strength = 0.1;
vec3 light_color = vec3(1.0, 1.0, 1.0); vec3 light_color = vec3(1.0, 1.0, 1.0);

Binary file not shown.

View File

@@ -1,4 +1,4 @@
use std::{convert::TryInto, io::{Read, Write}, sync::Arc}; use std::{convert::TryInto, io::{self, ErrorKind, Read, Write}, path::PathBuf, sync::Arc};
use vulkano::{command_buffer::AutoCommandBufferBuilder, descriptor::{descriptor::ShaderStages, descriptor_set::PersistentDescriptorSet}, pipeline::shader::ShaderModule}; use vulkano::{command_buffer::AutoCommandBufferBuilder, descriptor::{descriptor::ShaderStages, descriptor_set::PersistentDescriptorSet}, pipeline::shader::ShaderModule};
use vulkano::command_buffer::DynamicState; use vulkano::command_buffer::DynamicState;
@@ -53,6 +53,38 @@ fn shader_module_from_file(device: Arc<Device>, path: &str) -> Arc<ShaderModule>
} }
} }
fn matches_extension(path: &PathBuf, extensions: &Vec<&str>) -> bool {
if let Some(Some(path_extension)) = path.extension().map(|e| e.to_str()) {
for extension in extensions {
if *extension == path_extension { return true; }
}
}
return false;
}
fn compile_shaders() -> io::Result<()> {
for file_maybe in std::fs::read_dir("./shaders")? {
let path = file_maybe?.path();
if !path.is_dir() && matches_extension(&path, &vec!["frag", "vert"]) {
let mut target_path = path.to_str().ok_or(ErrorKind::Other)?.to_string();
target_path.push_str(".spv");
let output = std::process::Command::new("glslangValidator")
.arg("-V")
.arg(path.to_str().ok_or(ErrorKind::Other)?)
.arg("-o")
.arg(target_path)
.output().unwrap();
std::io::stdout().write_all(&output.stdout)?;
if !output.status.success() {
eprintln!("Shader compiler {:?}", output.status);
}
}
}
Ok(())
}
impl DefaultShader { impl DefaultShader {
pub fn new(device: Arc<Device>, render_pass: RP) -> Self { pub fn new(device: Arc<Device>, render_pass: RP) -> Self {
DefaultShader { DefaultShader {
@@ -66,12 +98,7 @@ impl DefaultShader {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
{ {
println!("Compiling shaders..."); println!("Compiling shaders...");
let output = std::process::Command::new("cmd.exe") compile_shaders().unwrap();
.arg("/c")
.arg("compile.bat")
.current_dir("shaders")
.output().unwrap();
std::io::stdout().write_all(&output.stdout).unwrap();
} }
unsafe { unsafe {