How archiegoldmill/nfsmw_sunset works
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: DepthPrePass.h Render Pipeline · dllmain.cpp SunSet DLL · Config.yml Runtime Data · SunSet Mod Package
Components 20
Host Integration
Injected DLL and reverse-engineered game boundary.
- SunSet DLL · Injected graphics mod loaded by the game.
SunSet/dllmain.cpp - Injector & Hooks · Connects the DLL to game rendering and host behavior.
SunSet/Injector/injector.hpp - Game Model Access · Exposes game entities, views, effects, and render connections.
SunSet/Game.h - Vehicle & World Paths · Separates vehicle and world render-state handling.
SunSet/VehicleRenderConn.h
Rendering Pipeline
Render stages, shaders, and GPU resources.
- Render Pipeline · Runs depth prepass, material updates, and post effects.
SunSet/DepthPrePass.h - Shader Loader · Loads packaged compiled shader assets.
SunSet/ShaderLoader.h - Effect Sources · World, car, lighting, prepass, spotlight, and rain shader definitions.
fx/world.fx - DX9 Resources · Owns render targets and DirectX resource integration.
SunSet/RenderTarget.h - Screen Effects · Bloom, motion blur, god rays, reflections, and fog/HDR effects.
SunSet/Bloom.h - Vehicle Rendering · Handles car materials, lights, brake glow, and reflections.
SunSet/CarRenderInfo.h - World Geometry & Textures · Handles culling, custom meshes, texture replacement, and prelit textures.
SunSet/CustomMeshes.h
Environment
Time, weather, and lighting systems.
- Time, Exposure & Weather · Drives day/night appearance, exposure, and rain conditions.
SunSet/TimeOfDay.h - Dynamic Lighting · Applies world lights, dynamic lights, and spotlights.
SunSet/DynamicLights.h - Rain Rendering · Renders rain and heavy-rain behavior.
SunSet/Rain.h
Content & Tuning
Data-driven assets and editable runtime settings.
- Runtime Data · Weather, lights, flares, mesh, texture, and default configuration data.
mod/SunSet/scripts/SunSetData/Config.yml - Texture Pack Metadata · Registers the SunSet texture pack for deployment.
mod/SunSet/TexturePacks/SunSet/meta.json - Mod Package · Ships the ASI module, compiled shaders, texture metadata, and settings.
mod/SunSet
Build & UI
Build-time shader compilation and in-game editing.
- Shader Compiler · Compiles effect sources into deployable shader binaries.
ShaderCompiler/Program.cs - Native Build · Builds the injected SunSet DLL.
SunSet/SunSet.vcxproj - In-Game Editor UI · Edits core configuration, weather, spotlights, textures, and meshes.
SunSet/UI.h
Connections 25
- 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