Skip to content

chescos/csgo-fade-percentage-calculator

Repository files navigation

CS2 Fade Percentage Calculator

NPM Version NPM Bundle Size NPM Downloads GitHub License GitHub Test Workflow Status GitHub Build Workflow Status

Calculate the Fade percentage value of a CS2 skin based on a given seed value. Supporting all Fade skins (except for gloves), Amber Fade skins, and Acid Fade skins. Easily convert every paint seed (also called pattern index) into a fade percentage value, or get a full list of all paint seeds and the corresponding fade percentages.

🚀 Installation

In order to install the latest package version from NPM, simply run:

npm install csgo-fade-percentage-calculator

🛠 Usage

There are three modules which all share the same four methods as shown in the examples below:

const {
  FadeCalculator,
  AmberFadeCalculator,
  AcidFadeCalculator,
} = require('csgo-fade-percentage-calculator');

// Get a list of all Fade percentages for all available weapons.
const allFadePercentages = FadeCalculator.getAllFadePercentages();

// Get a list of Amber Fade percentages for the P2000.
const p2000AmberFadePercentages = AmberFadeCalculator.getFadePercentages('P2000');

// Get the Acid Fade percentage for the SSG 08 and the seed 123.
const ssgAcidFadePercentage = AcidFadeCalculator.getFadePercentage('SSG 08', 123);

// Get all supported Fade weapons.
const supportedWeapons = FadeCalculator.getSupportedWeapons();

📜 How It Works

Each CS2 weapon skin has a random paint seed value between 0 and 1000. This paint seed value, sometimes also called pattern index, determines the positioning of the pattern on the gun. Specifically, the paint seed determines the X offset, Y offset, and rotation value for the pattern position. Those three values can be calculated using an algorithm that has been open-sourced by Valve.

Luckily, most Fade skins have the same X and Y offsets, and only the rotation value changes with each paint seed. This package simply converts paint seeds to rotation values and then assigns each rotation value a fade percentage between 80% and 100%, where the best rotation value is a 100% Fade, and the worst rotation value is an 80% Fade.

The whole process just involves simple math, and it is superior to alternative methods such as image pixel color analysis for various reasons:

  • The resulting Fade percentage values are much more accurate
  • The methodology can be easily verified and reproduced
  • The algorithm is simple and fast

🌎 Platform Support

Most platforms that support fade percentages use the open-source algorithm implemented by this package to generate their fade values. The sites below all share the same fade percentage values, which can also be generated by this package:

Other sites are currently known to use their own algorithms, probably based on image analysis. These sites come to different conclusions about which paint seed corresponds to which fade value, as pixel color analysis is not very accurate for determining a fade value:

💻 Other Programming Languages

Are you not using Node, JavaScript, or TypeScript for your project? We have a pre-generated JSON file for you that contains the fade percentages of all supported weapons. You can download it with any programming language into your project to store and process the values there.

Alternatively, feel free to check out the source code of this library and port it into your preferred language.

❓ Frequently Asked Questions

How accurate are the generated fade percentages?

The generated fade percentage values are basically as accurate as they can get. Fade percentages don't really exist in CS2 itself, it's a community-driven value that has been historically computed through image analysis of screenshots. However, this method is not very accurate as it depends on many presumptions of the used algorithm. This library just reverses the algorithm that Valve uses internally to apply the pattern on the weapon, and our only presumption is a fade percentage range between 80% and 100%, with 80% being the worst and 100% being the best value.

Why do some websites display different fade percentages?

Some websites may use different algorithms to calculate fade percentages, often based on pixel color analysis of screenshot images. Those algorithms can come to very different conclusions about what seed value corresponds to which fade percentage. Hopefully, the community will shift from image analysis to the open-source algorithm used by this library, creating a stronger consensus.

Why are gloves not supported?

Glove skins are handled differently in CS2. The method used by this library to compute fade values does not work for glove skins, because their patterns shift more unpredictably, similar to Case Hardened skins.

⭐ Credits

A big thanks goes to Step7750, the work on this library was inspired by his research about CS2 paint seeds. He also implemented Valve's uniform random number generator in Go, which was ported to TypeScript for this project.