[University Work] Black Outlines?
#1
Posted 03 February 2012 - 09:21 AM
If you saw my realistic ball rolling topic, you'll have realised I'm my final year of university work and am HAVING to make a 3D demo/game.
Well I was looking at the models today and I realised they look very rough around the edges and then I realised it's because I'm used to my graphics having black outlines
Now I've done searching for how to do black outlining, tried it and failed.
So now I ask for help from GMC. Does anyone know of a fool-proof way to get black outlining on models?
#2
Posted 03 February 2012 - 09:36 AM
There are two ways of doing it, the good way and the bad way. The good way is to protrude all vertices a certain amount (depending on how thick an outline you want) in the direction of their normal vector, invert the drawing order of the vertices, and draw the model in black. This creates a nice looking dynamic outline.
The bad method, which only works properly with symmetrical, origin-centered models, is scaling them with negative values less than -1 in all dimensions and drawing them in black. This is what I do in my jam5 game Duality, but there it isn't a problem, as all my models are basic primitives.
Edited by TheSnidr, 03 February 2012 - 10:23 AM.
#3
Posted 03 February 2012 - 09:50 AM
How do you make your models?
There are two ways of doing it, the good way and the bad way. The good way is to protrude all vertices a certain amount (depending on how thick an outline you want) in the direction of their normal vector, invert the drawing order of the triangles, and draw the model in black. This creates a nice looking dynamic outline.
The bad method, which only works properly with symmetrical, origin-centered models, is scaling them with negative values less than -1 in all dimensions and drawing them in black. This is what I do in my jam5 game Duality, but there it isn't a problem, as all my models are basic primitives.
For my project, I am drawing the models entirely out of basic shapes and polygons.
#4
Posted 03 February 2012 - 10:03 AM
#5
Posted 03 February 2012 - 10:09 AM
#6
Posted 03 February 2012 - 05:02 PM
Step 1: Set color to black (Black texture works nicely if you're using vertex colors and texture coordinates)Ok go through the bad way step by step as if you're talking to an idiot. Because when it comes to 3D, I am an idiot.
Step 2:
outline_scale = 1.1; // Anything more than 1 works. Smaller value = thinner outline. d3d_transformation_set_scaling(-outline_scale, outline_scale, outline_scale); // Scale around whichever axis is symmetrical (I think what I posted will work fine for GM primitives)Step 3: Draw your primitive.
#7
Posted 03 February 2012 - 05:37 PM
Step 1: Set color to black (Black texture works nicely if you're using vertex colors and texture coordinates)
Ok go through the bad way step by step as if you're talking to an idiot. Because when it comes to 3D, I am an idiot.
Step 2:outline_scale = 1.1; // Anything more than 1 works. Smaller value = thinner outline. [b]d3d_transformation_set_scaling(-outline_scale, outline_scale, outline_scale); // Scale around whichever axis is symmetrical (I think what I posted will work fine for GM primitives)[/b]Step 3: Draw your primitive.
Where and what do I set to black?
I'm guess the transforumation_set is before during the transformation phase?
#8
Posted 06 February 2012 - 01:36 AM
draw_set_color(c_black)
And yes, the d3d transform bit refers to the scaling.
#9
Posted 06 February 2012 - 01:30 PM
You haven't exactly answered my questions.Do
draw_set_color(c_black)
And yes, the d3d transform bit refers to the scaling.
Does anyone have an example they've done so I can have a look because I am at a loss here.
#11
Posted 07 February 2012 - 01:24 PM
Here you go
http://www.host-a.net/u/playway/Simple%20outlines.gm81
I've used the tutorial and it's throwing it back in my face. It completely covers the ball in black.
EDIT: Haha nevermind. Found the problem. Though the culling cuts off parts of the model I do want. Why does it do that?
Edited by King Tetiro, 07 February 2012 - 01:25 PM.
#12
Posted 07 February 2012 - 01:30 PM
http://en.wikipedia....ck-face_culling
So you're gonna have to fix your models I'm afraid
#13
Posted 07 February 2012 - 01:37 PM
Because the order of the vertices is defined in the wrong order. Vertices must be defined in a clockwise order to draw correctly when using culling. Read more here:
http://en.wikipedia.org/wiki/Back-face_culling
So you're gonna have to fix your models I'm afraid
EDIT: I've updated most of the model. I'm doing the primitives. How do you do black outlining for primitives?
Edited by King Tetiro, 07 February 2012 - 01:48 PM.
#14
Posted 07 February 2012 - 08:34 PM
I've never attempted this myself, but I imagine you'll need vector math, or more specifically, cross product, to find the normal of each triangle, then for each vertex you'll need to get the average of the normal vectors of all adjacent triangles, and protrude the vertex in the resulting direction.
In other words, that method is hard. If I were you I'd search around a little and see if anyone else have done this before, which would save you a lot of trouble
If I misunderstood and you're simply using the basic primitives, the answer is still in the example I posted
Edited by TheSnidr, 07 February 2012 - 08:36 PM.
#16
Posted 08 February 2012 - 12:58 AM
#17
Posted 08 February 2012 - 10:11 AM
#18
Posted 08 February 2012 - 10:33 AM
How do you switch between the two? This is all I can find in the manual:Not sure if you are able to do this in gamemaker 8.1 - (I only use 8.0), but just change the culling from backface (CCW culling) to frontface (CW culling). This will not draw any triangles with their fronts shown to you. Draw the model slightly larger and with frontface culling (outline) then draw it again, but smaller with backface culling.
d3d_set_culling(cull) Indicates to start backface culling (true) or stop backface culling (false).
#19
Posted 08 February 2012 - 06:05 PM
I think I'll just try to avoid using primitives then. Cheers for the help guys!
I assume you are referring to triangles, lines, or points. Unfortunately "primitives" is used to describe everything that GM can draw. I hear it used for triangles. I hear it used for cylinders. I hear it used for spheres. I hear it used for walls and floors. It's not descriptive. Stop assuming it is.
Triangle meshes can be extruded, but care must be taken when handling edges and corners, or your finished outline hull will have gaps. A simple solution is to extrude vertices, not individual triangles (May have trouble with sharp corners, but otherwise fine). You can find the vector to extrude along by calculating the vertex normal. This is typically the average of the normals of all triangles that share that vertex.
#20
Posted 09 February 2012 - 05:58 AM
As I said I use GM8.0 which does not support this. I'm not sure if GM8.1 supports it, but if that's a quote from the manual then it does not support frontface culling. If you use GMAPI and the DX SDK, all you need to do is something like this.How do you switch between the two? This is all I can find in the manual:
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);//Backface culling (Counter Clockwise) device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);//Frontface culling (Clockwise) device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);//No culling (None)Pick one and set the culling mode.
Edited by brett14, 09 February 2012 - 05:59 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











