Skewed Grid

Any aspects of level design for the Source engine.

Re: Skewed Grid

Postby Chopium on Fri Aug 06, 2010 9:50 pm

This shit is already heating up. Just leave it.

Would it be possible to like... rotate the grid? Like you could rotate it, everything should shift 15 degrees and you could work straight from there? I can't imagine how hard it was to make the left 4 dead 2 mall map in just a single 90 degree perspective.
User avatar
Chopium
Senior Member
Senior Member
 
Joined: Sun Apr 12, 2009 1:52 am
Location: Illinois

Re: Skewed Grid

Postby Shrinker on Fri Aug 06, 2010 10:01 pm

Athlete: Aha...

Choppy: Of course.

Thanks to coder0xff, I managed to make my orthogonal and skewed grid look much better, with less visual artifacts in the range that will usually be used in the editor. He deserves tight hugs and kisses for that. Next I'll have to look into making a circular grid.

Image
The original MB2 grid actually consisted of hundreds of lines that were displayed and translated according to the camera position. It was a pain to manage. This here now is based on a shader and allows a virtually unbounded amount of lines to be displayed at once. Thanks to a combined effort of me and coder0xff, this is a reasonably fast shader now, so the grid will probably only cause negligible rendering overhead, even if it looks really complex.
User avatar
Shrinker
Been Here A While
Been Here A While
 
Joined: Fri Nov 09, 2007 5:52 pm
Location: Germany

Re: Skewed Grid

Postby Athlete{UK} on Sat Aug 07, 2010 6:49 am

Shrinker wrote:Athlete: Aha...
.


I love that band.
User avatar
Athlete{UK}
Veteran
Veteran
 
Joined: Sun Nov 14, 2004 2:56 pm
Location: Stoke

Re: Skewed Grid

Postby Shrinker on Sat Aug 07, 2010 10:56 am

Okay, it turned out that the shader had really bad problems at angles that closed in to 45°. With coder0xff asleep, I could only experiment for hours and help myself today, because his approach yielded the same problems.
Image

At least from the rendering side, my skewed grid is now fully covered. Now I can _really_ look into the circular version, heh.

Yes, boring... for you, but not for nerds like us! :D
User avatar
Shrinker
Been Here A While
Been Here A While
 
Joined: Fri Nov 09, 2007 5:52 pm
Location: Germany

Re: Skewed Grid

Postby coder0xff on Tue Aug 10, 2010 1:53 pm

I heard this was all Photoshopped.
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: Skewed Grid

Postby Shrinker on Tue Aug 10, 2010 1:55 pm

GIMPe-- hey, why don't you just go away. :)
User avatar
Shrinker
Been Here A While
Been Here A While
 
Joined: Fri Nov 09, 2007 5:52 pm
Location: Germany

Re: Skewed Grid

Postby Shrinker on Wed Aug 11, 2010 1:04 pm

So I was like "OMG hey this works well enough now" and started messing with circular things. Of course it didn't work at all.
Image

What happened? I parametrized something wrong, and only later got the idea how to visualize the problem better -- distinguished by the slope of a line in space, the specified gap between lines applied to the x or y direction, which was of course not so good.
Image

Unfortunately, on the way, I noticed these typical artifacts from differentiating along the wrong line again... my grid lines became "fat" in the background if they were sloped. That felt great... time for a fourth approach? Yeah! After coder0xff assured me that my new approach made sense, I started implementing it, and the result is alright so far. Now I have based my shader on scan lines.
Image

So much work for that simple lines... ugh. But maybe I'll soon finally have my concentric circles built on top of this crap :D

Code: Select all
//lineOrigin in world units, nLineDirection normalized, lineWidth in pixels, gap in world units
bool lines(vec2 lineOrigin, vec2 nLineDirection, float lineWidth, vec2 gap)
{
  //determine whether the check shall be done on a horizontal (x) or vertical (y) scanline
  vec4
    a = gl_ModelViewProjectionMatrix*vec4(pointOnPlane               , 0, 1),
    b = gl_ModelViewProjectionMatrix*vec4(pointOnPlane+nLineDirection, 0, 1);
  vec2
    a2D = a.xy/a.z,
    b2D = b.xy/b.z,
    c2D = b2D -a2D;
  if (abs(c2D.x)/gl_ProjectionMatrix[0][0] >= abs(c2D.y))
  {
    //vertical (y) scanline

    //determine width of line intersecting scanline
    vec2 popDelta = dFdy(pointOnPlane);

    //pop2D is pointOnPlane in 2D screen space
    vec4 t = gl_ModelViewProjectionMatrix*vec4(pointOnPlane, 0, 1);
    float pop2Dy = t.y/t.z;
    //pop2D2 is for calculating the line width at the end
    t = gl_ModelViewProjectionMatrix*vec4(pointOnPlane+popDelta, 0, 1);
    float pop2D2y = t.y/t.z;

    //find intersection point of line going through pointOnPlane with the direction delta and the first line in question, starting at lineOrigin
    vec2 s = intersection(lineOrigin, nLineDirection, pointOnPlane, popDelta);

    //project gap_ to line by readin
    vec2 line = s-pointOnPlane;
    float lineLen = length(line)+length(popDelta)/2.;
    //gap between two lines = distance of intersection points with two neighboring lines, where one line was offset with gap
    float gapInLine = length(intersection(lineOrigin+gap, nLineDirection, pointOnPlane, popDelta)-s);
    //new line length*normalized line
    s = pointOnPlane+(lineLen-floor(lineLen/gapInLine)*gapInLine)*normalize(line);

    //t is used for the projection of the relocated intersection point
    t = gl_ModelViewProjectionMatrix*vec4(s, 0, 1);
    return abs(pop2Dy-t.y/t.z) < lineWidth*abs(pop2D2y-pop2Dy); //right side: pixel line width
  }
  else
  {
    //horizontal (x) scanline

    //determine width of line intersecting scanline
    vec2 popDelta = dFdx(pointOnPlane);

    //pop2D is pointOnPlane in 2D screen space
    vec4 t = gl_ModelViewProjectionMatrix*vec4(pointOnPlane, 0, 1);
    float pop2Dx = t.x/t.z;
    //pop2D2 is for calculating the line width at the end
    t = gl_ModelViewProjectionMatrix*vec4(pointOnPlane+popDelta, 0, 1);
    float pop2D2x = t.x/t.z;

    //find intersection point of line going through pointOnPlane with the direction delta and the first line in question, starting at lineOrigin
    vec2 s = intersection(lineOrigin, nLineDirection, pointOnPlane, popDelta);

    //project gap_ to line by readin
    vec2 line = s-pointOnPlane;
    float lineLen = length(line)+length(popDelta)/2.;
    //gap between two lines = distance of intersection points with two neighboring lines, where one line was offset with gap
    float gapInLine = length(intersection(lineOrigin+gap, nLineDirection, pointOnPlane, popDelta)-s);
    //new line length*normalized line
    s = pointOnPlane+(lineLen-floor(lineLen/gapInLine)*gapInLine)*normalize(line);

    //t is used for the projection of the relocated intersection point
    t = gl_ModelViewProjectionMatrix*vec4(s, 0, 1);
    return abs(pop2Dx-t.x/t.z) < lineWidth*abs(pop2D2x-pop2Dx); //right side: pixel line width
  }
}
Last edited by Shrinker on Thu Aug 12, 2010 8:35 am, edited 1 time in total.
User avatar
Shrinker
Been Here A While
Been Here A While
 
