The shader works per-texture. It can be used with regular map textures as well of course. If it's a graphic, the shader can be applied

If you are not familiar with using shaders, just check GLDEFS and add your own model textures. Basically, you need the shader file in the shaders directory, and a GLDEFS lump which assign any graphic to the shader. If you use it with normal map textures, you can just pass the name of the texture without the path or file extension. For other graphics, you need to pass the full path plus file extension.

(thanks to Kizoky)

Download:

simsun1.1.pk3

load TESTMAP to see some sample models in action.

Feel free to include this with any of your projects. If you would like to credit me and/or the others who provided help, that would be nice.

- Code: Select all • Expand view
`//SimSun Shader by Cherno`

const float pi = 3.14159265359;

vec4 Process(vec4 color)

{

vec3 lightDir = vec3(0.75,-1.0,-0.5);

//Doom map axis: x,z,y

//with 1.0-1.0,-1.0, the light comes from the north-west-west diagonally downwards, if north is towards the top of the (auto or editor)map

vec2 texCoord = gl_TexCoord[0].st;

vec3 l = lightDir;

vec3 n = normalize(vWorldNormal.xyz);

float angle = acos

(

(l.x*n.x + l.y*n.y + l.z * n.z)

/

(

(

sqrt

(

(l.x*l.x)+(l.y*l.y)+(l.z*l.z)

)

*

sqrt

(

(n.x*n.x) + (n.y*n.y) + (n.z*n.z)

)

)

)

);

float lightLevel = angle;

lightLevel /= pi;

//from here on out, you have a lightLevel between 0.0 and 1.0, depending on the angle of the surface relative to lightDir.

//a lightLevel of 0.5 results in the pixel at it would appear with no shading from SimSun at all.

//you can add calculations to the lightvalue if you wish to increase, decrease, or shoft the effect.

lightLevel += 0.25;//shifts the lightLevel so it gets slightly lighter, so there are less extremely dark areas

return getTexel(texCoord) * color * vec4(lightLevel,lightLevel,lightLevel,1.0);

}