OK, I figured it out - for full conversions at least.
What I did is this: I modified the GLSL fragment program and the colorconv_sepia.tga file in such a way so that the original sepia effect for the main game can remain unchanged, while allowing for a different effect to be created for a full conversion, just by providing an alternate colorconv_sepia.tga file (withouth overwriting the one in textures\effects\ folder; and without messing whit the GLSL shader any further).
This is the trick - I exploited the fact that the shader uses a 1D color conversion map. So I've doubled the length of the map from 256 to 512, and have split it into two logical regions (still one image file, just different purpose to the left and right side of the image). The left half of the image remains what it was - it's the input color map for the shader. The entire right side should be a single color - any gray shade. The shade of the right side decides if you want to use the original algorithm that came with amnesia (which is based on color conversion) [pure black], or the new one I made (which is based on color replacement, allowing for greyscale and true-sepia images) [pure white], or if you want to mix the two [the shade of gray determines the amount].
This allows for a range of effects, but, of course, once you find the one you like, you can only use that single one for your full conversion, in place of the original sepia effect (without affecting the main game).
IMPORTANT: Make sure to
backup any file before replacing it!
Here's the updated shader (just the main() function, download below). Notice that I've improved the code by using GLSL built in functions like dot() and mix():
void main()
{
vec3 vDiffuseColor = texture2DRect(diffuseMap, gl_TexCoord[0].xy).xyz;
// This is the original sepia shader used for amnesia - color conversion shader
vec3 vOutput = vec3(texture1D(convMap, vDiffuseColor.x * 0.5).x,
texture1D(convMap, vDiffuseColor.y * 0.5).y,
texture1D(convMap, vDiffuseColor.z * 0.5).z);
float third = 1.0 / 3.0;
float gray = dot(vDiffuseColor, vec3(third, third, third)); // Grayscale value
// This is the color-replacement shader
vec3 vReplacementColor = texture1D(convMap, gray * 0.5).xyz;
// the right part of the gradient determines the blend amount between the two shader algorithms; black = 0% , white = 100%
float blendAmmount = texture1D(convMap, 0.9).x;
vOutput = mix(vOutput, vReplacementColor, blendAmmount);
@ifdef UseFadeAlpha
gl_FragColor.xyz = vOutput*afFadeAlpha + vDiffuseColor*(1-afFadeAlpha);
@else
gl_FragColor.xyz = vOutput;
@endif
}
I've also attached several gradient maps for the effects you can see in the image below. To help you find your way around, I used a naming convention for the tga files:
colorconv_sepia.
shaderName.
conversion.tga
colorconv_sepia.
shaderName.
replacement.tga
If it ends with "conversion", the game will use the original shader, if it ends with "replacement", the game will use my shader ("conversion" stands for original color-conversion filter, "replacement" for my color-replacement filter.).
Here's what the effects look like (expand to see - it's a somewhat large image):
(
large image)
The gradient files are attached below (effect.zip). For the image above, "conversion" filters are on the left, and "replacement" filters are on the right. The files used are, row by row:
gray
gray1
invert
invert1
predator
sepia
Here's how to create the gradient images:
Installation:
(I'll be refering to
"redist" folder - this is for the retail edition; for Steam edition, the appropriate folder is
"amnesia the dark descent")
IMPORTANT: Make sure to
backup any file before replacing it!
The archive modified_posteffect_color_conv_tex_frag.zip contains the modified shader program. Go to redist\core\shaders, and create a backup of
posteffect_color_conv_tex_frag.glsl, then extract the corresponding file from the archive to the same folder, replacing the original.
Now go to redist\textures\effects, and backup the
colorconv_sepia.tga file. Download modified_colorconv_sepia.zip, and extract the image file to replace the original one.
That's it.
The effects.zip archive contains colorconv tga-s I used to create the screenshots above. Create some separate folder and extract them. To use one as an effect, you must rename it to
colorconv_sepia.tga, and make sure that your full conversion loads it before anything else (by specifying its path as the first entry in the FC's resources.cfg).
------
To temporarily test the shader
without creating a full conversion, create some folder inside the redist dir, for example "shader_test"; extract a file of your choice from effects.zip to that folder, and rename it to
colorconv_sepia.tga.
Then, from redist folder open resources.cfg in Notepad++ (or just Notepad), and add this line at the top, just under the <Resources> tag (create a backup first):
<Directory Path="/shader_test" AddSubDirs="true" />
Then run the main game or a custom story and invoke the sepia effect (say by calling the FadeSepiaColorTo() script function), to see the new effect.
When done, simply delete
colorconv_sepia.tga from shader_test folder (you can also restore resources.cfg).
Don't forget to do this, or the main game will stay affected.
NOTE: For the main game not to be affected, it is important that the custom
colorconv_sepia.tga file from your full conversion is located in a folder specifically used by the full conversion, so that the main resources file (of the main game)
does not reference it! So if you didn't restore resources.cfg, don't put the FC's color conversion gradient into the shader_test folder. Create a different, special-purpose folder for your FC.
------
Using With Full Conversions
When you full conversion is finished and ready, people who download it must also have their shader and gradient map files replaced. This is OK, since their main Amnesia gameplay experience will not be affected, but I recommend for the installation procedure of the full conversion to create a backup for each of the files. This can be done with a BAT file (batch script).
How To Specify a Separate Resource File for a Full Conversion?
You should read the tutorials others made about full conversions, but here's how to do this specific task:
- Assuming your FC config files are stored in redist/fc_config, and that the FC game is launched by Launcher.exe fc_config/main_init.cfg,
- Open main_init.cfg;
- Under <ConfigFiles
- find the Resources attribute, and set the appropriate path, like this:
- Resources = "fc_config/resources.cfg".
- Finally, in FC's resources.cfg add the path to the custom gradient file (colorconv_sepia.tga), as explained above.
Once again:
IMPORTANT: Make sure to
backup any file before replacing it!