Topic: Outline via glsl?
Hi - Just to get it right (inside my brain..)
If i want normal rendering and also a black outline (like in toon shading but without the toon shading)...
Then i need to write a glsl shader and add them in the blender export panel under materials/maritas/customshader in the vertex/fragment shader slots?
Found goggling the following code, haven't been able to test it yet, but could it work?
for Vertex:
varying vec3 normal, lightDir;
varying vec2 texCoord;
void main()
{
vec4 ecPos;
ecPos = vec4(gl_ModelViewMatrix * gl_Vertex);
lightDir = normalize(vec3(gl_LightSource[0].position) - ecPos.xyz);
normal = normalize(gl_NormalMatrix * gl_Normal);
texCoord = vec2(gl_MultiTexCoord0);
gl_Position = ftransform();
}
for Fragment:
varying vec3 normal, lightDir;
varying vec2 texCoord;
uniform sampler2D texture;
void main()
{
float intensity;
vec3 n;
vec4 _color;
n = normalize(normal);
intensity = dot(lightDir, n);
if (intensity > 0.98)
_color = vec4(1.0,1.0,1.0,1.0);
else if (intensity > 0.5)
_color = vec4(0.8,0.8,0.8,1.0);
else if (intensity > 0.35)
_color = vec4(0.4,0.4,0.4,1.0);
else
_color = vec4(0.0,0.0,0.0,1.0);
gl_FragColor = _color * texture2D(texture, texCoord);
}
Last edited by Kralle (2011-03-03 10:42:51)