LUX

From Valve Developer Community
(Redirected from Lux)
Jump to: navigation, search
English (en)中文 (zh)Translate (Translate)
LUX
Development.png In Alpha development
Wiki
TypeModification
DevelopersShiroDkxtro2
EngineSource Source
PlatformsPC PC
Based onSource 2013 Source 2013
 
GitHub
Join Discord server

LUX LUX is a mod specifically made and developed for use in Source 2013 Singleplayer Source 2013 Singleplayer and Source 2013 Multiplayer Source 2013 Multiplayer.
The Project is to entirely rewrite all existing "SDK_" Shaders, that come with the SDK and all those available in Mapbase Mapbase.

Goals

Overhaul/Clean 🖿materialsystem\stdshaders\ Folder
Implementing LUX LUX Shaders would entail replacing the existing 🖿stdshaders\ folder. LUX LUX Shaders should be able to do everything SDK_ Shaders in Source 2013 and Mapbase can do.
SDK_ Shaders will fall back to LUX_ Shaders, that way LUX LUX can easily be used on Mapbase Mapbase mods without much work.
Many .h, .cpp, .fxc files have been rewritten


Drastically decrease compile times for all Shaders
With LUX LUX, compiling the entirety of LUX_LightMappedGeneric takes around 30 seconds on 4 cores @4.1GHz


SM3.0 Shaders Only
Linux Linux and macOS macOS are not officially supported. Users of said systems will have to either patch togl to work with SM3.0 or use DxVK.
Note.pngNote:


More Documentation for Shaders, their parameters, how they work and any possible caveats
You might have noticed Articles like $lightwarptexture, $detail, UnlitTwoTexture and $envmapmask getting major updates with new information about caveats and bugs.
This was a direct result of LUX LUX development, although the focus was mainly on Source 2013 and Alien Swarm as their code is publicly available.


Implementing features that aren't available in Source 2013 Source 2013
See also:  Planned Features. This includes old features such as $selfillumtexture and newer features like $phongalbedoboost(only in Counter-Strike: Global Offensive).


Fixing most Parameter bugs and other caveats


Easy way of disabling features
A custom Pre-Processor program has been made, allowing Mods that don't require specific features to easily disable them and further increase Shader compilation speed.


Mapbase Mapbase compatibility
Replacing SDK_ Shaders in SDK mods, SDK2013CE or Mapbase mods should be as simple as replacing the 🖿stdshaders\ Folder, assuming that no custom shaders were added. If they were added, developers may need to add them back or recreate them.


Planned Features

This is a list of new features that are being implemented / will be implemented from newer branches such as:

The code may be modified for simplification or if it needs a overhaul

Icon-Important.pngImportant:LUX LUX does not use any leaked code. Features like $phongalbedoboost(only in Counter-Strike: Global Offensive) are not rocket science and easily be recreated.
Warning.pngWarning:For more complicated features, there might be visual disparity when compared to official implementations.

Mapbase Mapbase compatibility

Icon-Important.pngImportant:The parameters will be the same as Mapbase Mapbase, meaning that Mapbase's compilers can be used
Confirm:Is the Mapbase Mapbase implementation ported from Alien Swarm Alien Swarm?


New features

  • In Source 2013 Multiplayer Source 2013 Multiplayer, models utilizing Model Lightmapping can use $bumpmap. Additionally, all Model shaders will be able to utilize this feature, unless they have $phong.
    • The Lightmap does not do bumped-lighting using the bumpmap. Only named lights/projected textures will be able to do so.
    • Lightmapped models will not be able to receive $phong. This is not planned at the moment but should be possible for named lights/projected textures!
  • In Source 2013 Multiplayer Models can utilize Lightmap UV's.
    • The way this is currently implemented requires a custom-written tool, two SMDs (one with a lightmap uv), and also has a lot of precision loss for the Lightmap UVs. Additionally, this requires a custom compiler!
      Todo: Investigate Source 2007 Source 2007 code, supposedly the Studiomdl code is there. Maybe it can be packed via Blendweights or the precision loss might be decreased.

Features ported/recreated

  • $selfillumtexture Deprecated since Source 2007 Source 2007
    • Yes, there is a use for this! $detailblendmode 5 is commonly used for glowing textures. This parameter allows for not wasting your $detail. Additionally no $emissiveblend is required.
See also:  PBR Shaders in the community commonly have a $emissiontexture parameter that does EXACTLY what $selfillumtexture does in LUX LUX.

