• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ankhd

Rectangle Selection lasso Created in the GEOMETRY SHADER

3 posts in this topic

Im trying to create the selection lasso like the one in windows vista(where you hold the left mouse down and drag it and a rectangle is drawn.
Im doing it on the Geometry shader (4) I can create the quad based on a topleft and the width and height, this all works good.

Now I want to put a border around the rectangle, so as google is my friend I hit, hit it hard for 3 days so many pages of crap(lol). I was searching for bordes around quads, not many things came up at all(google hates me)so I sort of remembered doing a toon shader(good old frank, Thumbs up)many years a go and they where using edge detection so of I go looking for shit on silhouette edges and thing related, theres a few thing about it. found a open gl and a dx10 tut(the gl one was written 10 times better then the dx10, shame that. cant understand gl me)any how I ended up finding a post on here about some one wanting to do edge detection and that([url="http://www.gamedev.net/topic/434729-silhouette-drawing/"]http://www.gamedev.net/topic/434729-silhouette-drawing/[/url]). In that post was when I desided to go with 4 quads for the border line.
So I create my first quad in the geometry shader of the first pass works ok.
I then create a new geometry shader for pass2 using 16 returned vertices, this here is where it went all wrong(one of the border lines renders over the whole quad),
if I create 12 vertices this = 3 quads they render fine works great but its only 3 border lines, So I thought I had the quads dimensions wrong.
but when I commented out quad 2 and put quad 4(bottom border) back it worked with 3 border lines.
so back to google find [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb509660(v=vs.85).aspx"]here[/url] talks about RestartStrip so now I define the top and bottom quads in the geometry shader then I call RestartStrip I then repeat for the left and right side borders and put a nother RestartStrip after the last quad. Now it works fine[img]http://public.gamedev.net//public/style_emoticons/default/rolleyes.gif[/img] .

My question is how should I be using RestartStrip and in my code snipit below how could I improve the code any help would be appreciated.

[CODE]
//--------------------------------------------------------------------------------------
// GEOMETRY SHADER for pas 2 it creates 4 quads around the main rectangle
//of thickness 0.002f// looks about a pixel wide line
//--------------------------------------------------------------------------------------
[maxvertexcount(16)]
void GSPass2( point SPRITE_INPUT sprite[1], inout TriangleStream<PS_INPUT> triStream )
{
PS_INPUT v;
v.opacity = sprite[0].opacity;

//create sprite quad
//--------------------------------------------
//Top quad
//bottom left
v.p = float4(sprite[0].topLeft[0],sprite[0].topLeft[1]-gvThickness,0,1);
v.t = float2(0,1);
triStream.Append(v);

//top left
v.p = float4(sprite[0].topLeft[0],sprite[0].topLeft[1],0,1);
v.t = float2(0,0);
triStream.Append(v);
//bottom right
v.p = float4(sprite[0].topLeft[0]+sprite[0].dimensions[0],sprite[0].topLeft[1]-gvThickness,0,1);
v.t = float2(1,1);
triStream.Append(v);
//top right
v.p = float4(sprite[0].topLeft[0]+sprite[0].dimensions[0],sprite[0].topLeft[1],0,1);
v.t = float2(1,0);
triStream.Append(v);
//triStream.RestartStrip();
//////////end quad top
//quad Bottom
//bottom left
v.p = float4(sprite[0].topLeft[0],sprite[0].topLeft[1]-sprite[0].dimensions[1],0,1);
v.t = float2(0,1);
triStream.Append(v);

//top left
v.p = float4(sprite[0].topLeft[0],sprite[0].topLeft[1]-sprite[0].dimensions[1] + gvThickness,0,1);
v.t = float2(0,0);
triStream.Append(v);
//bottom right
v.p = float4(sprite[0].topLeft[0]+sprite[0].dimensions[0],sprite[0].topLeft[1]-sprite[0].dimensions[1],0,1);
v.t = float2(1,1);
triStream.Append(v);
//top right
v.p = float4(sprite[0].topLeft[0]+sprite[0].dimensions[0],sprite[0].topLeft[1]-sprite[0].dimensions[1] +gvThickness,0,1);
v.t = float2(1,0);
triStream.Append(v);
triStream.RestartStrip();
//////////end quad Bottom
//quad Left side
//bottom left
v.p = float4(sprite[0].topLeft[0],sprite[0].topLeft[1]-sprite[0].dimensions[1],0,1);
v.t = float2(0,1);
triStream.Append(v);

//top left
v.p = float4(sprite[0].topLeft[0],sprite[0].topLeft[1],0,1);
v.t = float2(0,0);
triStream.Append(v);
//bottom right
v.p = float4(sprite[0].topLeft[0]+ghThickness,sprite[0].topLeft[1]-sprite[0].dimensions[1],0,1);
v.t = float2(1,1);
triStream.Append(v);
//top right
v.p = float4(sprite[0].topLeft[0]+ghThickness,sprite[0].topLeft[1],0,1);
v.t = float2(1,0);
triStream.Append(v);
triStream.RestartStrip();
//////////end quad Left

//quad Right side
//bottom left
v.p = float4(sprite[0].topLeft[0] + sprite[0].dimensions[0]- ghThickness ,sprite[0].topLeft[1]-sprite[0].dimensions[1],0,1);
v.t = float2(0,1);
triStream.Append(v);

//top left
v.p = float4(sprite[0].topLeft[0] + sprite[0].dimensions[0] - ghThickness,sprite[0].topLeft[1],0,1);
v.t = float2(0,0);
triStream.Append(v);
//bottom right
v.p = float4(sprite[0].topLeft[0]+sprite[0].dimensions[0],sprite[0].topLeft[1]-sprite[0].dimensions[1],0,1);
v.t = float2(1,1);
triStream.Append(v);
//top right
v.p = float4(sprite[0].topLeft[0]+sprite[0].dimensions[0],sprite[0].topLeft[1],0,1);
v.t = float2(1,0);
triStream.Append(v);
triStream.RestartStrip();
//////////end quad Right

}//end
///////////////////////////////////////////////////////////////////////////////////////////////////////////

[/CODE]
1

Share this post


Link to post
Share on other sites
The output of a geometry shader is usually a triangle strip. You can use RestartStrip() to simulate triangle lists by calling RestartStrip() after appending each 3 vertices.
So if your example is working that's because you're correctly outputting triangle strips so there is no need to use RestartStrip() more than you do.

Another approach you could use is to just output 2 quads (4 triangles) one of them a little bigger than the other (to create the border) and add an attribute to the vertices so in the pixel shader you know if you're drawing the border and output a different color.

One improvement to do in my example would be to output the smaller quad first, so hopefully (I'm not sure if the first triangles will be drawn first but maybe someone else does, or you can simply test) when the second quad is drawn the early depth test will reject the pixels of the smaller quad and no overdraw occurs. Edited by TiagoCosta
0

Share this post


Link to post
Share on other sites
Thanks for the reply.
sorry I forgot to say that the first quad(full size one) will be transparent.
Im exporting 4 quads out from the geometry shader each time but 4 verts per quad 16vertices all up it work.
I was just woundering if the way I did it is slow it takes 2.2 ms for a 1440 * 900 full screen quad with a border
0

Share this post


Link to post
Share on other sites
Heres what it looks like when imported into a app with terrain [img]https://public.bay.livefilestore.com/y1pQbsmW78kEiq9YIrDBxQLAgHm-dJMuOG-BvYiZxGosO5aQRf9QZ1_zwx0IJsA5US0JQa2Q3kjePmg6HgTlpKQVQ/RectangleLasso.jpg?psid=1[/img]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0