forked from netwarm007/GameEngineFromScratch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshader_converter.sh
executable file
·36 lines (35 loc) · 1.47 KB
/
shader_converter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
set -e
echo "concat source files"
case $2 in
vs)
ext=vert
;;
ps)
ext=frag
;;
gs)
ext=geom
;;
cs)
ext=comp
;;
esac
InputFile=Asset/Shaders/$1_$2.glsl
if [ -e $InputFile ]; then
cat Asset/Shaders/cbuffer.glsl Asset/Shaders/functions.glsl $InputFile > Asset/Shaders/Vulkan/$1.$ext
echo "Vulkan GLSL --> SPIR-V"
External/`uname -s`/bin/glslangValidator -H -o Asset/Shaders/Vulkan/$1_$2.spv Asset/Shaders/Vulkan/$1.$ext
echo "SPIR-V --> Desktop GLSL"
External/`uname -s`/bin/SPIRV-Cross --version 400 --remove-unused-variables --no-420pack-extension --output Asset/Shaders/OpenGL/$1_$2.glsl Asset/Shaders/Vulkan/$1_$2.spv
echo "SPIR-V --> Embeded GLSL"
External/`uname -s`/bin/SPIRV-Cross --version 310 --es --remove-unused-variables --output Asset/Shaders/OpenGLES/$1_$2.glsl Asset/Shaders/Vulkan/$1_$2.spv
echo "SPIR-V --> HLSL"
External/`uname -s`/bin/SPIRV-Cross --hlsl --shader-model 52 --remove-unused-variables --output Asset/Shaders/HLSL/$1_$2.hlsl Asset/Shaders/Vulkan/$1_$2.spv
echo "SPIR-V --> Metal"
External/`uname -s`/bin/SPIRV-Cross --msl --msl-version 020101 --remove-unused-variables --output Asset/Shaders/Metal/$1_$2.metal Asset/Shaders/Vulkan/$1_$2.spv
if [ $2 = cs ]; then
External/`uname -s`/bin/SPIRV-Cross --ispc --remove-unused-variables --output Asset/Shaders/ISPC/$1.ispc Asset/Shaders/Vulkan/$1_$2.spv
fi
fi
echo "Finished"