View Full Version : Advanced light-based shading

06-20-2008, 10:59 AM
Right, so far I've made a skin, and have applied a shader to one of it's textures. However, what I'd now like to do is apply an additional layer which is blended with the lighting on the skin.

It's a difficult one to explain, so let's suppose:
- My player model is a cube (not really!)
- I have a texture which is a simple gradient, applied to the whole cube.

What I want therefore is:
- The darker the side of the cube is, the MORE the texture is visible
- The lighter the side of the cube is, the more faded the texture is

Thus, if the texture is being applied to a 100% dark area of the cube, then that area of the cube will have the full texture applied to it.
If the texture is being applied to a 100% light side on the cube, then the texture should be completely washed-out/white.
If the texture is being applied to a 50% light side of the cube then the texture will appear partly washed out (50% white, 50% texture).

Is this even possible? The concept behind this is that shaded areas of the texture should appear darker when in shadow, but should disappear completely when in the light. Is there any way to gain access to the lighting being applied to a texture at any given point when it is applied to a player-model, or is this completely impossible?

Another way to think of it is that what I want is for the texture to have more contrast the darker it is, and less contrast the lighter it is. Can I do this with a shader?

Also, a slight aside but not really deserving it's own topic; is it possible to apply a texture such that it is dependent on the user's view-point? E.g so I can apply a texture more to an area the user is looking directly at?

06-20-2008, 11:05 AM
If you create a specular map with less contrast you can probably achieve this with a simple specularity shader. You can find these shader types in many many mods if you don't know off-hand how to create one.

06-20-2008, 11:36 AM
Do you know any mods off-hand I should search for?

06-20-2008, 12:07 PM
If you search on JK3Files for 'specularity' in the description, I had a tendency to specifically mention when a mod had it. I don't claim to know a ton about JO, but the shader systems should be the same between the two games. If not you'll need to go track yourself down a seasoned JO modder.

06-20-2008, 04:48 PM
Thanks your help! I found a couple examples and it seems to be working as expected, though needs a load of tweaking yet, cheers!

06-21-2008, 08:42 AM
Okay, one other question; what is the best way to do bump-mapping on a character? I think I investigated before attempting to get a normal-mapping style effect on a skin and didn't have much luck; is there any recommended way to make a surface on a skin look "bumpy" even when light is applied to it?

I don't require proper bump-mapping; as I understand it this is only really possible on map surfaces and even then isn't perfect; however, I'd like to create an effect as close as possible.

06-21-2008, 02:28 PM
You can't do bump-mapping in JK2 or JK3. The engine does not support it.

If you want to do "fake" bump mapping you'll have to texture it onto the model and the spec map and hope it looks half decent.

06-22-2008, 12:18 PM
Hmm, in that case; is there at least a way to make parts of a texture always appear dark? E.g - so that colour appears as texture_colour * light, so black areas that are fully lit will remain black?

Or is this something shaders can't control and will need some trickery with a layer that ignores lighting (in the same way you would do a "full-bright" glow effect)? I'd rather avoid an extra layer as a rule, since I prefer not to have more than four stages in a shader, especially on a player model.