Joined: Fri Nov 09, 2007 5:52 pm
Location: Germany

Re: Skewed Grid

Postby Shrinker on Wed Aug 11, 2010 1:25 pm

Rejoice!
Image

Code: Select all
//circleOrigin in world units, lineWidth in pixels, gap in world units
bool circles(vec2 circleOrigin, float lineWidth, float gap)
{
  vec2 dn = normalize(pointOnPlane-circleOrigin);
  return lines(circleOrigin, vec2(dn.y, -dn.x), lineWidth, dn*gap);
}
User avatar
Shrinker
Been Here A While
Been Here A While
 
Joined: Fri Nov 09, 2007 5:52 pm
Location: Germany

Re: Skewed Grid

Postby Shrinker on Thu Aug 12, 2010 10:44 am

After another day of fine-tuning...

This is my proposal for a circular grid :)
Image

The count of the center lines and the delta of the circle radii should be changeable then...
(center lines *= or /= 10, circle radii *= or /= 2, as with the regular grid line gaps)
User avatar
Shrinker
Been Here A While
Been Here A While
 
Joined: Fri Nov 09, 2007 5:52 pm
Location: Germany

Re: Skewed Grid

Postby MNM on Thu Aug 12, 2010 11:15 am

Make a square on that :lol:
When in doubt, VDC.
User avatar
MNM
Pheropod
Pheropod
 
Joined: Thu Oct 02, 2008 6:13 pm
Location: Norway

Re: Skewed Grid

Postby Shrinker on Thu Aug 12, 2010 1:52 pm

Image
User avatar
Shrinker
Been Here A While
Been Here A While
 
Joined: Fri Nov 09, 2007 5:52 pm
Location: Germany

Re: Skewed Grid

Postby MNM on Thu Aug 12, 2010 1:59 pm

That's not even on the grid D:
When in doubt, VDC.
User avatar
MNM
Pheropod
Pheropod
 
Joined: Thu Oct 02, 2008 6:13 pm
Location: Norway

Re: Skewed Grid

Postby city14 on Thu Aug 12, 2010 3:16 pm

I think an overlay of a rough square grid like you had in the first picture of the circle grid where I rejoiced, would be a good idea.

Otherwise, just have the option to toggle the different grids you want.
coder0xff wrote:I wonder if Gabe ever lies in bed at night, thinking about all the fat jokes, and just cries himself to sleep, wiping his tears away with one-thousand dollar bills.
User avatar
city14
Pheropod
Pheropod
 
Joined: Tue Jun 16, 2009 8:35 pm
Location: Troutdale, Oregon

Re: Skewed Grid

Postby Shrinker on Thu Aug 12, 2010 5:09 pm

MNM: That is as much on the grid as you are on your chair. :P
city14: No, what are you thinking? Of course there will only be circular grids in future, with no option to use the traditional skewed grids. I'll fork a study that proves that circular grids are superior for all kinds of editing :P
User avatar
Shrinker
Been Here A While
Been Here A While
 
Joined: Fri Nov 09, 2007 5:52 pm
Location: Germany

Re: Skewed Grid

Postby city14 on Thu Aug 12, 2010 5:11 pm

I forgot that ease of use is a thing of the past!

Valve has done wonders with their products in this field, YOU CAN TOO!

lolololol
coder0xff wrote:I wonder if Gabe ever lies in bed at night, thinking about all the fat jokes, and just cries himself to sleep, wiping his tears away with one-thousand dollar bills.
User avatar
city14
Pheropod
Pheropod
 
Joined: Tue Jun 16, 2009 8:35 pm
Location: Troutdale, Oregon
PreviousNext

Return to Hammer Editor Help

Who is online

Users browsing this forum: Bing [Bot]

cron