Skip to content

Commit e6f64f7

Browse files
committed
clean up
1 parent 6271e20 commit e6f64f7

15 files changed

Lines changed: 61 additions & 77 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"rebuild": "gulp rebuild",
1919
"watch": "gulp watch",
2020
"clean": "gulp clean",
21-
"compile:shaders": "node tools/shaders.js",
21+
"compile:shaders": "node tools/shaders.js",
2222
"package:gma": "npm run rebuild && node tools/gma.js create --input dest --output artifacts/moonpanel.gma --manifest artifacts/moonpanel.manifest.json",
2323
"package:zip": "npm run rebuild && gulp packageZip",
2424
"verify:package": "node tools/package_smoke.js --require-gma --gma artifacts/moonpanel.gma --manifest artifacts/moonpanel.manifest.json",

shadersrc/common.hlsl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
sampler TexBase : register(s0);
22
sampler Tex1 : register(s1);
3-
sampler Tex2 : register(s2);
4-
sampler Tex3 : register(s3);
5-
6-
float2 TexBaseSize : register(c4);
7-
float2 Tex1Size : register(c5);
8-
float2 Tex2Size : register(c6);
9-
float2 Tex3Size : register(c7);
103

114
const float4 Constants0 : register(c0);
125
const float4 Constants1 : register(c1);
136
const float4 Constants2 : register(c2);
14-
const float4 Constants3 : register(c3);
157

