Skip to content

Commit

Permalink
Vulkan: added entity-color optimization for single-stage shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
ec- committed Sep 24, 2023
1 parent 2e4175c commit 4a84733
Show file tree
Hide file tree
Showing 12 changed files with 3,765 additions and 3,115 deletions.
16 changes: 16 additions & 0 deletions code/renderervk/shaders/compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ for %%f in (*.frag) do (
"%cl%" -S frag -V -o "%tmpf%" gen_frag.tmpl -DUSE_FIXED_COLOR -DUSE_ATEST -DUSE_FOG
"%bh%" "%tmpf%" %outf% frag_tx0_fixed_fog

@rem single-texture fragment, entity color

"%cl%" -S frag -V -o "%tmpf%" gen_frag.tmpl -DUSE_ENT_COLOR -DUSE_ATEST
"%bh%" "%tmpf%" %outf% frag_tx0_ent

"%cl%" -S frag -V -o "%tmpf%" gen_frag.tmpl -DUSE_ENT_COLOR -DUSE_ATEST -DUSE_FOG
"%bh%" "%tmpf%" %outf% frag_tx0_ent_fog

@rem single-texture fragment, depth-fragment

"%cl%" -S frag -V -o "%tmpf%" gen_frag.tmpl -DUSE_CLX_IDENT -DUSE_ATEST -DUSE_DF
Expand Down Expand Up @@ -227,6 +235,14 @@ for %%f in (*.frag) do (
"%cl%" -S frag -V -o "%tmpf%" gen_frag.tmpl -DUSE_FIXED_COLOR -DUSE_TX1 -DUSE_FOG
"%bh%" "%tmpf%" %outf% frag_tx1_fixed_fog

@rem double-texture fragment, entity colors

@rem "%cl%" -S frag -V -o "%tmpf%" gen_frag.tmpl -DUSE_ENT_COLOR -DUSE_TX1
@rem "%bh%" "%tmpf%" %outf% frag_tx1_ent

@rem "%cl%" -S frag -V -o "%tmpf%" gen_frag.tmpl -DUSE_ENT_COLOR -DUSE_TX1 -DUSE_FOG
@rem "%bh%" "%tmpf%" %outf% frag_tx1_ent_fog

@rem double-texture fragment, non-identical colors

"%cl%" -S frag -V -o "%tmpf%" gen_frag.tmpl -DUSE_CL1 -DUSE_TX1
Expand Down
24 changes: 12 additions & 12 deletions code/renderervk/shaders/fog.frag
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#version 450

layout(set = 1, binding = 0) uniform UBO {
// VERTEX
vec4 eyePos;
vec4 lightPos;
// VERTEX-FOG
vec4 fogDistanceVector;
vec4 fogDepthVector;
vec4 fogEyeT;
// FRAGMENT
vec4 lightColor;
vec4 fogColor;
// linear dynamic light
vec4 lightVector;
// light/env parameters:
vec4 eyePos; // vertex
vec4 lightPos; // vertex: light origin
vec4 lightColor; // fragment: rgb + 1/(r*r)
vec4 lightVector; // fragment: linear dynamic light
//#ifdef USE_FOG
// fog parameters:
vec4 fogDistanceVector; // vertex
vec4 fogDepthVector; // vertex
vec4 fogEyeT; // vertex
vec4 fogColor; // fragment
//#endif
};

layout(set = 3, binding = 0) uniform sampler2D fog_texture;
Expand Down
24 changes: 12 additions & 12 deletions code/renderervk/shaders/fog.vert
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ layout(push_constant) uniform Transform {
};

layout(set = 1, binding = 0) uniform UBO {
// VERTEX
vec4 eyePos;
vec4 lightPos;
// VERTEX-FOG
vec4 fogDistanceVector;
vec4 fogDepthVector;
vec4 fogEyeT;
// FRAGMENT
vec4 lightColor;
vec4 fogColor;
// linear dynamic light
vec4 lightVector;
// light/env parameters:
vec4 eyePos; // vertex
vec4 lightPos; // vertex: light origin
vec4 lightColor; // fragment: rgb + 1/(r*r)
vec4 lightVector; // fragment: linear dynamic light
//#ifdef USE_FOG
// fog parameters:
vec4 fogDistanceVector; // vertex
vec4 fogDepthVector; // vertex
vec4 fogEyeT; // vertex
vec4 fogColor; // fragment
//#endif
};

layout(location = 0) in vec3 in_position;
Expand Down
Loading

0 comments on commit 4a84733

Please sign in to comment.