Is it possible to prepare a generic bump map shader to be used by any 3D game?
I found this bump map shader:
Shader "Custom/BumpedEnvironment" {
Properties {
_myDiffuse ("Diffuse Texture", 2D) = "white" {}
_myBump ("Bump Texture", 2D) = "bump" {}
_mySlider ("Bump Amount", Range(0,10)) = 1
_myBright ("Brightness", Range(0,10)) = 1
_myCube ("Cube Map", CUBE) = "white" {}
}
SubShader {
CGPROGRAM
#pragma surface surf Lambert
sampler2D _myDiffuse;
sampler2D _myBump;
half _mySlider;
half _myBright;
samplerCUBE _myCube;
struct Input {
float2 uv_myDiffuse;
float2 uv_myBump;
float3 worldRefl; INTERNAL_DATA // <- THIS IS VERY IMPORTANT
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_myDiffuse, IN.uv_myDiffuse).rgb;
o.Normal = UnpackNormal(tex2D(_myBump, IN.uv_myBump)) * _myBright;
o.Normal *= float3(_mySlider, _mySlider, 1);
o.Emission = texCUBE(_myCube, WorldReflectionVector(IN, o.Normal)).rgb;
}
ENDCG
}
FallBack "Diffuse"
}
I want to let Arx Libertatis use that shader, but I would like also to let other 3D games that do not have it, to be able to use it too (see OpenSourcedGames.
Is the only way to adapt that shader inside the game engine, so the game engine itself send it to the GPU?
Or is it possible to compile a generic bump map shader like the above, load it into the GPU (while or before the game start to run) and force the GPU to apply that shader to specific 3D games? It would be like injecting a shader into a game I guess.
If it is possible, any tips how should I start doing it? the easiest way if possible, as I am very new to shaders.
I am not restricting the answer to Linux. If the answer can also work on Linux, it would be better though.
I just found about ENB, but it doesn't work on Linux. There is this that could work on Linux (there is a Linux instruction folder inside it; any newer version may have it too) but it requires Wine, and therefore a Windows compiled game binary, and I develop projects on Linux, compiled for Linux.
So, What I mean is, unless there is some equivalent to ENB that works on Linux (may be Mac) too, my main request/question is how can I do it myself instead of using some ready tool.