168
struct PS_INPUT
179
{
Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ float4 main(PS_INPUT input) : COLOR
66
float3 view = normalize(Constants1.xyz - input.localPosition);
77
float facing = abs(dot(normal, view));
88
float grazing = 1.0 - smoothstep(0.08, 0.55, facing);
9+
// pillars drive me mad
910
float pillar = step(0.5, Constants2.y);
1011
float radialLength = max(length(normal.xy), 0.0001);
1112
float3 pillarTangentU = float3(-normal.y / radialLength,
@@ -40,24 +41,27 @@ float4 main(PS_INPUT input) : COLOR
4041
matrixAngle * 0.2);
4142
screenColor = lerp(screenColor, float3(0.17, 0.18, 0.2),
4243
matrixAngle * 0.12);
44+
float3 modulation = input.color.rgb * Constants0.x;
45+
46+
// if backlit, return early. if not backlit, leave hope here
47+
if (Constants0.y < 0.5)
48+
return float4(screenColor * modulation, albedo.a);
4349

4450
float inverseW = 1.0 / max(abs(input.projected.w), 0.0001);
4551
float2 lightUV = float2(
4652
input.projected.x * inverseW * 0.5 + 0.5,
4753
-input.projected.y * inverseW * 0.5 + 0.5
4854
);
49-
float3 light = lerp(float3(1.0, 1.0, 1.0),
50-
saturate(tex2D(Tex1, lightUV).rgb), Constants0.w);
55+
float3 light = saturate(tex2D(Tex1, lightUV).rgb);
5156
float lightMaximum = max(light.r, max(light.g, light.b));
5257
float lightMinimum = min(light.r, min(light.g, light.b));
53-
float lightRange = lightMaximum - lightMinimum;
54-
float lightSaturation = lightRange / max(lightMaximum, 0.0001);
55-
float lightEnergy = smoothstep(0.0005, 0.004, lightMaximum);
56-
float coloredLight = smoothstep(0.12, 0.58, lightSaturation) *
57-
lightEnergy * Constants0.w;
58+
float lightSaturation = 1.0 - lightMinimum / max(lightMaximum, 0.0001);
59+
float spectralMix = smoothstep(0.12, 0.58, lightSaturation) *
60+
smoothstep(0.0005, 0.004, lightMaximum);
5861

59-
// The sampled Witness response preserves tiny non-zero lamp values and
60-
// approaches a square-root curve before its highlight shoulder.
62+
// this took an unreasonable amount of staring at witness panels
63+
// (like 580 screenshots from the game, ask me about them)
64+
// what do they mean mason
6165
float3 curvedLight = pow(light, float3(0.45, 0.45, 0.45));
6266
curvedLight = saturate(curvedLight * (2.4 - 1.4 * curvedLight));
6367

@@ -66,29 +70,27 @@ float4 main(PS_INPUT input) : COLOR
6670

6771
float sourceMaximum = max(screenColor.r,
6872
max(screenColor.g, screenColor.b));
69-
float stark = smoothstep(0.58, 0.82, sourceMaximum);
70-
float3 membership = step(sourceMaximum * 0.38, screenColor);
73+
float clueWeight = smoothstep(0.58, 0.82, sourceMaximum);
74+
float3 spectralMask = step(sourceMaximum * 0.38, screenColor);
7175
float3 normalizedColor = screenColor / max(sourceMaximum, 0.0001);
72-
float3 clueReflectance = normalizedColor * membership;
76+
float3 clueReflectance = normalizedColor * spectralMask;
7377
float3 clueLit = curvedLight * clueReflectance;
7478
float3 neutralClueLit = screenColor * neutralLight;
75-
float3 drivenClueLit = lerp(neutralClueLit, clueLit, coloredLight);
79+
float3 drivenClueLit = lerp(neutralClueLit, clueLit, spectralMix);
7680

77-
// Dark panel materials use a much straighter response than clue pixels.
81+
// clue special case doohickery
7882
float surfaceGamma = lerp(0.95, 0.62,
7983
smoothstep(0.12, 0.72, sourceMaximum));
8084
float3 surfaceLight = pow(light,
8185
float3(surfaceGamma, surfaceGamma, surfaceGamma));
8286
float3 surfaceLit = screenColor * surfaceLight;
83-
float3 lightDrivenResult = lerp(surfaceLit, drivenClueLit, stark);
84-
float3 reflected = lerp(screenColor, lightDrivenResult, Constants0.y);
85-
reflected *= input.color.rgb * Constants0.x;
87+
float3 lightDrivenResult = lerp(surfaceLit, drivenClueLit, clueWeight);
88+
float3 reflected = lightDrivenResult * modulation;
8689

87-
// HDR overbright values feed Source's normal bloom pass. Backlit panels
88-
// keep their authored emission in gamut; their glare is a separate pass.
90+
// the source bloom/hdr just turns this into soup
8991
float visibleMaximum = max(reflected.r, max(reflected.g, reflected.b));
9092
float bloom = smoothstep(0.72, 0.96, sourceMaximum) *
91-
smoothstep(0.58, 0.92, visibleMaximum) * Constants0.z * Constants0.y;
93+
smoothstep(0.58, 0.92, visibleMaximum) * Constants0.z;
9294
reflected *= 1.0 + bloom;
9395

9496
return float4(reflected, albedo.a);

src/lua/moonpanel/canvas/cl_canvas.moon

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ CANVAS.DestroyWorldMeshes = =>
131131
for meshObject in *meshes
132132
meshObject\Destroy! if meshObject.Destroy
133133
@__worldMeshes, @__worldReliefMeshes, @__worldWallMeshes = nil, nil, nil
134-
@__worldMeshesPillar, @__worldMeshBase, @__worldMeshVersion = nil, nil, nil
134+
@__worldMeshesPillar, @__worldMeshBase = nil, nil
135135

136136
CANVAS.HasBunkerRelief = => @__data and @__data.Appearance and
137137
@__data.Appearance.BunkerRelief == true
@@ -146,8 +146,7 @@ CANVAS.GetWorldMeshes = (fallback, pillar = false) =>
146146
return { fallback } unless @__clientData and @__clientData.paths and
147147
@__clientData.visibleNodes
148148
if not @__worldMeshes or @__worldMeshesPillar ~= pillar or
149-
@__worldMeshBase ~= fallback or
150-
@__worldMeshVersion ~= Moonpanel.Canvas.ReliefMeshVersion
149+
@__worldMeshBase ~= fallback
151150
@DestroyWorldMeshes!
152151
topology = reliefTopology @
153152
buildMeshes = Moonpanel.Canvas.BuildReliefMeshes
@@ -157,7 +156,6 @@ CANVAS.GetWorldMeshes = (fallback, pillar = false) =>
157156
@__worldMeshes[#@__worldMeshes + 1] = meshObject
158157
@__worldMeshesPillar = pillar
159158
@__worldMeshBase = fallback
160-
@__worldMeshVersion = Moonpanel.Canvas.ReliefMeshVersion
161159
@__worldMeshes
162160

163161
CANVAS.GetWorldWallMeshes = (fallback, pillar = false) =>

src/lua/moonpanel/canvas/cl_relief.moon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
RELIEF_CIRCLE_SEGMENTS = 48
22
RELIEF_MESH_VERTICES = 60000
3-
Moonpanel.Canvas.ReliefMeshVersion = 8
43

54
reliefPrimitives = (topology) ->
65
paths, nodes = {}, {}

src/lua/moonpanel/canvas/cl_rtpool.moon

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
MAX_RT_PAGES = 256
2-
DISPLAY_MATERIAL_VERSION = 23
32
DISPLAY_SHEAR = 0.012
43
DISPLAY_BLOOM = 1.1
54
WALL_UNLIT_BRIGHTNESS = 0.42
@@ -13,8 +12,8 @@ createDisplayMaterial = (name, texture) ->
1312
parameters =
1413
["$basetexture"]: texture\GetName!
1514
["$texture1"]: "color/black"
16-
["$pixshader"]: "moonpanel_display_v21_ps20"
17-
["$vertexshader"]: "moonpanel_display_v21_vs20"
15+
["$pixshader"]: "moonpanel_display_ps20"
16+
["$vertexshader"]: "moonpanel_display_vs20"
1817
["$vertexcolor"]: 1
1918
["$vertexalpha"]: 1
2019
["$translucent"]: 1
@@ -24,17 +23,16 @@ createDisplayMaterial = (name, texture) ->
2423
["$c0_x"]: 1
2524
["$c0_y"]: 0
2625
["$c0_z"]: DISPLAY_BLOOM
27-
["$c0_w"]: 0
2826
["$c1_x"]: 0
2927
["$c1_y"]: 0
3028
["$c1_z"]: 0
3129
["$c2_x"]: 0
3230
["$c2_y"]: 0
3331
["$c2_z"]: 0
34-
CreateMaterial "#{name} Display #{DISPLAY_MATERIAL_VERSION}",
32+
CreateMaterial "#{name} Display",
3533
"screenspace_general", parameters
3634

37-
wallMaterial = CreateMaterial "TheMP Relief Wall Metal 2", "VertexLitGeneric",
35+
wallMaterial = CreateMaterial "TheMP Relief Wall Metal", "VertexLitGeneric",
3836
["$basetexture"]: "color/white"
3937
["$color2"]: "[0.42 0.44 0.46]"
4038
["$envmap"]: "env_cubemap"
@@ -51,12 +49,12 @@ wallMaterial = CreateMaterial "TheMP Relief Wall Metal 2", "VertexLitGeneric",
5149
["$vertexcolor"]: 1
5250
Moonpanel.Canvas.ReliefWallMaterial = wallMaterial
5351

54-
wallUnlitMaterial = CreateMaterial "TheMP Relief Wall Gray 1", "UnlitGeneric",
52+
wallUnlitMaterial = CreateMaterial "TheMP Relief Wall Gray", "UnlitGeneric",
5553
["$basetexture"]: "color/white"
5654
["$model"]: 1
5755
["$vertexcolor"]: 1
5856

59-
screenGlassMaterial = CreateMaterial "TheMP Screen Glass 5", "VertexLitGeneric",
57+
screenGlassMaterial = CreateMaterial "TheMP Screen Glass", "VertexLitGeneric",
6058
["$basetexture"]: "color/white"
6159
["$color2"]: "[0.015 0.017 0.02]"
6260
["$envmap"]: "env_cubemap"
@@ -98,11 +96,9 @@ createRT = (name, worldMaterial = false) ->
9896
texture, material, displayMaterial
9997

10098
ensureDisplayMaterial = (rt) ->
101-
return rt.displayMaterial if rt.displayMaterial and
102-
rt.displayMaterialVersion == DISPLAY_MATERIAL_VERSION
99+
return rt.displayMaterial if rt.displayMaterial
103100
name = rt.texture\GetName!
104101
rt.displayMaterial = createDisplayMaterial name, rt.texture
105-
rt.displayMaterialVersion = DISPLAY_MATERIAL_VERSION
106102
rt.displayMaterial
107103

108104
initializePool = (canvas) ->
@@ -130,7 +126,6 @@ growPool = (canvas) ->
130126
:texture
131127
:material
132128
:displayMaterial
133-
displayMaterialVersion: DISPLAY_MATERIAL_VERSION
134129
}
135130

136131
canvas.__rtPageCount = target
@@ -223,15 +218,14 @@ drawWorldRT = (rt, meshObjects, power, worldLighting, strongColorResponse,
223218
strongColorResponse and 1 or 0
224219
else
225220
0
226-
displayMaterial\SetFloat "$c0_w", worldLighting and 1 or 0
227221
displayMaterial\SetFloat "$c2_x", shear and DISPLAY_SHEAR or 0
228222
displayMaterial\SetFloat "$c2_y", pillar and 1 or 0
229223
displayMaterial\SetFloat "$c2_z", matrixResponse and 1 or 0
230224
if viewPosition
231225
displayMaterial\SetFloat "$c1_x", viewPosition.x
232226
displayMaterial\SetFloat "$c1_y", viewPosition.y
233227
displayMaterial\SetFloat "$c1_z", viewPosition.z
234-
if worldLighting
228+
if worldLighting and strongColorResponse
235229
getLightTexture = Moonpanel.Canvas.GetWorldLightTexture
236230
if lightTexture = getLightTexture and getLightTexture!
237231
displayMaterial\SetTexture "$texture1", lightTexture

src/lua/moonpanel/canvas/cl_worldlighting.moon

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ target, targetWidth, targetHeight, renderedFrame = nil, 0, 0, -1
77
targetPushed = false
88
activeDescriptors = nil
99

10-
probeMaterial = CreateMaterial "TheMP World Light Probe 2", "VertexLitGeneric",
10+
probeMaterial = CreateMaterial "TheMP World Light Probe", "VertexLitGeneric",
1111
["$basetexture"]: "color/white"
1212
["$model"]: 1
1313
["$translucent"]: 1
1414
["$additive"]: 1
1515

16-
dynamicMaterial = CreateMaterial "TheMP Dynamic Light Probe 1", "UnlitGeneric",
16+
dynamicMaterial = CreateMaterial "TheMP Dynamic Light Probe", "UnlitGeneric",
1717
["$basetexture"]: "color/white"
1818
["$model"]: 1
1919
["$vertexcolor"]: 1
@@ -29,7 +29,7 @@ ensureTarget = ->
2929
CREATERENDERTARGETFLAGS_HDR, IMAGE_FORMAT_RGBA8888
3030
target
3131

32-
flatDescriptor = (entity, record, canvas) ->
32+
flatDescriptor = (entity, record) ->
3333
return unless entity.ScreenMatrix
3434
entity\SetupBones! if entity.SetupBones
3535
bone = entity\GetBoneMatrix 0
@@ -44,7 +44,7 @@ flatDescriptor = (entity, record, canvas) ->
4444
meshes: { Canvas.GetFlatScreenMesh! }
4545
}
4646

47-
pillarDescriptor = (entity, record, canvas) ->
47+
pillarDescriptor = (entity, record) ->
4848
radius = math.max 1, entity\GetPillarRadius! + PROBE_BIAS
4949
height = math.max 1, entity\GetPillarHeight!
5050
segments = if radius >= 128 then 128 elseif radius >= 48 then 64 else 32
@@ -65,10 +65,11 @@ collectDescriptors = ->
6565
continue unless IsValid entity
6666
canvas = entity\GetCanvas!
6767
continue unless canvas and canvas\CanRender!
68+
continue unless canvas\HasStrongColorResponse!
6869
descriptor = if entity.MoonpanelPillar
69-
pillarDescriptor entity, record, canvas
70+
pillarDescriptor entity, record
7071
else
71-
flatDescriptor entity, record, canvas
72+
flatDescriptor entity, record
7273
descriptors[#descriptors + 1] = descriptor if descriptor
7374
descriptors
7475

src/lua/moonpanel/sv_resources.moon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ if SERVER
1414

1515
add "materials/moonpanel"
1616
add "sound/moonpanel"
17-
resource.AddSingleFile "shaders/fxc/moonpanel_display_v21_ps20b.vcs"
18-
resource.AddSingleFile "shaders/fxc/moonpanel_display_v21_vs20.vcs"
17+
resource.AddSingleFile "shaders/fxc/moonpanel_display_ps20b.vcs"
18+
resource.AddSingleFile "shaders/fxc/moonpanel_display_vs20.vcs"
1.39 KB
Binary file not shown.

0 commit comments

Comments
 (0)