LUX

From Valve Developer Community
Revision as of 15:31, 17 February 2023 by ShiroDkxtro2 (talk | contribs) (Fixed minor mistake - Github Link is doubled, a bunch of typo's)
Jump to navigation Jump to search
English (en)中文 (zh)Translate (Translate)
LUX
Development.png In Alpha development
Wiki
TypeModification
DevelopersShiroDkxtro2
EngineSource Source
Platforms(only in PC)
Based onSource 2013 Source 2013
 
GitHub
Join Discord server

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

  • Overhauled/Cleaned materialsystem\stdshaders\ Folder
Warning.pngWarning:Pretty much everything except existing shader-compile functionality is pretty much "nuked".
Note.pngNote: Implementing LUX Shaders would entail replacing the existing stdshaders\ with the one from LUX. Effectively 'nuking' SDK_ Shaders. LUX Shaders should be able to do everything SDK_ Shaders in Source 2013 and Mapbase can do.
Note.pngNote:SDK_ Shaders will fall back to LUX_ Shaders, that way LUX_ can easily be used on Mapbase Mapbase mods without much work.
  • Drastically decreased compile-times for all Shaders
Why?: Valves Shaders take forever to compile Source 2013 SingleplayerSource 2013 MultiplayerAlien Swarm. Especially using the stock Shader-Compiler. This disincentives modding the Shaders.
Note.pngNote:Even on a good CPU it can take half a day, or more. As an example for LUX. Compiling the entirety of LUX_LightMappedGeneric takes around 30 seconds on 4 cores @4.1GHz
  • SM3.0 Shaders Only
Why?: ps20b and below is too limiting. The lack of available constant registers causes extreme branching and a lot of 'combos'. Making the code terrible to read and complicated. This disincentives Modders.
Note.pngNote:SM3.0 released in 2004, and Valve considered ps2.0b low end hardware in ~2008. See slide 8
Note.pngNote:This means that older hardware not capable of SM3.0 will not be able to use the new Shaders.
Note.pngNote:Linux is not officially supported. MacOS is also not officially supported. Users of said system will have to either patche togl to work with SM3.0 or use DxVK.
  • Totally rewritten .h, .cpp, .fxc files
  • More Documentation for Shaders, their parameters, how they work and any possible caveats
Note.pngNote: You might have noticed Articles like $lightwarptexture, $detail, UnlitTwoTexture and $envmapmask getting major updates from ShiroDkxtro2,
where new information about Caveats and bugs were added for Team Fortress 2Alien SwarmSource 2013Counter-Strike: Global Offensive. This was a direct result of LUX development, although the focus was mainly on Source 2013Alien Swarm as their code is publicly available.
Note.pngNote:The current lack of documentation, on how Shaders work in Source, disincentives Modders from learning how to mod Shaders or make their own. The barrier of entry is v. high as a lot of very specific knowledge is required too.
  • Implementing features that aren't available in Source 2013
See also:  Planned Features. This includes old features such as $selfillumtexture and newer features like $phongalbedoboost(only in csgo).

  • Fixing most Parameter "bugs:" and other caveats
See also:  Stock Shaders VS LUX

  • Easy way of disabling features
Icon-Important.pngImportant:A custom Pre-Processor program has been made. It automatically sets // STATIC:'s to predefined values depending on #define's in an included header file.
Note.pngNote:Mods that don't require specific features (lightwarptexture/distancealpha/phong/envmaps/etc), can easily disable them. This will speed up Shader-compilation. Most parameters have been #ifdef'd in the c++ code!
  • Mapbase compatibility
Note.pngNote: Replacing SDK_ Shaders in SDK mods, SDK2013CE or Mapbase mods should be as simple as replacing the stdshaders\ Folder.
Note.pngNote: It is assumed that no custom Shaders apart from SDK_ ones were added. If they do were added however, developers should be capable of adding them back, as that is the prerequisite for adding custom Shaders.

Planned Features

This is a list of new features that are being implemented, or features that will be ported/recreated from newer branches such as Alien SwarmLeft 4 Dead 2Counter-Strike: Global Offensive

Note.pngNote:Ported in this case usually means Alien SwarmMapbase, however in most of these cases, the code for this will be heavily adapted to simplify or overhaul it.
Icon-Important.pngImportant:LUX does not use any leaked code. Features like $phongalbedoboost(only in csgo) are not rocket-science. They can safely be recreated without the use of leaked code.
Warning.pngWarning:For features that are more complicated, there might be visual disparity when compared to official implementations.

Features required for Mapbase Mapbase compatibility

Note.pngNote:Just like Mapbase Mapbase, this requires custom compilers to work.
Icon-Important.pngImportant:The parameters are the same for LUX and Mapbase. This means that Mapbase compilers can be used for this to work.
Todo: Is the Mapbase implementation ported from Alien Swarm?

New Features

  • In Source 2013 Multiplayer Models utilizing Model Lightmapping can use $bumpmap. Additionally all Model shaders will be able to utilize this feature. Except they have $phong.
Icon-Important.pngImportant:The Lightmap does not do bumped-lighting using the bumpmap. Only named-lights/projected textures will be able to do so.
Note.pngNote: 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.
Warning.pngWarning:The way this is currently implemented requires a custom written tool, two smd's ( one with lightmap uv ) and also has a lot of precision loss for the Lightmap UV's. Additionally this requires a custom compiler!
Todo: Investigate Source 2007 code, supposedly the Studiomdl code is there. Maybe it can be packed via Blendweights or alternatively the precision loss might be decreased.

Features ported/recreated/revived

Note.pngNote:LUX allows the use of Rec. 709 HDTV Luminance Weights. float3(0.2126f, 0.7152f, 0.0722f).

Previously SDK_ Shaders would use the NTSC Analog Television standard of float3(0.2990f, 0.5870f, 0.1140f)

Note.pngNote: 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.

Icon-Important.pngImportant:
* 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, will use the Lightmap. Regardless of whether or not $bumpmap is used.

Features that are being discarded

  • $envmapsphere and related - These features have been removed since Alien Swarm and are obsolete.
Note.pngNote:This is very easy to re-implement. The 7th face of a Cubemap is still being built in Source 2013 and therefore this feature is still operational given that the code has been implemented!

Features that won't be ported/recreated/revived

  • $basealphaenvmapmaskminmaxexp from 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

Not functional - FOR NOW



Stock Shaders VS LUX

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

LightMappedGeneric

Stock Shader's

Icon-Bug.pngBug:$detailblendmodeSource 2013Team Fortress 2 2-9 Don't work.  [todo tested in ?]
Icon-Bug.pngBug:$detailblendmodeAlien Swarm 6 Doesn't work.  [todo tested in ?]
Icon-Bug.pngBug:$detailblendmodeCounter-Strike: Global Offensive 1-6, 8 Don't work. 9 Does not work with $bumpmap, $envmap or $selfillum  [todo tested in ?]


Icon-Bug.pngBug:$bumpmap + $envmapmask Doesn't work, except in Counter-Strike: Global Offensive Counter-Strike: Global Offensive  [todo tested in ?]
Icon-Bug.pngBug:$lightwarptexture + $detailTeam Fortress 2Alien Swarm Doesn't work  [todo tested in ?]
Icon-Bug.pngBug:$basealphaenvmapmask + bumpmap Doesn't work  [todo tested in ?]


Note.pngNote:$selfillummask Missing
Note.pngNote:$selfillum_envmapmask_alpha Missing
Note.pngNote:$selfillumfresnel Missing
Note.pngNote:$blendtintbybasealpha Missing
Note.pngNote:$detailtexturetransform Missing
Note.pngNote:$lightwarptextureCounter-Strike: Global Offensive Missing
Note.pngNote:$envmapfresnelminmaxexp(only in Left 4 Dead+)
Note.pngNote:$envmaplightscale(only in Alien Swarm+)
Note.pngNote:$basealphaenvmapmask requires inverted masks

LUX_LightMappedGeneric

Note.pngNote:Caveat - Has higher priority than $selfillum/$selfillummask.
Note.pngNote:Caveat - $selfillumtexture has higher priority than both.
Icon-Important.pngImportant:$basealphaenvmapmask does no longer require a flipped mask.
PlacementTip.pngWorkaround:Materials that previously used have to be adjusted. Use $envmapmask or $normalmapalphaenvmapmask instead!

VertexLitGeneric

Stock Shader's

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.  [todo tested in ?]
Icon-Bug.pngBug:$selfillumfresnel missing.  [todo tested in ?]
Icon-Bug.pngBug:$lightwarptexture missing.  [todo tested in ?]
Note.pngNote:$lightwarptexture fores 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.  [todo tested in ?]
Icon-Bug.pngBug:$detailblendmodeCounter-Strike: Global Offensive 5-6 & 8-11 Don't work.  [todo tested in ?]
Note.pngNote:$envmapmask missing. Except Mapbase.
Note.pngNote:$selfillummask missing.
Confirm:Only in Mapbase?
Note.pngNote:$selfillum_envmapmask_alphaMapbase missing.
Icon-Bug.pngBug:$selfillumfresnel disables $normalmapalphaenvmapmask.
Todo: Also on other branches than Alien Swarm?
  [todo tested in ?]

With $Phong

Icon-Bug.pngBug:$detailblendmodeSource 2013Team Fortress 2Alien SwarmCounter-Strike: Global Offensive 8-11 Don't work.  [todo tested in ?]
Icon-Bug.pngBug:$invertphongmaskAlien SwarmSource 2013 In the shadercode, only flips the mask used for $envmap.
Confirm:Also on newer branches?
  [todo tested in ?]
Icon-Bug.pngBug:$phongalbedotint cannot be used without $phongexponenttexture.  [todo tested in ?]
Icon-Bug.pngBug:$phongwarptextureLeft 4 Dead 2 does not work.  [todo tested in ?]
Icon-Bug.pngBug:$phongalbedoboost(only in Counter-Strike: Global Offensive) + $detail does not work.  [todo tested in ?]
Icon-Bug.pngBug:$phongtint disables $phongalbedotint.  [todo tested in ?]
Icon-Bug.pngBug:$envmap always masked by something.  [todo tested in ?]
Icon-Bug.pngBug:Only in Left 4 Dead+ $envmap masked by $basetexture luminance when $normalmapalphaenvmapmask and $basemapluminancephongmask is used.  [todo tested in ?]
Icon-Bug.pngBug:$envmap masked by $basetexture alpha when $normalmapalphaenvmapmask and $basemapalphaphongmask is used.  [todo tested in ?]
Icon-Bug.pngBug:$basemapalphaphongmask makes $phong ignore the $bumpmap.  [todo tested in ?]
Icon-Bug.pngBug:$selfillumfresnel + $normalmapalphaenvmapmask will cause the $envmap to be multiplied by 0.0f regardless of whether $invertphongmask is used.  [todo tested in ?]
Icon-Bug.pngBug:$selfillumfresnel will cause $envmap to be masked using the $basetexture alpha channel  [todo tested in ?]
Note.pngNote:$phongdisablehalflambert only in Alien Swarm+
Note.pngNote:$phongexponentfactor only in Team Fortress 2Source 2013 Multiplayer
Note.pngNote:$basemapluminancephongmask only in Left 4 Dead+
Note.pngNote:$phongalbedoboost only in Counter-Strike: Global Offensive+

LUX_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:Will use entirety of $basetexture, without being masked.
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 as to not have disparity.

However it can now be overriden using two new parameters. $phongforcebasealphaenvmapmask and $phongforcenormalmapalphaenvmapmask

Note.pngNote:This will make materials that previously used this intentionally, look different.





Todo: Add LUX_WorldVertexTransition and other LUX_ Shaders to this list of comparison and changes.
Note.pngNote: Probably better as their own pages to document all parameters.