Icon-Important.pngImportant:Features are dependant on types:
  • On brushes, this will use the Lightmap
  • On models with $bumpmap, this will use Bumped lighting.
  • On models without $bumpmap, this will use Vertex Lighting.
  • In Source 2013 Multiplayer Models utilizing Model Lightmapping, this will use the Lightmap, regardless of if $bumpmap is used.

Features that won't be ported/recreated/revived

  • $basealphaenvmapmaskminmaxexp from Alien Swarm Alien Swarm - This parameter is not yet documented on the VDC, it is also unclear what exactly it does...
  • $EnvMapLightScaleMinMax from Counter-Strike: Global Offensive Counter-Strike: Global Offensive
  • $envmapsphere and related - These features have been removed since Alien Swarm Alien Swarm and is obsolete.
    • This is very easy to re-implement. The 7th face of a cubemap is still built in Source 2013 Source 2013, so this feature is still operational.

Not functional for now

Stock Shaders VS LUX

Todo: Move This to their own pages or something like that. Also, update.


LightmappedGeneric

Stock Shaders

Icon-Bug.pngBug:

$detailblendmode (Source 2013Team Fortress 2) 2-9 Don't work.
$detailblendmode (Alien Swarm) 6 Doesn't work.
$detailblendmode (Counter-Strike: Global Offensive) 8 doesn't work. 9 doesn't work with $bumpmap, $envmap or $selfillum
$bumpmap + $envmapmask Doesn't work, except in Counter-Strike: Global Offensive
$lightwarptexture + $detail (Team Fortress 2Alien Swarm) Doesn't work.

$basealphaenvmapmask + bumpmap Doesn't work  [todo tested in?]

$selfillummask (not in Source 2013)
$selfillum_envmapmask_alpha (not in Source 2013)
$selfillumfresnel (not in Source 2013)
$blendtintbybasealpha (not in Source 2013)
$detailtexturetransform (not in Source 2013)
$lightwarptexture(not in Counter-Strike: Global Offensive)
$envmapfresnelminmaxexp(in all games since Left 4 Dead)
$envmaplightscale(in all games since Alien Swarm)
$basealphaenvmapmask requires inverted masks

LUXLUX_LightMappedGeneric

Note.pngNote:

$detailblendmode 1-9 works.
$detailblendmode 10-11 planned.
$bumpmap + $envmapmask works, used to be (only in Counter-Strike: Global Offensive.)
$lightwarptexture + $detail works
$basealphaenvmapmask + $bumpmap works.
$selfillummask Exists now.
$blendtintbybasealpha Exists now.
$selfillum_envmapmask_alpha Exists now.
$envmaplightscale Exists now.

$detailtexturetransform Exists now.
Note.pngNote:Caveat - Has higher priority than $selfillum/$selfillummask.
Note.pngNote:Caveat - $selfillumtexture has higher priority than both.
Icon-Important.pngImportant:$basealphaenvmapmask does not require a flipped mask.
PlacementTip.pngWorkaround:There is a new parameter that can flip the envmap mask. It also works with $envmapmask and $normalmapalphaenvmapmask.

VertexLitGeneric

Stock Shaders

Always

$envmaplightscale(only in Counter-Strike: Global Offensive).

Without $Bumpmap

Icon-Bug.pngBug:$detailblendmodeSource 2013Team Fortress 2Alien SwarmCounter-Strike: Global Offensive 10-11 Don't work.

$selfillumfresnel missing.

$lightwarptexture missing.  [todo tested in?]
Note.pngNote:$lightwarptexture forces bumpmapping by binding a default one, unless one is manually specified.


With $Bumpmap

Icon-Bug.pngBug:

$detailblendmodeSource 2013Team Fortress 2Alien SwarmCounter-Strike: Global Offensive 5-11 Don't work.

$detailblendmodeCounter-Strike: Global Offensive 5-6 & 8-11 Don't work.  [todo tested in?]
Note.pngNote:

$envmapmask missing. Except Mapbase.

$selfillummask missing.
Confirm:Only in Mapbase?

$selfillum_envmapmask_alphaMapbase missing.

$selfillumfresnel disables $normalmapalphaenvmapmask.
Todo: Also on other branches than Alien Swarm?


With $Phong

Icon-Bug.pngBug:$detailblendmodeSource 2013Team Fortress 2Alien SwarmCounter-Strike: Global Offensive 8-11 Don't work. $invertphongmaskAlien SwarmSource 2013 In the shadercode, only flips the mask used for $envmap.
Confirm:Also on newer branches?

