<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Artificialparanoia</id>
	<title>Frictional Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Artificialparanoia"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page/Special:Contributions/Artificialparanoia"/>
	<updated>2026-04-03T18:12:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=7011</id>
		<title>HPL3/Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=7011"/>
		<updated>2025-04-23T21:49:35Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started ==&lt;br /&gt;
* [[HPL3/Shaders/Shaders Overview|Shaders Overview]]&lt;br /&gt;
* [https://www.khronos.org/opengl/wiki/Getting_Started Getting Started With OpenGL]&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
* [[HPL3/Shaders/HPSL Shading Language|The HPSL Shading Language]]&lt;br /&gt;
* [[HPL3/Shaders/Overwriting Existing Shaders|Overwriting Existing Shaders]]&lt;br /&gt;
* [[HPL3/Shaders/Adding Custom Shaders|Adding Custom Shaders]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Tutorials&amp;diff=6858</id>
		<title>HPL3/SOMA/Tutorials</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Tutorials&amp;diff=6858"/>
		<updated>2024-11-04T00:33:57Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: Add link to shader pages until someone links them on the main page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
'''Find tutorials of various HPL3 topics here.'''&lt;br /&gt;
&lt;br /&gt;
{{CategoryHeader}}&lt;br /&gt;
{{CategoryNewcolumn}}&lt;br /&gt;
&lt;br /&gt;
== Modding ==&lt;br /&gt;
*[https://www.youtube.com/watch?v=ZIN9v0SohHo&amp;amp;list=PLwJXvfVZGcJljQs1G-rAnipVf5SeuXawX&amp;amp;index=10 Setting up a Mod Entry] - By Draugemalf&lt;br /&gt;
*[https://www.youtube.com/watch?v=8XKKXO9K7fI Creating a Mod] - By Frictional Games&lt;br /&gt;
&lt;br /&gt;
== Level Design ==&lt;br /&gt;
*[https://www.youtube.com/watch?v=lR-4OlG4uuc&amp;amp;list=PLwJXvfVZGcJmwkaH6JiZUrlKAv5SXwwjW Level Editor Tutorial Series] - By Draugemalf&lt;br /&gt;
*[https://www.youtube.com/watch?v=K9cfQLO92jg&amp;amp;list=PLwJXvfVZGcJljQs1G-rAnipVf5SeuXawX&amp;amp;index=11 SH Probes Tutorial] - By [[User:TiMan|TiMan]]&lt;br /&gt;
*[https://www.youtube.com/watch?v=TGhwsa1k1LU Creating a Map] - By Frictional Games&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
*[https://www.youtube.com/watch?v=3kD4dT4DNjs Setting up CodeLite] - By Frictional Games (Outdated)&lt;br /&gt;
*[https://www.youtube.com/watch?v=CPKtK_koYh0 Scripting Overview] - By Frictional Games&lt;br /&gt;
*[[HPL3/SOMA/Tutorials/Scripting/Amnesia-Style Inventory Script Reference|Amnesia-Style Inventory Script Reference]] - By Abion47&lt;br /&gt;
&lt;br /&gt;
== Shaders ==&lt;br /&gt;
*[[HPL3/Shaders/Overwriting_Existing_Shaders|Overwriting Existing Shaders]] - By Artificialparanoia&lt;br /&gt;
&lt;br /&gt;
{{CategoryEnd}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:Entry pages]]&lt;br /&gt;
[[Category:English]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6841</id>
		<title>HPL3/Shaders/Overwriting Existing Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6841"/>
		<updated>2024-09-13T22:14:16Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: Typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
[[File:Greyscale Demonstration.jpg|thumb|A simple shader mod that gives SOMA a classic, film noir look...]]Most shaders can be overwritten at runtime by StandAlone and AddOn mods, allowing for them to easily modify shader behavior. Here's an example mod for SOMA in both [https://mega.nz/file/egE1CYZD#WliKF2KuCEwn2XNmt9idmGqaDv8Nr5pIFtEi2EA6ISs StandAlone] and [https://mega.nz/file/L4dEFBJJ#wAIzKE7fF0pAjpXRmDr1bzvDMTvz5mawVrKp0QvbiB8 AddOn] configuration that makes a simple edit to the game's &amp;lt;code&amp;gt;posteffect_tonemapping_frag.hpsl&amp;lt;/code&amp;gt; shader. After loading either version, you can see that the entire game is now in black and white!&lt;br /&gt;
&lt;br /&gt;
Alternatively, vanilla shaders can be directly modified in the &amp;lt;code&amp;gt;core\shaders\&amp;lt;/code&amp;gt; directory of your game install. This can be useful for more complex shader mods which edit the few shaders that cannot be reliably overwritten by normal StandAlone or AddOn mods, which are currently:&lt;br /&gt;
&lt;br /&gt;
* base_vtx.hpsl&lt;br /&gt;
* base_frag.hpsl&lt;br /&gt;
* cache_terrain_diffuse_frag.hpsl&lt;br /&gt;
* clear_frag.hpsl&lt;br /&gt;
* clear_vtx.hpsl&lt;br /&gt;
* deferred_base_frag.hpsl&lt;br /&gt;
* deferred_base_vtx.hpsl&lt;br /&gt;
* deferred_skybox_frag.hpsl&lt;br /&gt;
* deferred_terrain_gbuffer_frag.hpsl&lt;br /&gt;
* deferred_terrain_tess_cs.hpsl&lt;br /&gt;
* deferred_terrain_tess_es.hpsl&lt;br /&gt;
* deferred_terrain_vtx.hpsl&lt;br /&gt;
* null_frag.hpsl&lt;br /&gt;
* null_frag_array.hpsl&lt;br /&gt;
* null_frag_array2.hpsl&lt;br /&gt;
* null_vtx.hpsl&lt;br /&gt;
&lt;br /&gt;
These likely have special behavior in-engine that changes the way they're loaded when compared to other shaders. More testing will be needed to determine why this is the case. &lt;br /&gt;
&lt;br /&gt;
== Set Up ==&lt;br /&gt;
&lt;br /&gt;
Edit your mod's &amp;lt;code&amp;gt;resources.cfg&amp;lt;/code&amp;gt; file to include the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;Resources&amp;gt;&lt;br /&gt;
    &amp;lt;Directory Path=&amp;quot;/core&amp;quot; AddSubDirs=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/Resources&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
GLSL shaders should be located in your mod's &amp;lt;code&amp;gt;core\shaders\&amp;lt;/code&amp;gt; directory and HPSL shaders should be in &amp;lt;code&amp;gt;core\shaders\hpsl&amp;lt;/code&amp;gt;. For existing shaders, your shader MUST have the same name and path as the shader you're trying to overwrite. Most of the shader list is hardcoded within the executable and there is no known way to create new GpuPrograms or delete existing ones without access to the source code. For a simple AddOn that just alters shaders, your file structure will likely look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
modFolder/&lt;br /&gt;
├── core/&lt;br /&gt;
│   ├── shaders/&lt;br /&gt;
│   │   ├── hpsl/&lt;br /&gt;
├── entry.hpc&lt;br /&gt;
├── resources.cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SOMA ===&lt;br /&gt;
&lt;br /&gt;
Beyond this, the setup process for SOMA is extremely straightforward and is as simple as placing your shaders in your mod's &amp;lt;code&amp;gt;core\shaders\&amp;lt;/code&amp;gt; directory, and your changes should be reflected in-game after loading your mod. Keep in mind that not all shader code is compiled on startup and is often conditional depending on what is being rendered in the current map, so some changes will not be immediately apparent! &lt;br /&gt;
&lt;br /&gt;
=== Amnesia: Rebirth and Amnesia: The Bunker ===&lt;br /&gt;
&lt;br /&gt;
For Amnesia: Rebirth and Amnesia: The Bunker, &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; MUST be set to false in your mod's user settings configuration file for your mod's custom shaders to be reflected in-game. This will likely lead to slightly degraded performance, but this doesn't seem too noticeable on modern hardware. You will need to overwrite the base game's &amp;lt;code&amp;gt;default_user_settings.cfg&amp;lt;/code&amp;gt; in the config folder to automatically set &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; to false (for Rebirth) OR you will need to manually instruct users to set &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; to false in their .cfg file (for Bunker). &lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' Make sure &amp;lt;code&amp;gt;SaveShaderCache&amp;lt;/code&amp;gt; is set to false! This has much worse performance degradation and worse compatibility than &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt;, as it constantly regenerates the shadercache.xml file in &amp;lt;code&amp;gt;_shadersource&amp;lt;/code&amp;gt; at runtime. This may be useful for directly editing shaders within your base install, but is unlikely to be useful for StandAlone or AddOn mods.&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6840</id>
		<title>HPL3/Shaders/Overwriting Existing Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6840"/>
		<updated>2024-09-13T22:07:37Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: Remove construction banner&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
[[File:Greyscale Demonstration.jpg|thumb|A simple shader mod that gives SOMA a classic, film noir look...]]Most shaders can be overwritten at runtime by StandAlone and AddOn mods, allowing for them to easily modify shader behavior. Here's an example mod for SOMA in both [https://mega.nz/file/egE1CYZD#WliKF2KuCEwn2XNmt9idmGqaDv8Nr5pIFtEi2EA6ISs StandAlone] and [https://mega.nz/file/L4dEFBJJ#wAIzKE7fF0pAjpXRmDr1bzvDMTvz5mawVrKp0QvbiB8 AddOn] configuration that makes a simple edit to the game's &amp;lt;code&amp;gt;posteffect_tonemapping_frag.hpsl&amp;lt;/code&amp;gt; shader. After loading either version, you can see that the entire game is now in black and white!&lt;br /&gt;
&lt;br /&gt;
Alternatively, vanilla shaders can be directly modified in the &amp;lt;code&amp;gt;core\shaders\&amp;lt;/code&amp;gt; directory of your game install. This can be useful for more complex shader mods which edit the few shaders that cannot be reliably overwritten by normal StandAlone or AddOn mods, which are currently:&lt;br /&gt;
&lt;br /&gt;
* base_vtx.hpsl&lt;br /&gt;
* base_frag.hpsl&lt;br /&gt;
* cache_terrain_diffuse_frag.hpsl&lt;br /&gt;
* clear_frag.hpsl&lt;br /&gt;
* clear_vtx.hpsl&lt;br /&gt;
* deferred_base_frag.hpsl&lt;br /&gt;
* deferred_base_vtx.hpsl&lt;br /&gt;
* deferred_skybox_frag.hpsl&lt;br /&gt;
* deferred_terrain_gbuffer_frag.hpsl&lt;br /&gt;
* deferred_terrain_tess_cs.hpsl&lt;br /&gt;
* deferred_terrain_tess_es.hpsl&lt;br /&gt;
* deferred_terrain_vtx.hpsl&lt;br /&gt;
* null_frag.hpsl&lt;br /&gt;
* null_frag_array.hpsl&lt;br /&gt;
* null_frag_array2.hpsl&lt;br /&gt;
* null_vtx.hpsl&lt;br /&gt;
&lt;br /&gt;
These likely have special behavior in-engine that changes the way they're loaded when compared to other shaders. More testing will be needed to determine why this is the case. &lt;br /&gt;
&lt;br /&gt;
== Set Up ==&lt;br /&gt;
&lt;br /&gt;
Edit your mod's &amp;lt;code&amp;gt;resources.cfg&amp;lt;/code&amp;gt; folder to include the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;Resources&amp;gt;&lt;br /&gt;
    &amp;lt;Directory Path=&amp;quot;/core&amp;quot; AddSubDirs=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/Resources&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
GLSL shaders should be located in your mod's &amp;lt;code&amp;gt;core\shaders\&amp;lt;/code&amp;gt; directory and HPSL shaders should be in &amp;lt;code&amp;gt;core\shaders\hpsl&amp;lt;/code&amp;gt;. For existing shaders, your shader MUST have the same name and path as the shader you're trying to overwrite. Most of the shader list is hardcoded within the executable and there is no known way to create new GpuPrograms or delete existing ones without access to the source code. For a simple AddOn that just alters shaders, your file structure will likely look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
modFolder/&lt;br /&gt;
├── core/&lt;br /&gt;
│   ├── shaders/&lt;br /&gt;
│   │   ├── hpsl/&lt;br /&gt;
├── entry.hpc&lt;br /&gt;
├── resources.cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SOMA ===&lt;br /&gt;
&lt;br /&gt;
Beyond this, the setup process for SOMA is extremely straightforward and is as simple as placing your shaders in your mod's &amp;lt;code&amp;gt;\core\shaders\&amp;lt;/code&amp;gt; directory, and your changes should be reflected in-game after loading your mod. Keep in mind that not all shader code is compiled on startup and is often conditional depending on what is being rendered in the current map, so some changes will not be immediately apparent! &lt;br /&gt;
&lt;br /&gt;
=== Amnesia: Rebirth and Amnesia: The Bunker ===&lt;br /&gt;
&lt;br /&gt;
For Amnesia: Rebirth and Amnesia: The Bunker, &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; MUST be set to false in your mod's user settings configuration file for your mod's custom shaders to be reflected in-game. This will likely lead to slightly degraded performance, but this doesn't seem too noticeable on modern hardware. You will need to overwrite the base game's &amp;lt;code&amp;gt;default_user_settings.cfg&amp;lt;/code&amp;gt; in the config folder to automatically set &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; to false (for Rebirth) OR you will need to manually instruct users to set &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; to false in their .cfg file (for Bunker). &lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' Make sure &amp;lt;code&amp;gt;SaveShaderCache&amp;lt;/code&amp;gt; is set to false! This has much worse performance degradation and worse compatibility than &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt;, as it constantly regenerates the shadercache.xml file in &amp;lt;code&amp;gt;_shadersource&amp;lt;/code&amp;gt; at runtime. This may be useful for directly editing shaders within your base install, but is unlikely to be useful for StandAlone or AddOn mods.&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6839</id>
		<title>HPL3/Shaders/Overwriting Existing Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6839"/>
		<updated>2024-09-13T21:59:22Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: Updated guide with more detail and better formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
{{constructionNotice|This page is currently a work in progress! Information will be added over time based on research and testing.}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
[[File:Greyscale Demonstration.jpg|thumb|A simple shader mod that gives SOMA a classic, film noir look...]]Most shaders can be overwritten at runtime by StandAlone and AddOn mods, allowing for them to easily modify shader behavior. Here's an example mod for SOMA in both [https://mega.nz/file/egE1CYZD#WliKF2KuCEwn2XNmt9idmGqaDv8Nr5pIFtEi2EA6ISs StandAlone] and [https://mega.nz/file/L4dEFBJJ#wAIzKE7fF0pAjpXRmDr1bzvDMTvz5mawVrKp0QvbiB8 AddOn] configuration that makes a simple edit to the game's &amp;lt;code&amp;gt;posteffect_tonemapping_frag.hpsl&amp;lt;/code&amp;gt; shader. After loading either version, you can see that the entire game is now in black and white!&lt;br /&gt;
&lt;br /&gt;
Alternatively, vanilla shaders can be directly modified in the &amp;lt;code&amp;gt;core\shaders\&amp;lt;/code&amp;gt; directory of your game install. This can be useful for more complex shader mods which edit the few shaders that cannot be reliably overwritten by normal StandAlone or AddOn mods, which are currently:&lt;br /&gt;
&lt;br /&gt;
* base_vtx.hpsl&lt;br /&gt;
* base_frag.hpsl&lt;br /&gt;
* cache_terrain_diffuse_frag.hpsl&lt;br /&gt;
* clear_frag.hpsl&lt;br /&gt;
* clear_vtx.hpsl&lt;br /&gt;
* deferred_base_frag.hpsl&lt;br /&gt;
* deferred_base_vtx.hpsl&lt;br /&gt;
* deferred_skybox_frag.hpsl&lt;br /&gt;
* deferred_terrain_gbuffer_frag.hpsl&lt;br /&gt;
* deferred_terrain_tess_cs.hpsl&lt;br /&gt;
* deferred_terrain_tess_es.hpsl&lt;br /&gt;
* deferred_terrain_vtx.hpsl&lt;br /&gt;
* null_frag.hpsl&lt;br /&gt;
* null_frag_array.hpsl&lt;br /&gt;
* null_frag_array2.hpsl&lt;br /&gt;
* null_vtx.hpsl&lt;br /&gt;
&lt;br /&gt;
These likely have special behavior in-engine that changes the way they're loaded when compared to other shaders. More testing will be needed to determine why this is the case. &lt;br /&gt;
&lt;br /&gt;
== Set Up ==&lt;br /&gt;
&lt;br /&gt;
Edit your mod's &amp;lt;code&amp;gt;resources.cfg&amp;lt;/code&amp;gt; folder to include the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;Resources&amp;gt;&lt;br /&gt;
    &amp;lt;Directory Path=&amp;quot;/core&amp;quot; AddSubDirs=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/Resources&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
GLSL shaders should be located in your mod's &amp;lt;code&amp;gt;core\shaders\&amp;lt;/code&amp;gt; directory and HPSL shaders should be in &amp;lt;code&amp;gt;core\shaders\hpsl&amp;lt;/code&amp;gt;. For existing shaders, your shader MUST have the same name and path as the shader you're trying to overwrite. Most of the shader list is hardcoded within the executable and there is no known way to create new GpuPrograms or delete existing ones without access to the source code. For a simple AddOn that just alters shaders, your file structure will likely look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
modFolder/&lt;br /&gt;
├── core/&lt;br /&gt;
│   ├── shaders/&lt;br /&gt;
│   │   ├── hpsl/&lt;br /&gt;
├── entry.hpc&lt;br /&gt;
├── resources.cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== SOMA ===&lt;br /&gt;
&lt;br /&gt;
Beyond this, the setup process for SOMA is extremely straightforward and is as simple as placing your shaders in your mod's &amp;lt;code&amp;gt;\core\shaders\&amp;lt;/code&amp;gt; directory, and your changes should be reflected in-game after loading your mod. Keep in mind that not all shader code is compiled on startup and is often conditional depending on what is being rendered in the current map, so some changes will not be immediately apparent! &lt;br /&gt;
&lt;br /&gt;
=== Amnesia: Rebirth and Amnesia: The Bunker ===&lt;br /&gt;
&lt;br /&gt;
For Amnesia: Rebirth and Amnesia: The Bunker, &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; MUST be set to false in your mod's user settings configuration file for your mod's custom shaders to be reflected in-game. This will likely lead to slightly degraded performance, but this doesn't seem too noticeable on modern hardware. You will need to overwrite the base game's &amp;lt;code&amp;gt;default_user_settings.cfg&amp;lt;/code&amp;gt; in the config folder to automatically set &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; to false (for Rebirth) OR you will need to manually instruct users to set &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt; to false in their .cfg file (for Bunker). &lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' Make sure &amp;lt;code&amp;gt;SaveShaderCache&amp;lt;/code&amp;gt; is set to false! This has much worse performance degradation and worse compatibility than &amp;lt;code&amp;gt;LoadShaderCache&amp;lt;/code&amp;gt;, as it constantly regenerates the shadercache.xml file in &amp;lt;code&amp;gt;_shadersource&amp;lt;/code&amp;gt; at runtime. This may be useful for directly editing shaders within your base install, but is unlikely to be useful for StandAlone or AddOn mods.&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=File:Greyscale_Demonstration.jpg&amp;diff=6838</id>
		<title>File:Greyscale Demonstration.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=File:Greyscale_Demonstration.jpg&amp;diff=6838"/>
		<updated>2024-09-13T20:47:33Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An image of SOMA in the black and white due to shader editing.&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6837</id>
		<title>HPL3/Shaders/Overwriting Existing Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6837"/>
		<updated>2024-09-13T05:12:07Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: /* Set Up */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
{{constructionNotice|This page is currently a work in progress! Information will be added over time based on research and testing.}}&lt;br /&gt;
&lt;br /&gt;
Most shaders can be overwritten at runtime by StandAlone and AddOn mods, allowing for them to easily modify shader behavior. &lt;br /&gt;
&lt;br /&gt;
Alternatively, vanilla shaders can be directly modified in the core\shaders\ directory of your game install. This can be useful for more complex shader mods which edit the few shaders that cannot be reliably overwritten by normal StandAlone or AddOn mods, which are currently:&lt;br /&gt;
&lt;br /&gt;
* base_vtx.hpsl&lt;br /&gt;
* base_frag.hpsl&lt;br /&gt;
* cache_terrain_diffuse_frag.hpsl&lt;br /&gt;
* clear_frag.hpsl&lt;br /&gt;
* clear_vtx.hpsl&lt;br /&gt;
* deferred_base_frag.hpsl&lt;br /&gt;
* deferred_base_vtx.hpsl&lt;br /&gt;
* deferred_skybox_frag.hpsl&lt;br /&gt;
* deferred_terrain_gbuffer_frag.hpsl&lt;br /&gt;
* deferred_terrain_tess_cs.hpsl&lt;br /&gt;
* deferred_terrain_tess_es.hpsl&lt;br /&gt;
* deferred_terrain_vtx.hpsl&lt;br /&gt;
* null_frag.hpsl&lt;br /&gt;
* null_frag_array.hpsl&lt;br /&gt;
* null_frag_array2.hpsl&lt;br /&gt;
* null_vtx.hpsl&lt;br /&gt;
&lt;br /&gt;
These likely have special behavior in-engine that changes the way they're loaded when compared to other shaders. More testing will be needed to determine why this is the case. &lt;br /&gt;
&lt;br /&gt;
== Set Up==&lt;br /&gt;
&lt;br /&gt;
GLSL shaders are to be located in your mod's core\shaders\ directory and HPSL shaders should be in core\shaders\hpsl. For existing shaders, your shader MUST have the same name and path as the shader you're trying to overwrite. Most of the shader list is hardcoded within the executable and there is no known way to create new GpuPrograms or delete existing ones without access to the source code. &lt;br /&gt;
&lt;br /&gt;
=== SOMA ===&lt;br /&gt;
&lt;br /&gt;
The setup process for SOMA is extremely straightforward and is as simple as placing your shaders in your mod's \core\shaders\ directory, and your changes should be reflected in-game after loading your mod. Keep in mind that not all shader code is compiled on startup and is often conditional depending on what is being rendered in the current map, so some changes will not be immediately apparent! &lt;br /&gt;
&lt;br /&gt;
=== Amnesia: Rebirth and Amnesia: The Bunker ===&lt;br /&gt;
&lt;br /&gt;
For Amnesia: Rebirth and Amnesia: The Bunker, LoadShaderCache MUST be set to false in your mod's user settings configuration file for your mod's custom shaders to be reflected in-game. This will likely lead to slightly degraded performance, but this doesn't seem too noticeable on modern hardware. You will need to overwrite the base game's default_user_settings.cfg in the config folder to automatically set LoadShaderCache to false (for Rebirth) OR you will need to manually instruct users to set LoadShaderCache to false in their .cfg file (for Bunker). &lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' Make sure SaveShaderCache is set to false! This has much worse performance degradation and worse compatibility than LoadShaderCache, as it constantly regenerates the shadercache.xml file in _shadersource at runtime. This may be useful for directly editing shaders within your base install, but is unlikely to be useful for StandAlone or AddOn mods.&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=6836</id>
		<title>HPL3/Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=6836"/>
		<updated>2024-09-13T05:05:24Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: /* General */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started ==&lt;br /&gt;
* [[HPL3/Shaders/Shaders Overview|Shaders Overview]]&lt;br /&gt;
* [https://www.khronos.org/opengl/wiki/Getting_Started Getting Started With OpenGL]&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
* [[HPL3/Shaders/HPSL Shading Language|The HPSL Shading Language]]&lt;br /&gt;
* [[HPL3/Shaders/Overwriting Existing Shaders|Overwriting Existing Shaders]]&lt;br /&gt;
* [[HPL3/Shaders/Adding New Shaders|Adding Custom Shader Functionality]]&lt;br /&gt;
* [[HPL3/Shaders/Adding New Shaders|Adding New Shaders]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6835</id>
		<title>HPL3/Shaders/Overwriting Existing Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6835"/>
		<updated>2024-09-13T05:00:42Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: /* Amnesia: Rebirth and Amnesia: The Bunker */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
{{constructionNotice|This page is currently a work in progress! Information will be added over time based on research and testing.}}&lt;br /&gt;
&lt;br /&gt;
Most shaders can be overwritten at runtime by StandAlone and AddOn mods, allowing for them to easily modify shader behavior. &lt;br /&gt;
&lt;br /&gt;
Alternatively, vanilla shaders can be directly modified in the core\shaders\ directory of your game install. This can be useful for more complex shader mods which edit the few shaders that cannot be reliably overwritten by normal StandAlone or AddOn mods, which are currently:&lt;br /&gt;
&lt;br /&gt;
* base_vtx.hpsl&lt;br /&gt;
* base_frag.hpsl&lt;br /&gt;
* cache_terrain_diffuse_frag.hpsl&lt;br /&gt;
* clear_frag.hpsl&lt;br /&gt;
* clear_vtx.hpsl&lt;br /&gt;
* deferred_base_frag.hpsl&lt;br /&gt;
* deferred_base_vtx.hpsl&lt;br /&gt;
* deferred_skybox_frag.hpsl&lt;br /&gt;
* deferred_terrain_gbuffer_frag.hpsl&lt;br /&gt;
* deferred_terrain_tess_cs.hpsl&lt;br /&gt;
* deferred_terrain_tess_es.hpsl&lt;br /&gt;
* deferred_terrain_vtx.hpsl&lt;br /&gt;
* null_frag.hpsl&lt;br /&gt;
* null_frag_array.hpsl&lt;br /&gt;
* null_frag_array2.hpsl&lt;br /&gt;
* null_vtx.hpsl&lt;br /&gt;
&lt;br /&gt;
These likely have special behavior in-engine that changes the way they're loaded when compared to other shaders. More testing will be needed to determine why this is the case. &lt;br /&gt;
&lt;br /&gt;
== Set Up==&lt;br /&gt;
&lt;br /&gt;
For existing shaders, your shader MUST have the same name as the shader you're trying to overwrite. Most of the shader list is hardcoded within the executable and there is no known way to create new GpuPrograms or delete existing ones without access to the source code. &lt;br /&gt;
&lt;br /&gt;
=== SOMA ===&lt;br /&gt;
&lt;br /&gt;
The setup process for SOMA is extremely straightforward and is as simple as placing your shaders in your mod's \core\shaders\ directory, and your changes should be reflected in-game after loading your mod. Keep in mind that not all shader code is compiled on startup and is often conditional depending on what is being rendered in the current map, so some changes will not be immediately apparent! &lt;br /&gt;
&lt;br /&gt;
=== Amnesia: Rebirth and Amnesia: The Bunker ===&lt;br /&gt;
&lt;br /&gt;
For Amnesia: Rebirth and Amnesia: The Bunker, LoadShaderCache MUST be set to false in your mod's user settings configuration file for your mod's custom shaders to be reflected in-game. This will likely lead to slightly degraded performance, but this doesn't seem too noticeable on modern hardware. You will need to overwrite the base game's default_user_settings.cfg in the config folder to automatically set LoadShaderCache to false (for Rebirth) OR you will need to manually instruct users to set LoadShaderCache to false in their .cfg file (for Bunker). &lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' Make sure SaveShaderCache is set to false! This has much worse performance degradation and worse compatibility than LoadShaderCache, as it constantly regenerates the shadercache.xml file in _shadersource at runtime. This may be useful for directly editing shaders within your base install, but is unlikely to be useful for StandAlone or AddOn mods.&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6834</id>
		<title>HPL3/Shaders/Overwriting Existing Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders/Overwriting_Existing_Shaders&amp;diff=6834"/>
		<updated>2024-09-13T04:57:54Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: Adding initial stub&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
{{constructionNotice|This page is currently a work in progress! Information will be added over time based on research and testing.}}&lt;br /&gt;
&lt;br /&gt;
Most shaders can be overwritten at runtime by StandAlone and AddOn mods, allowing for them to easily modify shader behavior. &lt;br /&gt;
&lt;br /&gt;
Alternatively, vanilla shaders can be directly modified in the core\shaders\ directory of your game install. This can be useful for more complex shader mods which edit the few shaders that cannot be reliably overwritten by normal StandAlone or AddOn mods, which are currently:&lt;br /&gt;
&lt;br /&gt;
* base_vtx.hpsl&lt;br /&gt;
* base_frag.hpsl&lt;br /&gt;
* cache_terrain_diffuse_frag.hpsl&lt;br /&gt;
* clear_frag.hpsl&lt;br /&gt;
* clear_vtx.hpsl&lt;br /&gt;
* deferred_base_frag.hpsl&lt;br /&gt;
* deferred_base_vtx.hpsl&lt;br /&gt;
* deferred_skybox_frag.hpsl&lt;br /&gt;
* deferred_terrain_gbuffer_frag.hpsl&lt;br /&gt;
* deferred_terrain_tess_cs.hpsl&lt;br /&gt;
* deferred_terrain_tess_es.hpsl&lt;br /&gt;
* deferred_terrain_vtx.hpsl&lt;br /&gt;
* null_frag.hpsl&lt;br /&gt;
* null_frag_array.hpsl&lt;br /&gt;
* null_frag_array2.hpsl&lt;br /&gt;
* null_vtx.hpsl&lt;br /&gt;
&lt;br /&gt;
These likely have special behavior in-engine that changes the way they're loaded when compared to other shaders. More testing will be needed to determine why this is the case. &lt;br /&gt;
&lt;br /&gt;
== Set Up==&lt;br /&gt;
&lt;br /&gt;
For existing shaders, your shader MUST have the same name as the shader you're trying to overwrite. Most of the shader list is hardcoded within the executable and there is no known way to create new GpuPrograms or delete existing ones without access to the source code. &lt;br /&gt;
&lt;br /&gt;
=== SOMA ===&lt;br /&gt;
&lt;br /&gt;
The setup process for SOMA is extremely straightforward and is as simple as placing your shaders in your mod's \core\shaders\ directory, and your changes should be reflected in-game after loading your mod. Keep in mind that not all shader code is compiled on startup and is often conditional depending on what is being rendered in the current map, so some changes will not be immediately apparent! &lt;br /&gt;
&lt;br /&gt;
=== Amnesia: Rebirth and Amnesia: The Bunker ===&lt;br /&gt;
&lt;br /&gt;
For Amnesia: Rebirth and Amnesia: The Bunker, LoadShaderCache MUST be set to false in your mod's user settings configuration file for your mod's custom shaders to be reflected in-game. This will likely lead to slightly degraded performance, but this doesn't seem too noticeable on modern hardware. You will need to overwrite the base game's default_user_settings.cfg in the config folder to automatically set LoadShaderCache to false (for Rebirth) OR you will need to manually instruct users to set LoadShaderCache to false in their .cfg file (for Bunker). &lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' Make sure SaveShaderCache is set to false! This has much worse performance degradation and worse compatibility than LoadShaderCache, as it constantly regenerates the shadercache.xml file in _shadersource at runtime. This may be useful for directly editing shaders within your base install, but is unlikely to be useful for mods.&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=6833</id>
		<title>HPL3/Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=6833"/>
		<updated>2024-09-13T04:28:49Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started ==&lt;br /&gt;
* [[HPL3/Shaders/Shaders Overview|Shaders Overview]]&lt;br /&gt;
* [https://www.khronos.org/opengl/wiki/Getting_Started Getting Started With OpenGL]&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
* [[HPL3/Shaders/HPSL Shading Language|The HPSL Shading Language]]&lt;br /&gt;
* [[HPL3/Shaders/Overwriting Existing Shaders|Overwriting Existing Shaders]]&lt;br /&gt;
* [[HPL3/Shaders/Adding New Shaders|Adding New Shaders]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=6832</id>
		<title>HPL3/Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=6832"/>
		<updated>2024-09-12T22:19:30Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: /* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started ==&lt;br /&gt;
* [[HPL3/Shaders/Shaders Overview|Shaders Overview]]&lt;br /&gt;
* [https://www.khronos.org/opengl/wiki/Getting_Started Getting Started With OpenGL]&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
* [[HPL3/Shaders/HPSL Shading Language|The HPSL Shading Language]]&lt;br /&gt;
* [[HPL3/Shaders/Setting Up Mods to Use Shaders|Setting Up Mods to Use Shaders]]&lt;br /&gt;
* [[HPL3/Shaders/Overwriting Existing Shaders|Overwriting Existing Shaders]]&lt;br /&gt;
* [[HPL3/Shaders/Adding New Shaders|Adding New Shaders]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders/HPSL_Shading_Language&amp;diff=6831</id>
		<title>HPL3/Shaders/HPSL Shading Language</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders/HPSL_Shading_Language&amp;diff=6831"/>
		<updated>2024-09-12T22:17:54Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: Add HPSL documentation from https://frictionalgames.com/2014-04-tech-feature-hpsl-shading-language/&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;Introduction&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;HPL3 is our first engine to support both PC and consoles. To make it easy to support multiple platforms and multiple shading languages we have decided to use our own shading language called HPSL. Shader code written in HPSL goes through a shader parser to translate it to the language used by the hardware.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The shader written in HPSL is loaded into the engine at runtime, the code is then run through a preprocess parser that strips away any code that is not needed by the effect or material. After that the stripped code is translated to the language used by the hardware (GLSL #330 on PC and PSSL on the PS4) and then compiled.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;HPSL uses the same syntax as the scripting or engine code. HPSL is based on GLSL #330 but some of the declarations are closer to HLSL.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;wp-block-code&amp;quot;&amp;gt;// Example code&lt;br /&gt;
&lt;br /&gt;
@ifdef UseTexture&lt;br /&gt;
&lt;br /&gt;
uniform cTexture2D aColorMap : 0;&lt;br /&gt;
&lt;br /&gt;
@endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void main(in cVector4f px_vPosition,&lt;br /&gt;
&lt;br /&gt;
                in cVector4f px_vColor,&lt;br /&gt;
&lt;br /&gt;
                in cVector4f px_vTexCoord0,&lt;br /&gt;
&lt;br /&gt;
                out cVector4f out_vColor : 0)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
          cVector4f vColor = px_vColor;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@ifdef UseTexture&lt;br /&gt;
&lt;br /&gt;
                    vColor *= sample(aColorMap, px_vTexCoord0.xy);&lt;br /&gt;
&lt;br /&gt;
          @endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          out_vColor = vColor;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//Preproccess step&lt;br /&gt;
&lt;br /&gt;
void main(in cVector4f px_vPosition,&lt;br /&gt;
&lt;br /&gt;
                in cVector4f px_vColor,&lt;br /&gt;
&lt;br /&gt;
                in cVector4f px_vTexCoord0,&lt;br /&gt;
&lt;br /&gt;
                out cVector4f out_vColor : 0)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
          cVector4f vColor = px_vColor;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          out_vColor = vColor;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Translation step&lt;br /&gt;
&lt;br /&gt;
#version 330&lt;br /&gt;
&lt;br /&gt;
#extension GL_ARB_explicit_attrib_location : enable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
in vec4 px_vColor;&lt;br /&gt;
&lt;br /&gt;
in vec4 px_vTexCoord0;&lt;br /&gt;
&lt;br /&gt;
layout(location = 0) out vec4 out_vColor;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
          vec4 px_vPosition = gl_FragCoord;&lt;br /&gt;
&lt;br /&gt;
          bool px_bFrontFacing = gl_FrontFacing;&lt;br /&gt;
&lt;br /&gt;
          int px_lPrimitiveID = gl_PrimitiveID;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          vec4 vColor = px_vColor;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          out_vColor = vColor;&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;Preprocessing&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;All the shader code used in SOMA is handwritten. In order to keep all the relevant code at the same place and to be able to quickly optimize shaders HPL3 uses a preprocessing step. This has been used for our previous games as well. A preprocessor goes thorugh the code and removes large chunks that are not needed or used by the effect or material. The lighting shader used in SOMA contains code used by all the different light types. Changing a preprocess variable can change a light from a point light to a spotlight or can be used to enable shadow mapping. The preprocessor strips blocks of code that are not used, this increases performance since code that has no visual effects is removed completely. Another feature of the preprocess parser is the ability to change the value of a constant variable, this can be used to change the quality of an effect.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;wp-block-code&amp;quot;&amp;gt;// SSAO code&lt;br /&gt;
&lt;br /&gt;
for(float d = 0.0; d &amp;amp;lt; $kNumSamples; d+=4.0)&lt;br /&gt;
{&lt;br /&gt;
          // perform SSAO…&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The preprocessor makes it easy to do complex materials with multiple textures and shading properties while only performing the heavy computations for the materials that need it.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;Translation&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;After the preprocess strips the code it is ready to get translated. In the first step all the variable types and special functions are converted to the new language. Then the main entry function is created and all the input and output is bound to the correct semantics. In the last step the translated code is scanned for texture and buffers that get bound to the correct slot.&amp;amp;nbsp;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;Compilation&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The translated code is then compiled. If a compilation error occurred the translated code is printed to the log file along with the error message and corresponding row for easy debugging.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;Summary&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;In order to deliver the same visual experience to all platforms and to make development faster we decided on using our own shading language. The code is translated to the language used by the hardware and compiled at runtime. Supporting other shading languages in the future will be very easy since we only need to add another converter.&amp;amp;nbsp;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;HPSL translates to GLSL #330 which requires OpenGL 3.3 (DirectX 10 feature set). This means that SOMA will require a DirectX 10 or newer graphic card.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Modders will still be able to write shader code directly in GLSL if they chose to.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;HPSL Reference&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;Syntax&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;HPSL uses the same syntax used by the scripting language.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Variable Type&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Description&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;int&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;32 bit signed integer&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;uint&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;32 bit unsigned integer&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;bool&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Stores true or false&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;float&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;32 bit float&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;double&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;64 bit float&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cVectorXf&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Vector of floats&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cVectorXl&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Vector of signed integers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cVectorXu&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Vector of unsigned intergers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cMatrixXf&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Square float matrix&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cMatrixXxXf&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Non-square matrix (Ex cMatrix2x4f)&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cBuffer&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Container of multiple variables that get set by the CPU&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Texture Type&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Description&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cTexture1D&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Single dimension texture&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cTexture2D&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Standard 2D texture&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cTexture3D&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Volume texture&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cTextureCube&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Cubemap texture&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cTextureBuffer&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;A large single dimension texture used to store variables&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cTexture2DMS&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;A 2D render target with MSAA support&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cTextureXCmp&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;A shadow map texture used for comparison operations&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;cTextureXArray&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Array of cTextureX textures&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;A texture contains both the image and information about what happens when it is sampled. If you are used to OpenGL/GLSL then this is nothing new. DirectX uses a different system for storing this information. It uses a texture for storing the data and a separate sampler_state that controls filtering and clamping. Using the combined format makes it easy to convert to either GLSL or HLSL.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Textures need to be bound to a slot at compilation time. Binding is done by using the “:” semantic after the texture name.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;wp-block-code&amp;quot;&amp;gt;//bind diffuse map to slot 0&lt;br /&gt;
uniform cTexture2D aDiffuseMap : 0;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Variable Type Modifier&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Description&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;uniform&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;A variable or texture that is set by the CPU&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;in&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Read only input to a function&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;out&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Output of a function&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;inout&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Read and write input and output to a function&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;const&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;A constant value that must be initialized in the declaration and can’t be changed&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;Entry Point and Semantics&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The entry point of a shader program is the “void main” function. Input and output of the shader is defined as arguments to this function. The input to the vertex shader comes from the mesh that is rendered. This might be information like the position, color and uv mapping of a vertex. What the vertex shader outputs is user defined, it can be any kind of information that the pixel shader needs. The output of the vertex shader is what gets sent to the pixel shader as input. The variables are interpolated between the vertices of the triangle. The input of the pixel shader and the output of the vertex shader must be the same or else the shaders won’t work together. Finally the output of the pixel shader is what is shown on the screen. The pixel shader can output to a of maximum 4 different render targets at the same time.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Some of the input and output are System defined semantics. System Semantics are set or used by the hardware.&amp;amp;nbsp;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;System Semantic&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Description&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Type&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Shader Type&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;px_vPosition&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Vertex position output. Pixel shader input as screen position. This is required by all shaders&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4f&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Vertex (out), Pixel (in)&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;: X&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Output color slot, where X must be in the range 0-3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Pixel (out)&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_lVertexID&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Index of the current vertex&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;int&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Vertex (in)&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_lInstanceID&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Index of the current instance&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;int&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Vertex (in)&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;px_lPrimitiveID&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Index of the triangle this pixel belongs to&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;int&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Pixel (in)&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;px_bFrontFacing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Indicates if the pixel belongs to&amp;amp;nbsp; &amp;amp;nbsp;the front or back of the primitive&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;bool&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Pixel (in)&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Input to the vertex shader is user defined. HPL3 has a few user defined semantics that work with our mesh format.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Mesh Semantic&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Description&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Type&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_vPosition&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Position of the vertex&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4f&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_vTexCoord0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Primary UV coord&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4f&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_vTexCoord1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Secondary UV coord&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4f&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_vNormal&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;World space normal&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector3f&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_vTangent&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;World space tangent, w contains binormal direction&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4f&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_vColor&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Color&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4f&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_vBoneIndices&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Index of the bones used to modify this vertex&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4l&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;vtx_vBoneWeight&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Weight to multiply the bones with&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;cVector4f&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;It is possible to add more user defined semantics if needed:&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;wp-block-code&amp;quot;&amp;gt;//vertex shader&lt;br /&gt;
&lt;br /&gt;
uniform cMatrixf a_mtxModelViewProjection;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void main(in cVector4f vtx_vPosition,&lt;br /&gt;
&lt;br /&gt;
               in cVector4f vtx_vColor,&lt;br /&gt;
&lt;br /&gt;
               in cVector4f vtx_vTexCoord0,&lt;br /&gt;
&lt;br /&gt;
               out cVector4f px_vColor,&lt;br /&gt;
&lt;br /&gt;
               out cVector4f px_vTexCoord0,&lt;br /&gt;
&lt;br /&gt;
              out cVector4f px_vPosition)&lt;br /&gt;
&lt;br /&gt;
{                          &lt;br /&gt;
&lt;br /&gt;
          px_vPosition = mul(a_mtxModelViewProjection, vtx_vPosition);&lt;br /&gt;
&lt;br /&gt;
          px_vColor = vtx_vColor;&lt;br /&gt;
&lt;br /&gt;
                             px_vTexCoord0 = vtx_vTexCoord0;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//pixel shader&lt;br /&gt;
&lt;br /&gt;
uniform cTexture2D aColorMap : 0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void main(in cVector4f px_vPosition,&lt;br /&gt;
&lt;br /&gt;
               in cVector4f px_vColor,&lt;br /&gt;
&lt;br /&gt;
               in cVector4f px_vTexCoord0,&lt;br /&gt;
&lt;br /&gt;
               out cVector4f out_vColor : 0)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
         out_vColor = px_vColor * sample(aColorMap, px_vTexCoord0.xy);&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 class=&amp;quot;wp-block-heading&amp;quot;&amp;gt;Functions&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;HPSL is based on OpenGL 3.3 and GLSL version 330 and supports almost all of the&amp;amp;nbsp;[http://www.shaderific.com/glsl-functions/ GLSL arithmetic functions]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;There are some functions that are different from GLSL. This is to make it easier to support HLSL and PSSL.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Arithmetic Function&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Description&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;mul(x, y)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplies two matrices together (multiplying by using * not supported for matrices)&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;lerp(x, y, t)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Interpolates between two values&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Texture sampling use functions specific to the HPSL language.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Texture Function&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Description&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;sample(texture, uv)sample(texture, uv, offset)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Samples a texture at the specified uv coordinate. Can be used with an integet offset&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;sampleGather(texture, uv)sampleGather(texture, uv, offset)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Samples a texture but returns only the red component of each texel corner&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;sampleGrad(texture, uv, dx, dy)sampleGrad(texture, uv, dx, dy, offset)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Performs texture lookup with explicit gradients&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;sampleLod(texture, uv, lod)sampleLod(texture, uv, lod, offset)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Samples the texture at a specific mipmap level&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;sampleCmp(texture, uv, comp_value)sampleCmp(texture, uv, comp_value, offset)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Performs texture lookup and compares it with the comparison value and returns result&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;load(texture, position)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Gets the value of a texel at the integer position&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;getTextureSize(texture, lod)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Returns the width and height of the texture lod&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;getTextureLod(texture, uv)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Gets the lod that would get sampled if that uv coord is used&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;getTextureLevelCount&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Gets the number of MipMap levels&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;It is also possible to use language specific code directly. Some languages and graphic cards might have functions that are more optimized for those systems and then it might be a good idea to write code specific for that language.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;wp-block-code&amp;quot;&amp;gt;@ifdef Lang_GLSL&lt;br /&gt;
                  vec4 vModifier = vec4(lessThan(vValue, vLimit));&lt;br /&gt;
@else&lt;br /&gt;
                  cVector4f vModifier = step(vValue, vLimit);&lt;br /&gt;
@endif&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=6830</id>
		<title>HPL3/Shaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Shaders&amp;diff=6830"/>
		<updated>2024-09-12T21:15:03Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: Initial entry for HPL3/Shaders&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started ==&lt;br /&gt;
* [[HPL3/Shaders/Shaders Overview|Shaders Overview]]&lt;br /&gt;
* [https://www.khronos.org/opengl/wiki/Getting_Started#Using_OpenGL Getting Started With OpenGL]&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
* [[HPL3/Shaders/HPSL Shading Language|The HPSL Shading Language]]&lt;br /&gt;
* [[HPL3/Shaders/Setting Up Mods to Use Shaders|Setting Up Mods to Use Shaders]]&lt;br /&gt;
* [[HPL3/Shaders/Overwriting Existing Shaders|Overwriting Existing Shaders]]&lt;br /&gt;
* [[HPL3/Shaders/Adding New Shaders|Adding New Shaders]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Glossary&amp;diff=6244</id>
		<title>HPL3/SOMA/Glossary</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Glossary&amp;diff=6244"/>
		<updated>2021-09-15T06:52:12Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: Basic glossary setup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{constructionNotice|This page is currently undergoing major editing, as some information on this page is currently in the process of being formatted or re-written from scratch to achieve a higher standard of formatting and/or clarity.}}&lt;br /&gt;
&lt;br /&gt;
{{stub}}&lt;br /&gt;
'''Find explanations of various HPL3 terms here.'''&lt;br /&gt;
&lt;br /&gt;
{{CategoryHeader}}&lt;br /&gt;
{{CategoryNewcolumn}}&lt;br /&gt;
&lt;br /&gt;
== Modding ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Level Design ==&lt;br /&gt;
&lt;br /&gt;
=== General ===&lt;br /&gt;
&lt;br /&gt;
=== Areas ===&lt;br /&gt;
&lt;br /&gt;
=== Entities ===&lt;br /&gt;
&lt;br /&gt;
An entity is any object within the game world which possesses custom behavior, and can have custom code applied to it to perform specific functions.&lt;br /&gt;
&lt;br /&gt;
*'''Agents''' - Special entities typically used as Enemies/NPC's.&lt;br /&gt;
*'''Props''' - A type of entity which can be interacted with, either by the player or via script. The majority of entities are classified as props.&lt;br /&gt;
*'''Critters''' - Small or background creatures which do not warrant an agent script, usually equipped with simplistic AI.&lt;br /&gt;
&lt;br /&gt;
=== Lights ===&lt;br /&gt;
&lt;br /&gt;
=== Sounds ===&lt;br /&gt;
&lt;br /&gt;
=== Static Objects ===&lt;br /&gt;
&lt;br /&gt;
=== Terrain ===&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
*'''Static Object''' - An in-game object which is used only for physics collisions. They can't be influenced by scripts.&lt;br /&gt;
*'''Entity''' - An in-game object which allows interaction.&lt;br /&gt;
*'''Prop''' - A type of entity which the player can interact with, such as items with in-game physics interaction.&lt;br /&gt;
*'''Area''' - Invisible in-game cuboid which marks 3D space. Used as an input-output systems for the levels.&lt;br /&gt;
&lt;br /&gt;
== Modding ==&lt;br /&gt;
*'''Mod''' - Additional game content created by community members and fans.&lt;br /&gt;
*'''Custom Story''' - User-made content available from the game's main menu or from a designated launcher. They use all settings from the config files the game was started with, which limits what the creator can change (for example being forced to use the default lantern). This is the type of creation recommended for beginners.&lt;br /&gt;
*'''Mod Dependency''' - A mod which is being used by other mods as a source for content.&lt;br /&gt;
&lt;br /&gt;
== Level Design ==&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
*'''Script''' - Written code which determines what happens in a map. This includes events, puzzles, music, and more.&lt;br /&gt;
*'''User Module''' - Script files which always run in the background and usually define the behavior or core mechanics in the game.&lt;br /&gt;
*'''Handler''' - A synonym for a User Module.&lt;br /&gt;
&lt;br /&gt;
{{CategoryEnd}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:Entry pages]]&lt;br /&gt;
[[Category:English]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Glossary&amp;diff=6242</id>
		<title>HPL3/SOMA/Glossary</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Glossary&amp;diff=6242"/>
		<updated>2021-09-15T03:12:51Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: /* Edited prop description for clarity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
'''Find explanations of various HPL3 terms here.'''&lt;br /&gt;
&lt;br /&gt;
{{CategoryHeader}}&lt;br /&gt;
{{CategoryNewcolumn}}&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
*'''Static Object''' - An in-game object which is used only for physics collisions. They can't be influenced by scripts.&lt;br /&gt;
*'''Entity''' - An in-game object which allows interaction.&lt;br /&gt;
*'''Prop''' - A type of entity which the player can interact with, such as items with in-game physics interaction.&lt;br /&gt;
*'''Area''' - Invisible in-game cuboid which marks 3D space. Used as an input-output systems for the levels.&lt;br /&gt;
&lt;br /&gt;
== Modding ==&lt;br /&gt;
*'''Mod''' - Additional game content created by community members and fans.&lt;br /&gt;
*'''Custom Story''' - User-made content available from the game's main menu or from a designated launcher. They use all settings from the config files the game was started with, which limits what the creator can change (for example being forced to use the default lantern). This is the type of creation recommended for beginners.&lt;br /&gt;
*'''Mod Dependency''' - A mod which is being used by other mods as a source for content.&lt;br /&gt;
&lt;br /&gt;
== Level Design ==&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
*'''Script''' - Written code which determines what happens in a map. This includes events, puzzles, music, and more.&lt;br /&gt;
*'''User Module''' - Script files which always run in the background and usually define the behavior or core mechanics in the game.&lt;br /&gt;
*'''Handler''' - A synonym for a User Module.&lt;br /&gt;
&lt;br /&gt;
{{CategoryEnd}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:Entry pages]]&lt;br /&gt;
[[Category:English]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Amnesia:_Rebirth/Glossary&amp;diff=6199</id>
		<title>HPL3/Amnesia: Rebirth/Glossary</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Amnesia:_Rebirth/Glossary&amp;diff=6199"/>
		<updated>2021-01-11T04:57:34Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: /* Scripting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
'''Find explanations of various HPL3 terms here.'''&lt;br /&gt;
&lt;br /&gt;
{{CategoryHeader}}&lt;br /&gt;
{{CategoryNewcolumn}}&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
*'''Static Object''' - An in-game object which is used only for physics collisions. They can't be influenced by scripts.&lt;br /&gt;
*'''Entity''' - An in-game object which allows interaction.&lt;br /&gt;
*'''Prop''' - A type of entity which can be collected and added to the player's inventory.&lt;br /&gt;
*'''Area''' - Invisible in-game cuboid which marks 3D space. Used as an input-output systems for the levels.&lt;br /&gt;
&lt;br /&gt;
== Modding ==&lt;br /&gt;
*'''Mod''' - Additional game content created by community members and fans.&lt;br /&gt;
*'''Custom Story''' - User-made content available from the game's main menu or from a designated launcher. They use all settings from the config files the game was started with, which limits what the creator can change (for example being forced to use the default lantern). This is the type of creation recommended for beginners.&lt;br /&gt;
*'''Mod Dependency''' - A mod which is being used by other mods as a source for content.&lt;br /&gt;
&lt;br /&gt;
== Level Design ==&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
*'''Script''' - Written code which determines what happens in a map. This includes events, puzzles, music, and more.&lt;br /&gt;
*'''User Module''' - Script files which always run in the background and usually define the behavior or core mechanics in the game.&lt;br /&gt;
*'''Handler''' - A synonym for a User Module.&lt;br /&gt;
&lt;br /&gt;
{{CategoryEnd}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:Entry pages]]&lt;br /&gt;
[[Category:English]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Amnesia:_Rebirth/Glossary&amp;diff=6198</id>
		<title>HPL3/Amnesia: Rebirth/Glossary</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Amnesia:_Rebirth/Glossary&amp;diff=6198"/>
		<updated>2021-01-11T04:52:15Z</updated>

		<summary type="html">&lt;p&gt;Artificialparanoia: /* Scripting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
'''Find explanations of various HPL3 terms here.'''&lt;br /&gt;
&lt;br /&gt;
{{CategoryHeader}}&lt;br /&gt;
{{CategoryNewcolumn}}&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
*'''Static Object''' - An in-game object which is used only for physics collisions. They can't be influenced by scripts.&lt;br /&gt;
*'''Entity''' - An in-game object which allows interaction.&lt;br /&gt;
*'''Prop''' - A type of entity which can be collected and added to the player's inventory.&lt;br /&gt;
*'''Area''' - Invisible in-game cuboid which marks 3D space. Used as an input-output systems for the levels.&lt;br /&gt;
&lt;br /&gt;
== Modding ==&lt;br /&gt;
*'''Mod''' - Additional game content created by community members and fans.&lt;br /&gt;
*'''Custom Story''' - User-made content available from the game's main menu or from a designated launcher. They use all settings from the config files the game was started with, which limits what the creator can change (for example being forced to use the default lantern). This is the type of creation recommended for beginners.&lt;br /&gt;
*'''Mod Dependency''' - A mod which is being used by other mods as a source for content.&lt;br /&gt;
&lt;br /&gt;
== Level Design ==&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
*'''Script''' - Written code which determines what happens in a map. This includes events, puzzles, music, and more.&lt;br /&gt;
*'''User Module''' - Script files which always run in the background and usually define the behavior or core mechanics in the game.&lt;br /&gt;
*'''Handler''' - A synonym for a User Module.&lt;br /&gt;
*'''Interface''' - Script files that allow User Modules to be loaded by the engine and used in other scripts.&lt;br /&gt;
&lt;br /&gt;
{{CategoryEnd}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:Entry pages]]&lt;br /&gt;
[[Category:English]]&lt;/div&gt;</summary>
		<author><name>Artificialparanoia</name></author>
		
	</entry>
</feed>