Skip to content

Commit

Permalink
Added 3.20.0 source
Browse files Browse the repository at this point in the history
  • Loading branch information
pkraif committed Sep 11, 2023
1 parent baa55fe commit 14d95a1
Show file tree
Hide file tree
Showing 206 changed files with 9,134 additions and 1,630 deletions.
71 changes: 46 additions & 25 deletions BBMOD_GML/BBMOD.resource_order

Large diffs are not rendered by default.

41 changes: 35 additions & 6 deletions BBMOD_GML/BBMOD.yyp

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions BBMOD_GML/ExpandShaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def combine(*_args: list[dict]) -> dict:
PBR = { "X_PBR": 1 }
TERRAIN = { "X_TERRAIN": 1 }
OUTPUT_DEPTH = { "X_OUTPUT_DEPTH": 1 }
OUTPUT_GBUFFER = combine({ "X_OUTPUT_GBUFFER": 1 }, PBR)
ID = { "X_ID": 1 }

# Default shaders
Expand Down Expand Up @@ -93,8 +94,18 @@ def combine(*_args: list[dict]) -> dict:
expand_shader("BBMOD_ShTerrainUnlit", combine(TERRAIN))
expand_shader("BBMOD_ShTerrain", combine(TERRAIN, PBR))

# G-buffer
expand_shader("BBMOD_ShGBuffer", combine(OUTPUT_GBUFFER))
expand_shader("BBMOD_ShGBufferAnimated", combine(OUTPUT_GBUFFER, ANIMATED))
expand_shader("BBMOD_ShGBufferBatched", combine(OUTPUT_GBUFFER, BATCHED))
expand_shader("BBMOD_ShGBufferColor", combine(OUTPUT_GBUFFER, COLOR))
expand_shader("BBMOD_ShGBufferColorAnimated", combine(OUTPUT_GBUFFER, COLOR, ANIMATED))
expand_shader("BBMOD_ShGBufferColorBatched", combine(OUTPUT_GBUFFER, COLOR, BATCHED))
expand_shader("BBMOD_ShGBufferTerrain", combine(TERRAIN, OUTPUT_GBUFFER))

# Zombie shaders
ZOMBIE = combine({ "X_ZOMBIE": 1 }, ANIMATED)

expand_shader("ShZombie", combine(ZOMBIE, PBR))
expand_shader("ShZombieDepth", combine(ZOMBIE, OUTPUT_DEPTH))
expand_shader("ShZombieGBuffer", combine(ZOMBIE, OUTPUT_GBUFFER))
2 changes: 1 addition & 1 deletion BBMOD_GML/Xpanda
14 changes: 7 additions & 7 deletions BBMOD_GML/Xshaders/DoDirectionalLightPS.xsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma include("Material.xsh")
#if defined(X_PBR)
#if !defined(X_TERRAIN)
#pragma include("CheapSubsurface.xsh")
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP) && !defined(X_PARTICLES)
# pragma include("CheapSubsurface.xsh")
#endif
#pragma include("SpecularGGX.xsh")
#if defined(X_PBR) && !defined(X_PARTICLES)
# pragma include("SpecularGGX.xsh")
#else
#pragma include("SpecularBlinnPhong.xsh")
# pragma include("SpecularBlinnPhong.xsh")
#endif

void DoDirectionalLightPS(
Expand All @@ -22,12 +22,12 @@ void DoDirectionalLightPS(
{
vec3 L = normalize(-direction);
float NdotL = max(dot(N, L), 0.0);
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP)
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP) && !defined(X_PARTICLES)
subsurface += xCheapSubsurface(m.Subsurface, V, N, L, color);
#endif
color *= (1.0 - shadow) * NdotL;
diffuse += color;
#if defined(X_PBR)
#if defined(X_PBR) && !defined(X_PARTICLES)
specular += color * SpecularGGX(m, N, V, L);
#else
specular += color * SpecularBlinnPhong(m, N, V, L);
Expand Down
14 changes: 7 additions & 7 deletions BBMOD_GML/Xshaders/DoPointLightPS.xsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma include("Material.xsh")
#if defined(X_PBR)
#if !defined(X_TERRAIN)
#pragma include("CheapSubsurface.xsh")
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP) && !defined(X_PARTICLES)
# pragma include("CheapSubsurface.xsh")
#endif
#pragma include("SpecularGGX.xsh")
#if defined(X_PBR) && !defined(X_PARTICLES)
# pragma include("SpecularGGX.xsh")
#else
#pragma include("SpecularBlinnPhong.xsh")
# pragma include("SpecularBlinnPhong.xsh")
#endif

void DoPointLightPS(
Expand All @@ -27,12 +27,12 @@ void DoPointLightPS(
float att = clamp(1.0 - (dist / range), 0.0, 1.0);
att *= att;
float NdotL = max(dot(N, L), 0.0);
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP)
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP) && !defined(X_PARTICLES)
subsurface += xCheapSubsurface(m.Subsurface, V, N, L, color);
#endif
color *= (1.0 - shadow) * NdotL * att;
diffuse += color;
#if defined(X_PBR)
#if defined(X_PBR) && !defined(X_PARTICLES)
specular += color * SpecularGGX(m, N, V, L);
#else
specular += color * SpecularBlinnPhong(m, N, V, L);
Expand Down
14 changes: 7 additions & 7 deletions BBMOD_GML/Xshaders/DoSpotLightPS.xsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma include("Material.xsh")
#if defined(X_PBR)
#if !defined(X_TERRAIN)
#pragma include("CheapSubsurface.xsh")
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP) && !defined(X_PARTICLES)
# pragma include("CheapSubsurface.xsh")
#endif
#pragma include("SpecularGGX.xsh")
#if defined(X_PBR) && !defined(X_PARTICLES)
# pragma include("SpecularGGX.xsh")
#else
#pragma include("SpecularBlinnPhong.xsh")
# pragma include("SpecularBlinnPhong.xsh")
#endif