$phongalbedotint cannot be used without $phongexponenttexture.
$phongwarptextureLeft 4 Dead 2 does not work.
$phongalbedoboost(only in Counter-Strike: Global Offensive) + $detail does not work.
$phongtint disables $phongalbedotint.
$envmap always masked by something.
{{Only in Left 4 Dead+ $envmap masked by $basetexture luminance when $normalmapalphaenvmapmask and $basemapluminancephongmask is used.
$envmap masked by $basetexture alpha when $normalmapalphaenvmapmask and $basemapalphaphongmask is used.
$basemapalphaphongmask makes $phong ignore the $bumpmap.
$selfillumfresnel + $normalmapalphaenvmapmask will cause the $envmap to be multiplied by 0.0f regardless of whether $invertphongmask is used.

$selfillumfresnel will cause $envmap to be masked using the $basetexture alpha channel.}}  [todo tested in?]
Note.pngNote:$phongdisablehalflambert(in all games since Alien Swarm)

$phongexponentfactor only in Team Fortress 2Source 2013 Multiplayer
$basemapluminancephongmask(in all games since Left 4 Dead)

$phongalbedoboost only in (in all games since Counter-Strike: Global Offensive)

LUXLUX_VertexLitGeneric

Without $Bumpmap

Todo: Make a parameter that allows its usage. Right now default behavior is replicated and a default bumpmap is bound.


With $Bumpmap


With $Phong

Note.pngNote:$invertphongmask Now only flips the mask used for phong. It will no longer touch the envmapmask at all.
$phongalbedotint can now be used without $phongexponenttexture.
Note.pngNote:Will use entirety of $basetexture, without being masked.
Note.pngNote:$phongtint does no longer disable $phongalbedotint. It will do ($baseTexture * Mask) * $PhongTint
Note.pngNote:When no $phongexponenttexture is specified, Mask will be 1.0f!
  • $envmap Can now be not-masked by using a new parameter ($phongenvmapnomask)
Icon-Important.pngImportant:By default the original masking for the $envmap will be replicated to not have disparity. However, it can now be overridden using two new parameters. $phongforcebasealphaenvmapmask and $phongforcenormalmapalphaenvmapmask
Note.pngNote:This will make materials that previously used this intentionally, look different.

History

LUX LUX started development on January 20th, 2023, but it was planned and thought around January 14th, when the lead developer ShiroDkxtro2 was in a hospital stay.
Even before 2023, the idea of rewriting Valve's shaders was being considered. Various people asked ShiroDkxtro2 if certain modifications could be implemented for default shaders, such as cascaded shadow mapping.
These requests would usually result in a simple "no", as modifying the default shaders was not considered feasible for various reasons, most of which are indirectly mentioned in LUX's Goals.
The project's inception was supposed to be a means to make the existing shaders more moddable, with new features in mind and laid out so that implementing new things would be easier.

Credits

SCell555's ShaderCompiler
Used to compile the Shaders. Include files ( .inc ) are intended to be made using Perl.
LUX LUX copies various code from thexa4's PBR header
Tottery ( Also known as TotteryNine )
TotteryNine was crucial to ShiroDkxtro2 for learning the basics and more complicated aspects of making and compiling Shaders.
Sitkinator
Aiding with the initial logo and adding a screen-reflection effect to it.
Mr.Kleiner
For writing various tools. Including a VTF Flagging tool for Cubemaps inside a .bsp file, a tool for packing lightmap UV's into .smd files
roman_memes
Various logical checks and ideas. Also helped with prototyping new features and finding siggraph or other papers regarding modern and oldschool graphical implementations.
Alivebyte!
For doing modifications to the ShaderCompiler, which so far have not been implemented into the repo.
Ficool2
For enlightening us about the Constant Register Hack, allowing for the use of more than 32 float constant registers on SM3.0
This Project would be nearly impossible without it.
ChatGPT
Help with programming and the undocumented graphical features of the Source Engine.
It knows things and can make new things to a degree. Various code used in LUX LUX has been partially written by AI.
Mapbase Mapbase
Since one of the goals of this project is to be compatible with it, various code from it has been adapted.
This means that all Shader-related things should also be inherited with the credits of LUX LUX. You can find Mapbase's credits here.
Source++
Code might be included, like the NvidiaPCF5x5Gaussian Shadow Filter
Joshua Ashton
For his various open-source work related to the Source Engine

See also

Development can be followed here, Bug-Reports & suggestions made.
It is also intended as a general place for discussing Source 2013 Source 2013 related Shader-Modding.
Todo: Make a new category for LUX_ Shaders and document them and their parameters there, instead of here. Preferably after they were released on the GitHub.