I'm trying to determine those areas of the level map / game world consisting of a specific material (asphalt roads) in my pixel shader.
Since the engine (xRay) of the game I'm modding (Stalker 1) does not provide some material index or look-up function, I have to find some way to distinguish asphalt from other material by it's texture only.
Texture bump maps does not seem to be useful here, mainly because they already have a designated use (i.e. to create bumps in the vertex shader) disallowing to manipulate them without major side effects.
So I tried using the color mixture of the texture as fake material indicator, e.g. increase the blue channel and check the blue amount / color ratio in the pixel shader to determine whether it's asphalt or not. Works quite well in theory, but in reality I'm experiencing heavy issues making my algorithm somewhat impotent:
1. The lighting changes the resulting color in game. I can partially correct this with the hemisphere (sun light) color which I can access from the shaders but since there are different light sources working in combination I have troubles to revert the resulting color back to the texture color.
2. The bump maps change the way the texture is rendered, thus changing it's resulting color as well (because of different lighting influence), so even if I found a solution to point 1, it would probably fail in combination with the bump maps.
3. In cases where I succeeded in determining the area of the color in question, I didn't manage to adjust that areas color back to the original color that the texture had prior to edition (i.e. to decrease the blue channel correctly again). I don't know what's the problem here, but e.g. doubling the blue amount in photoshop and then decreasing it by 50% again in game does not result in the original color.
3. Maybe there are other influences changing the color in game which I didn't check yet.
After some heavy research and trial-and-error session I managed to tweak my color recognition algorithm to serve at minimum as approximation pattern, but that's still not precise enough and error-prone, so I can't use it as a solid recognition of materials by texture color.
So I'm kinda stuck here, and I need some hints / advice / recommendations on what I could try to yet improve my algorithm, so some other way to determine the material without having access to it's index or properties from the pixel shader.
Any ideas here? Am I on the completely wrong path?