void DoSpotLightPS(
Expand All @@ -31,12 +31,12 @@ void DoSpotLightPS(
float theta = dot(L, normalize(-direction));
float epsilon = dcosInner - dcosOuter;
float intensity = clamp((theta - dcosOuter) / epsilon, 0.0, 1.0);
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP)
#if defined(X_PBR) && !defined(X_TERRAIN) && !defined(X_LIGHTMAP) && !defined(X_PARTICLES)
subsurface += xCheapSubsurface(m.Subsurface, V, N, L, color);
#endif
color *= (1.0 - shadow) * intensity * att;
diffuse += color;
#if defined(X_PBR)
#if defined(X_PBR) && !defined(X_PARTICLES)
specular += color * SpecularGGX(m, N, V, L);
#else
specular += color * SpecularBlinnPhong(m, N, V, L);
Expand Down
4 changes: 2 additions & 2 deletions BBMOD_GML/Xshaders/MetallicMaterial.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Material UnpackMaterial(
#if !defined(X_TERRAIN)
float isMetallic,
sampler2D texMaterial,
#if !defined(X_LIGHTMAP)
#if !defined(X_LIGHTMAP) && !defined(X_PARTICLES)
sampler2D texSubsurface,
#endif
sampler2D texEmissive,
Expand Down Expand Up @@ -95,7 +95,7 @@ Material UnpackMaterial(
m.SpecularPower = exp2(1.0 + (m.Smoothness * 10.0));
}

#if !defined(X_LIGHTMAP)
#if !defined(X_LIGHTMAP) && !defined(X_PARTICLES)
// Subsurface (color and intensity)
vec4 subsurface = texture2D(texSubsurface, uv);
m.Subsurface = vec4(xGammaToLinear(subsurface.rgb).rgb, subsurface.a);
Expand Down
46 changes: 31 additions & 15 deletions BBMOD_GML/Xshaders/PBRShader.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,32 @@ void PBRShader(Material material, float depth)
#if !defined(X_2D)
if (bbmod_ShadowmapEnablePS == 1.0)
{
vec4 shadowmapPos = v_vPosShadowmap;
shadowmapPos.xy /= shadowmapPos.w;
float shadowmapAtt = (bbmod_ShadowCasterIndex == -1.0)
? clamp((1.0 - length(shadowmapPos.xy)) / 0.1, 0.0, 1.0)
: 1.0;
shadowmapPos.xy = shadowmapPos.xy * 0.5 + 0.5;
#if defined(_YY_HLSL11_) || defined(_YY_PSSL_)
shadowmapPos.y = 1.0 - shadowmapPos.y;
#endif
shadowmapPos.z /= bbmod_ShadowmapArea;
int shadowCasterIndex = int(bbmod_ShadowCasterIndex);
bool isPoint = (shadowCasterIndex >= 0) && (bbmod_LightPunctualDataB[shadowCasterIndex * 2].x == 0.0);

shadow = ShadowMap(bbmod_Shadowmap, bbmod_ShadowmapTexel, shadowmapPos.xy, shadowmapPos.z)
* shadowmapAtt;
if (!isPoint)
{
vec4 shadowmapPos = v_vPosShadowmap;
shadowmapPos.xy /= shadowmapPos.w;
float shadowmapAtt = (bbmod_ShadowCasterIndex == -1.0)
? clamp((1.0 - length(shadowmapPos.xy)) / 0.1, 0.0, 1.0)
: 1.0;
shadowmapPos.xy = shadowmapPos.xy * 0.5 + 0.5;
#if defined(_YY_HLSL11_) || defined(_YY_PSSL_)
shadowmapPos.y = 1.0 - shadowmapPos.y;
#endif
shadowmapPos.z /= bbmod_ShadowmapArea;

shadow = ShadowMap(bbmod_Shadowmap, bbmod_ShadowmapTexel, shadowmapPos.xy, shadowmapPos.z)
* shadowmapAtt;
}
else
{
vec3 position = bbmod_LightPunctualDataA[shadowCasterIndex * 2].xyz;
vec3 lightVec = position - v_vVertex;
vec2 uv = xVec3ToOctahedronUv(-lightVec);
shadow = ShadowMap(bbmod_Shadowmap, bbmod_ShadowmapTexel, uv, (length(lightVec) - bbmod_ShadowmapNormalOffsetPS) / bbmod_ShadowmapArea);
}
}
#endif

Expand Down Expand Up @@ -130,7 +143,10 @@ void PBRShader(Material material, float depth)
// Fog
Fog(depth);

Exposure();
TonemapReinhard();
GammaCorrect();
if (bbmod_HDR == 0.0)
{
Exposure();
TonemapReinhard();
GammaCorrect();
}
}
Loading

0 comments on commit 14d95a1

Please sign in to comment.