# archiegoldmill/nfsmw_sunset architecture

> Architecture diagram of the GitHub repository archiegoldmill/nfsmw_sunset, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/archiegoldmill/nfsmw_sunset
- Repository: https://github.com/archiegoldmill/nfsmw_sunset

## Overview

#### Purpose and Deployment

SunSet is a native graphics-mod DLL for *Need for Speed: Most Wanted*. It injects into the game, replaces/extends rendering behavior, and ships runtime assets/configuration as a mod package. The distributable layout is under `mod/SunSet`, including the ASI module, shader binaries, texture-pack metadata, and editable YAML settings.

Primary native entry point: `SunSet/dllmain.cpp`. Injection and host-process integration are centered on `SunSet/Injector/injector.hpp` and `SunSet/Hooks.h`.

#### Host Integration and Game Model Access

The DLL hooks game rendering and gameplay-facing structures rather than owning an application loop. Internal wrappers/model definitions expose game entities, views, effects, and rendering connections:

- `SunSet/Game.h`
- `SunSet/eModel.h`
- `SunSet/eView.h`

Vehicle and world render paths are represented separately through `SunSet/VehicleRenderConn.h`, `SunSet/SmackableRenderConn.h`, and `SunSet/WorldModel.h`. This is the principal boundary between reverse-engineered game state and SunSet-managed rendering logic.

#### Rendering Pipeline and Shader Replacement

Rendering enhancements are organized as render stages and material/shader management. The pipeline includes depth prepass, lighting, reflection, and screen-space/post-processing operations:

- `SunSet/DepthPrePass.h`
- `SunSet/UpdateMaterials.h`
- `SunSet/PostEffects.h`

Shader source lives in `fx/*.fx`, with key effects such as `fx/world.fx`, `fx/car.fx`, `fx/lighting.fx`, `fx/prepass.fx`, and `fx/spotlights.fx`. Compiled shader resources are deployed under `mod/SunSet/shaders`. `SunSet/ShaderLoader.h` loads these runtime shader assets.

#### Lighting, Time, and Weather Systems

SunSet derives changing scene appearance from coordinated environmental systems. Day/night progression and exposure feed dynamic lighting and atmosphere; weather drives rain-specific rendering and related effects.

- `SunSet/TimeOfDay.h`, `SunSet/Exposure.h`, `SunSet/Weather.h`
- `SunSet/DynamicLights.h`, `SunSet/WorldLights.h`, `SunSet/Spotlight.h`
- `SunSet/Rain.h`, `SunSet/HeavyRain.h`, `SunSet/CarRain.h` is not present; car rain shader behavior is instead in `fx/car_rain.fx`.

Runtime tuning is externalized in `mod/SunSet/scripts/SunSetData/Weather.yml`, `SpotLights.yml`, and `Flares.yml`.

#### Vehicles, World Geometry, and Custom Assets

Vehicle-specific rendering supports car materials, lights, brake glow, vinyl masking, and reflection-oriented passes. World handling includes culling, custom meshes, texture replacement, and prelit/normal-map variants.

- `SunSet/CarRenderInfo.h`, `SunSet/CarLights.h`, `SunSet/CarBrakeGlow.h`
- `SunSet/CustomMeshes.h`, `SunSet/TextureInfo.h`, `SunSet/PrelitTextures.h`
- `SunSet/GridCuller.h`, `SunSet/GrandSceneryCullInfo.h`

Data-driven mesh and texture mappings reside in `mod/SunSet/scripts/SunSetData/Meshes.yml` and `Textures.yml`; texture-pack registration is `mod/SunSet/TexturePacks/SunSet/meta.json`.

#### Post-Processing and Render Resources

Screen effects include bloom, motion blur, god rays, fog/HDR-oriented shaders, reflections, and render-target/resource management:

- `SunSet/Bloom.h`, `SunSet/MotionBlur.h`, `SunSet/GodRays.h`
- `SunSet/Reflection.h`, `SunSet/RenderTarget.h`, `SunSet/DirectResources.h`

