nacmacneedle

Member
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

101 Neutral

About nacmacneedle

  • Rank
    Newbie
  1. Outlines with vertex shader

    Uhm. Well. I... uh... fixed it but of course it was not such a stupid thing... *whistles innocently* ;-) *lol* Thanks... I wouln't have spotted that in a hundred years. I must say, the workaround looked better, at least with a simple box...
  2. Hi community! I'm currently writing a cel shaded game. The cel shading itself works quite well, but drawing outlines seems to be a bit harder. At the moment I'm solving this by loading my model two times, enlarging one copy by 1% and then rendering the back faces black to get the outline. But since the game is aimed at handheld devices and I have to do deformation operations which will scale O(n^2 ) or even worse I can't take the costs of doubling the vertices. I wanted to render the back faces black and let the vertex shader enlarge them in direction of their surface normals, which I read is a common method. So I created the following vertex shader and combined it with a fragment shader which returns only black. attribute vec4 a_position; // given by model loaderattribute vec3 a_normal; // uniform mat4 u_matrix; // combined matrixuniform float u_thickness; // outline thicknessvoid main() { vec4 position = a_position + normalize( vec4( a_normal, 0.0 ) ) * u_thickness; gl_Position = u_matrix * a_position;} When I only use the outline shader I get the black back faces, but when I draw the cel shaded model over the outlines, it has exactly the same size, so I don't get any outlines. Why doesn't my shader resize the back faces? Attached is (hopefully) a screenshot of the rendered with the cel-shader and the outline-shader next to each other as well and with my current workaround which produces the desired effect. I apologize for the formatting... somehow my line breaks seem to get removed upon posting?