Giter Site home page Giter Site logo

nordlichts / custom-shaders-redalert3 Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 0.0 15.77 MB

Physical-Based-Render graphic improvements for this old dx9 game CnC Red Alert 3

License: MIT License

HLSL 99.63% Python 0.37%
hlsl shader gamemodding d3d9 directx

custom-shaders-redalert3's Introduction

custom-shaders-RedAlert3

Graphic improvements for this old dx9 game "Command Conquer Red Alert 3 " (2008) , based on hlsl code published in CnC3 Tiberium Wars MODSDK by Electronic Arts.

also with a little help from https://github.com/lanyizi/DXDecompiler (could be experimental)

the main project here is PBR (physical based render) shader. It should be used to replace Objects and Buildings shaders in the game (after compile! Don't try to let the game itself compile it, its compiler is too outdated. Use FXC.EXE from legacy microsoft direct x sdk. BUT 3dsmax requires uncompiled version)

Compiled+packed game-ready patch, download it here: (updated on April 22) https://www.moddb.com/mods/psysonic-omega/downloads/pbr-shader-patch-v14

ObjectsWorkflow series is my latest and most complete implementation, with the ability of previewing near in-game result in 3dsmax. alt text you may notice, as the reflectivity increase, diffuse lights decreases according to law of conservation of energy. Fresnel effect (darker on verticle view angle) also becomes more obvious, and disappear again once the material is considered metallic. Metal is not supposed to cause diffuse reflection or fresnel effect either, all energy goes to specular. if you want to edit the preview, such as adding or neglecting an in-game feature in 3dsmax, caution: alt text

ObjectWorkflow_Compatile.fx is a variant specially fine-tuned to match the original Red Alert 3 textures and artstyle while still maintaining all BRDF. NO texture edit is needed to use them! alt text Left=original game shader, Right=new shader. As you may notice, the shadow's edge is also smoothed and anti-aliased. alt text

the original game used a very lasy way to shade the lights received from nearby point light sources (usually flame or laser VFX) which is a waste for such a nice feature. I implemented BRDF for all my point lights (the function was originally written for directional sunlight, but turns out even better for point light sources with correct decay multiplier) alt text dark environment with single point light. You can see the "mirror image" is blurred according to different surface roughness. alt text specular reflection caused by a weapon vfx, it makes the metallic surface seem more metallic alt text up to 8 nearby point lights can be received by a single drawcall / object per frame alt text Buildings with windows is a nice sample to observe. Notice that Fresnel effect and normal map also play big roles here.

as for the specular in BRDF (bi-directional reflection distribution function) i used a tricky approach: instead of calculating Half-way vector for every light source, I calculate the single Reflection vector based on View vector (yes the same vector that you use to sample skybox cube texture for envirnmental reflection) And compare the angle between it and other Light vectors. In fact i don't even compare the angles, but its Cosine, its function curve is pretty close to parabel. This can save a lot of computation power especially as point light count increases. alt text Fresnel effect is also more obvious, though less realistic compared to the popular schlick approximation, i like the artstyle more. alt text

====(side project)====

I accidentially read across this input semantic for pixel shader and realized, by using screen-space position as texture sampling coordinate, i can show the "protal to cosmos" visual effects, inspired by the "blade of no thought" vfx from genshin impact. alt text this shader have one for objects and one for laser mesh. Named "starry" in this repo alt text alt text remember to register the starry sky texture in SCRAPEO so it can have standard annotation string address.

====(out dated contents below)====

The older PBR implementaions have three variants: "myPBR" for original game and most mods, "myPBR_g2yw" for Generals 2 mod, "myPBR_genevo" for Generals Evolution mod. "3dsmax only" is for you to export the needed parameters in 3dsmax when making an w3x model file. It cannot be used in-game. The preview is crude (for now) you have to guess its in-game visuals. I'll implement a better preview in 3dsmax later.

Each has 10 (maybe more) global variables to adjust, you can tweak them to get the style fitting for your skirmish map. They all support up to 8 point lights (per mesh) all using microfacet BRDF to shade. You can see how the VFX cast lights on windows are way different from original game.

I will upload a few preview screenshots later.

terrain: smooth shadow, RA2 style fog of war (register conflict occured, need further fixing)

laserhc: laser now glow as team color, the "color emissive" in your VFX code can only control the brightness of this laser, not its color. However the laser texture's color can still influence final color, this color will be mixed with team color.

custom-shaders-redalert3's People

Contributors

nordlichts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.