lfnetwork.com mark read register faq members calendar

Thread: [Kotor I/II][WIP] ShaderOverride
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 04-30-2016, 10:05 PM   #1
Join Date: Apr 2016
Posts: 1
[Kotor I/II][WIP] ShaderOverride

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.

ShaderOverride 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[8];
    TEMP fogFactor;
    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.

Kotor I
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.

Last edited by HappyFunTimes; 05-03-2016 at 05:09 PM. Reason: Wrong forum.
HappyFunTimes is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Star Wars Gamer > Community > The Star Forge > Knights of the Old Republic series > Holowan Laboratories > [Kotor I/II][WIP] ShaderOverride

mod shaders dll speed fog

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -4. The time now is 12:33 AM.

Powered by vBulletin®
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.