These stages depend on DirectX 9 integration, indicated by bundled ImGui DX9 bindings in `SunSet/imgui/imgui_impl_dx9.cpp`. DXVK is an optional external compatibility/runtime layer for deployment.

#### Configuration UI and Build Toolchain

An in-game ImGui UI exposes configuration/editor screens for core subsystems:

- `SunSet/UI.h`, `SunSet/UIEditor.h`, `SunSet/UIWeather.h`
- `SunSet/UISpotlights.h`, `SunSet/UITextures.h`, `SunSet/UICustomMeshes.h`

`SunSet/SunSet.vcxproj` builds the C++ DLL; dependencies are declared through `SunSet/vcpkg.json`. Shader compilation is a separate C# utility at `ShaderCompiler/Program.cs`, producing deployable effects from the `fx` project/assets. Runtime defaults are packaged in `mod/SunSet/scripts/SunSetData/Config.yml`.

Main entry points: [`SunSet/DepthPrePass.h`](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/DepthPrePass.h) (Render Pipeline), [`SunSet/dllmain.cpp`](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/dllmain.cpp) (SunSet DLL), [`mod/SunSet/scripts/SunSetData/Config.yml`](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/mod/SunSet/scripts/SunSetData/Config.yml) (Runtime Data), [`mod/SunSet`](https://github.com/archiegoldmill/nfsmw_sunset/tree/master/mod/SunSet) (Mod Package)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host Integration"]
  node_dll{{"SunSet DLL<br/>native module<br/>[dllmain.cpp]"}}
  node_injector_hooks["Injector &amp; Hooks<br/>host hooks<br/>[injector.hpp]"]
  node_game_model["Game Model Access<br/>game wrappers<br/>[Game.h]"]
  node_vehicle_world["Vehicle &amp; World Paths<br/>render connections"]
end

subgraph group_render["Rendering Pipeline"]
  node_render_pipeline["Render Pipeline<br/>render stages<br/>[DepthPrePass.h]"]
  node_shader_loader["Shader Loader<br/>shader runtime<br/>[ShaderLoader.h]"]
  node_shader_sources["Effect Sources<br/>HLSL effects<br/>[world.fx]"]
  node_gpu_resources["DX9 Resources<br/>render resources<br/>[RenderTarget.h]"]
  node_post_processing["Screen Effects<br/>post processing<br/>[Bloom.h]"]
  node_vehicle_rendering["Vehicle Rendering<br/>vehicle materials<br/>[CarRenderInfo.h]"]
  node_world_assets["World Geometry &amp; Textures<br/>world assets<br/>[CustomMeshes.h]"]
end

subgraph group_environment["Environment"]
  node_time_weather["Time, Exposure &amp; Weather<br/>environment state<br/>[TimeOfDay.h]"]
  node_dynamic_lighting["Dynamic Lighting<br/>lighting system<br/>[DynamicLights.h]"]
  node_rain["Rain Rendering<br/>weather rendering<br/>[Rain.h]"]
end

subgraph group_content["Content &amp; Tuning"]
  node_runtime_data["Runtime Data<br/>YAML mappings<br/>[Config.yml]"]
  node_texture_pack["Texture Pack Metadata<br/>texture registration<br/>[meta.json]"]
  node_mod_package["Mod Package<br/>deployment layout"]
end

subgraph group_tooling["Build &amp; UI"]
  node_shader_compiler["Shader Compiler<br/>C&#35; build utility<br/>[Program.cs]"]
  node_native_build["Native Build<br/>Visual C++ project<br/>[SunSet.vcxproj]"]
  node_in_game_ui["In-Game Editor UI<br/>ImGui UI<br/>[UI.h]"]
end

node_dll -->|"initializes"| node_injector_hooks
node_injector_hooks -->|"hooks and reads"| node_game_model
node_game_model -->|"supplies state to"| node_vehicle_world
node_vehicle_world -->|"drives"| node_vehicle_rendering
node_vehicle_world -->|"drives"| node_world_assets
node_dll -->|"executes"| node_render_pipeline
node_render_pipeline -->|"uses"| node_shader_loader
node_shader_loader -->|"loads shaders from"| node_mod_package
node_render_pipeline -->|"uses"| node_gpu_resources
node_render_pipeline -->|"runs"| node_post_processing
node_time_weather -->|"controls"| node_dynamic_lighting
node_time_weather -->|"controls"| node_rain
node_dynamic_lighting -->|"contributes lighting"| node_render_pipeline
node_rain -->|"contributes effects"| node_render_pipeline
node_vehicle_rendering -->|"submits passes"| node_render_pipeline
node_world_assets -->|"submits geometry"| node_render_pipeline
node_runtime_data -->|"tunes"| node_time_weather
node_runtime_data -->|"tunes"| node_dynamic_lighting
node_runtime_data -->|"maps assets"| node_world_assets
node_texture_pack -->|"included in"| node_mod_package
node_shader_sources -->|"compiled by"| node_shader_compiler
node_shader_compiler -->|"emits shader binaries"| node_mod_package
node_native_build -->|"builds"| node_dll
node_dll -->|"packaged as ASI"| node_mod_package
node_in_game_ui -->|"edits"| node_runtime_data

click node_dll "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/dllmain.cpp"
click node_injector_hooks "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/Injector/injector.hpp"
click node_game_model "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/Game.h"
click node_vehicle_world "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/VehicleRenderConn.h"
click node_render_pipeline "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/DepthPrePass.h"
click node_shader_loader "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/ShaderLoader.h"
click node_shader_sources "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/fx/world.fx"
click node_gpu_resources "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/RenderTarget.h"
click node_post_processing "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/Bloom.h"
click node_time_weather "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/TimeOfDay.h"
click node_dynamic_lighting "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/DynamicLights.h"
click node_rain "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/Rain.h"
click node_vehicle_rendering "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/CarRenderInfo.h"
click node_world_assets "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/CustomMeshes.h"
click node_runtime_data "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/mod/SunSet/scripts/SunSetData/Config.yml"
click node_texture_pack "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/mod/SunSet/TexturePacks/SunSet/meta.json"
click node_mod_package "https://github.com/archiegoldmill/nfsmw_sunset/tree/master/mod/SunSet"
click node_shader_compiler "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/ShaderCompiler/Program.cs"
click node_native_build "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/SunSet.vcxproj"
click node_in_game_ui "https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/UI.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dll,node_injector_hooks,node_game_model,node_vehicle_world toneBlue
class node_render_pipeline,node_shader_loader,node_shader_sources,node_gpu_resources,node_post_processing,node_vehicle_rendering,node_world_assets toneAmber
class node_time_weather,node_dynamic_lighting,node_rain toneMint
class node_runtime_data,node_texture_pack,node_mod_package toneRose
class node_shader_compiler,node_native_build,node_in_game_ui toneIndigo
```

## Components

### Host Integration

Injected DLL and reverse-engineered game boundary.

- [SunSet DLL](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/dllmain.cpp): native module · Injected graphics mod loaded by the game. · `SunSet/dllmain.cpp`
- [Injector & Hooks](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/Injector/injector.hpp): host hooks · Connects the DLL to game rendering and host behavior. · `SunSet/Injector/injector.hpp`
- [Game Model Access](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/Game.h): game wrappers · Exposes game entities, views, effects, and render connections. · `SunSet/Game.h`
- [Vehicle & World Paths](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/VehicleRenderConn.h): render connections · Separates vehicle and world render-state handling. · `SunSet/VehicleRenderConn.h`

### Rendering Pipeline

Render stages, shaders, and GPU resources.

- [Render Pipeline](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/DepthPrePass.h): render stages · Runs depth prepass, material updates, and post effects. · `SunSet/DepthPrePass.h`
- [Shader Loader](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/ShaderLoader.h): shader runtime · Loads packaged compiled shader assets. · `SunSet/ShaderLoader.h`
- [Effect Sources](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/fx/world.fx): HLSL effects · World, car, lighting, prepass, spotlight, and rain shader definitions. · `fx/world.fx`
- [DX9 Resources](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/RenderTarget.h): render resources · Owns render targets and DirectX resource integration. · `SunSet/RenderTarget.h`
- [Screen Effects](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/Bloom.h): post processing · Bloom, motion blur, god rays, reflections, and fog/HDR effects. · `SunSet/Bloom.h`
- [Vehicle Rendering](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/CarRenderInfo.h): vehicle materials · Handles car materials, lights, brake glow, and reflections. · `SunSet/CarRenderInfo.h`
- [World Geometry & Textures](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/CustomMeshes.h): world assets · Handles culling, custom meshes, texture replacement, and prelit textures. · `SunSet/CustomMeshes.h`

### Environment

Time, weather, and lighting systems.

- [Time, Exposure & Weather](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/TimeOfDay.h): environment state · Drives day/night appearance, exposure, and rain conditions. · `SunSet/TimeOfDay.h`
- [Dynamic Lighting](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/DynamicLights.h): lighting system · Applies world lights, dynamic lights, and spotlights. · `SunSet/DynamicLights.h`
- [Rain Rendering](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/Rain.h): weather rendering · Renders rain and heavy-rain behavior. · `SunSet/Rain.h`

### Content & Tuning

Data-driven assets and editable runtime settings.

- [Runtime Data](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/mod/SunSet/scripts/SunSetData/Config.yml): YAML mappings · Weather, lights, flares, mesh, texture, and default configuration data. · `mod/SunSet/scripts/SunSetData/Config.yml`
- [Texture Pack Metadata](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/mod/SunSet/TexturePacks/SunSet/meta.json): texture registration · Registers the SunSet texture pack for deployment. · `mod/SunSet/TexturePacks/SunSet/meta.json`
- [Mod Package](https://github.com/archiegoldmill/nfsmw_sunset/tree/master/mod/SunSet): deployment layout · Ships the ASI module, compiled shaders, texture metadata, and settings. · `mod/SunSet`

### Build & UI

Build-time shader compilation and in-game editing.

- [Shader Compiler](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/ShaderCompiler/Program.cs): C# build utility · Compiles effect sources into deployable shader binaries. · `ShaderCompiler/Program.cs`
- [Native Build](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/SunSet.vcxproj): Visual C++ project · Builds the injected SunSet DLL. · `SunSet/SunSet.vcxproj`
- [In-Game Editor UI](https://github.com/archiegoldmill/nfsmw_sunset/blob/master/SunSet/UI.h): ImGui UI · Edits core configuration, weather, spotlights, textures, and meshes. · `SunSet/UI.h`

## Connections

- SunSet DLL → Injector & Hooks: initializes
- Injector & Hooks → Game Model Access: hooks and reads
- Game Model Access → Vehicle & World Paths: supplies state to
- Vehicle & World Paths → Vehicle Rendering: drives
- Vehicle & World Paths → World Geometry & Textures: drives
- SunSet DLL → Render Pipeline: executes
- Render Pipeline → Shader Loader: uses
- Shader Loader → Mod Package: loads shaders from
- Render Pipeline → DX9 Resources: uses
- Render Pipeline → Screen Effects: runs
- Time, Exposure & Weather → Dynamic Lighting: controls
- Time, Exposure & Weather → Rain Rendering: controls
- Dynamic Lighting → Render Pipeline: contributes lighting
- Rain Rendering → Render Pipeline: contributes effects
- Vehicle Rendering → Render Pipeline: submits passes
- World Geometry & Textures → Render Pipeline: submits geometry
- Runtime Data → Time, Exposure & Weather: tunes
- Runtime Data → Dynamic Lighting: tunes
- Runtime Data → World Geometry & Textures: maps assets
- Texture Pack Metadata → Mod Package: included in
- Effect Sources → Shader Compiler: compiled by
- Shader Compiler → Mod Package: emits shader binaries
- Native Build → SunSet DLL: builds
- SunSet DLL → Mod Package: packaged as ASI
- In-Game Editor UI → Runtime Data: edits
