Edit: RTFM'ing, I realize that I've posted this in the wrong spot. Could a moderator please move it to the Taris Upper City Emporium?
After running into the fog issue with the current steam version of Kotor II, I decided to go and make an OpenGL shim and try to fix it. This is the product of that.
is a shim DLL (Dynamic Link Library). It
- is derived from gShaderReplacer by psycholns copyright (c) 2015
- is devived from the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by Frank Thilo and RSA Data Security, Inc. copyright (c) 1991-2
- makes use of 7-Zip copyright (c) 1999-2010 Igor Pavlov in compilation
A shim DLL is a DLL that is designed to look exactly like another DLL, intercepting function call and/or performing additional functions. In this case, it is designed to
- - dump the shader assembly code to "shaders_original"
- - try to name them something human readable from "shader_ident.txt"
- - check "shaders_override" for a modified shader and load it instead
- - provide fog display attributes to the fragment shaders in environment variable 8
- - provide viewport dimensions to the fragment shaders in environment variable 10
- - include a "fp_speedblur.txt" to override the default speed blur effect. (Kotor II only)
I am satisfied with what I wanted to do with this project, but am posting it here in the hopes the community finds it useful. It isn't exhaustively tested (I'm still playing through Kotor II, and didn't use it in Kotor I), so if anyone finds any bugs, please mention them.
The project is hosted on Github, licensed under the MIT license in the spirit of the projects it is derived from:
While mentioned in the readme, to use the fog fix you will want to
- - put the opengl32.dll file in the Kotor II folder
- - copy all fp*.txt files from "shaders_original" to "shaders_override"
- - add this code before the last "MOV result.color, r0" statement
# == manual interpolation for fog ==
PARAM p = program.env;
MUL fogFactor.x, p.x, fragment.fogcoord.x;
EX2_SAT fogFactor.x, -fogFactor.x;
MUL fogFactor.y, p.y, fragment.fogcoord.x;
MUL fogFactor.y, fogFactor.y, fogFactor.y;
EX2_SAT fogFactor.y, -fogFactor.y;
MAD_SAT fogFactor.z, p.z, fragment.fogcoord.x, p.w;
MUL fogFactor.x, fogFactor.y, fogFactor.x;
MUL fogFactor.x, fogFactor.z, fogFactor.x;
LRP r0.rgb, fogFactor.x, r0, state.fog.color;
- - if you want to use the speed blur change, put the "fp_speedblur.txt" in "shaders_override" (Kotor II only)
- - at this point you can change any shaders you have interest in and put them in the override folder.
This appears to work with Kotor I, but there are no fragment shaders that the shim recognizes. I'm not sure what can be done purely in the vertex shaders.