skyrim-community-shaders icon indicating copy to clipboard operation
skyrim-community-shaders copied to clipboard

Create Common/Game.hlsli for game-specific constants

Open coderabbitai[bot] opened this issue 4 months ago • 3 comments
trafficstars

Description

We need to create package/Shaders/Common/Game.hlsli to consolidate game-specific constants and mirror the structure of src/Utils/Game.h.

Background

Currently, game-specific constants like unit conversions are scattered across different shader files:

  • GAME_UNIT_TO_CM = 1.428f (from PR #1225)
  • METRES_TO_UNITS = 70.f in Inverse Square Lighting feature

This creates duplication and inconsistency. We should follow the same architectural pattern as the C++ codebase where src/Utils/Game.h contains game-specific utilities.

Implementation

Create package/Shaders/Common/Game.hlsli with:

#ifndef __GAME_HLSLI__
#define __GAME_HLSLI__

// Game unit conversions
#define GAME_UNIT_TO_CM 1.428f   // Convert game units to centimeters  
#define METRES_TO_UNITS 70.0f    // Convert meters to game units (for lighting calculations)

#endif // __GAME_HLSLI__

Tasks

  • [x] Create package/Shaders/Common/Game.hlsli
  • [ ] Cross-reference src/Utils/Game.h to identify other constants that should be imported
  • [ ] Update existing shader files to use the centralized constants
  • [ ] Remove duplicate constant definitions from individual features

References

  • Related PR: #1225 (Hair self-shadow and Marschner model)
  • C++ reference file: src/Utils/Game.h
  • Discussion: https://github.com/doodlum/skyrim-community-shaders/pull/1225#discussion_r2179297120

This is a great beginner-friendly task that improves code organization and follows established architectural patterns!

coderabbitai[bot] avatar Jul 02 '25 07:07 coderabbitai[bot]