nint22 / dwarfcraft

Automatically exported from code.google.com/p/dwarfcraft
Other
0 stars 0 forks source link

Better edge generation using GLSL to generate pixelated edges? #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Use GLSL, much like cell-shading, to fill out the edges of world models!

Original issue reported on code.google.com by nin...@gmail.com on 18 Nov 2011 at 5:22

GoogleCodeExporter commented 9 years ago
Note to self: don't forget OSX has the build in shader preview.

Original comment by nin...@gmail.com on 22 Nov 2011 at 8:08

GoogleCodeExporter commented 9 years ago
One approach is to do pixel vector vs. view vector (and dot product them with a 
comparison):

// Vertex Shader:
varying vec3 normal;
varying vec2 vTexCoord;

void main()
{
    normal = gl_NormalMatrix * gl_Normal;
    gl_Position = ftransform();

}

// Fragment shader:

varying vec3 normal;
varying vec2 vTexCoord;

void main()
{
    float intensity;
    vec4 color;

    // Apply an edge detection (new to this..)
    // Need world pos!!!
    vec3 n = normalize(normal);
    vec3 viewDirection = normalize(vec3(5, 0, 5));
    if(dot(viewDirection, n) < 0.1)
        gl_FragColor = vec4(0, 0, 0, 1); // black

}

Original comment by nin...@gmail.com on 23 Nov 2011 at 12:08

GoogleCodeExporter commented 9 years ago
Current approaches:
Use a sobel filter: http://www.blitzbasic.com/Community/posts.php?topic=85263
Minecraft-mod approach: http://pastebin.com/KmD72cx8

Original comment by nin...@gmail.com on 23 Nov 2011 at 1:02

GoogleCodeExporter commented 9 years ago
glsl contour lines is another approach

Original comment by nin...@gmail.com on 23 Nov 2011 at 3:07

GoogleCodeExporter commented 9 years ago
Creating shader class to wrap all future shaders

Original comment by nin...@gmail.com on 23 Nov 2011 at 4:58

GoogleCodeExporter commented 9 years ago
Done!

Original comment by nin...@gmail.com on 24 Nov 2011 at 12:13