• 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
-XM-

Dynamic 2D Shadows Optimization

4 posts in this topic

Hi guys, I've implemented this shadow sample into my engine: http://www.catalinzima.com/2013/01/dynamic-2d-shadows-for-windows-phone-7/ Everything was working fine until I ran my game on the Xbox 360.... I get 30 FPS when my game runs at 1920 x 1080, but if I run it at 1280 x 720 or below it runs at 60 FPS. If you run the stand alone sample the same thing happens.

 

I don't know exactly why the resolution makes a difference, but I did some further profiling and found that this call gets called for every hull:

 

game.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2);

 

When I draw just one hull my FPS goes back up to 60, so for the last week or so I've been trying to add all of the verts and indices to a list and then make this call one time after iterating through the hulls. The problem is that after doing this the shadows are drawing really whacky... I'm not sure where I'm going wrong, this should be a simple fix but it seems I'm overlooking something small that is screwing me up.

 

Any help would be appreciated! I attached the modified sample to this post.

 

My changes are in ConvexHull's DrawShadows:

            int currentIndex = startingIndex;
            int svCount = 0;
            while (svCount != shadowVertexCount * 2)
            {
                shadowHullIndices.Add(currentIndex + shadowHullVertices.Count); //Added this
                Vector3 vertexPos = vertices[currentIndex].Position + new Vector3(position, 0);

                //one vertex on the hull
                shadowVertices[svCount] = new VertexPositionColor();
                shadowVertices[svCount].Color = Color.Transparent;
                shadowVertices[svCount].Position = vertexPos;

                //one extruded by the light direction
                shadowVertices[svCount + 1] = new VertexPositionColor();
                shadowVertices[svCount + 1].Color = Color.Transparent;
                Vector3 L2P = vertexPos - new Vector3(lightSource.Position, 0);
                L2P.Normalize();
                shadowVertices[svCount + 1].Position = new Vector3(lightSource.Position, 0) + L2P * 9000;

                svCount += 2;
                currentIndex = (currentIndex + 1) % primitiveCount;
            }


            drawingEffect.World = Matrix.Identity;
            drawingEffect.CurrentTechnique.Passes[0].Apply();

            for (int i = 0; i < shadowVertexCount * 2 - 2; i++) //Added this
                shadowHullVertices.Add(shadowVertices[i]);
//Original call:
//game.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2); 

and in Game1's DrawLightmap:

                foreach (ConvexHull ch in objects)
                {
                    //draw shadow
                    ch.DrawShadows(light, shadowHullVertices, shadowHullIndices); //Added. For now, pass the lists in and add the appropriate verts and indices.
                }

                //Added this:
                GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, shadowHullVertices.ToArray(), 0, shadowHullVertices.Count, shadowHullIndices.ToArray(), 0, shadowHullIndices.Count / 3);

 



 

Edited by -XM-
0

Share this post


Link to post
Share on other sites

So it's hard to tell from the code provided, but generally speaking if your frame rate goes down when you increase resolution, you're most likely fill-rate bound. Try cutting stuff out of your pixel shader and see if you can get a better framerate. It's just a guess though.

 

Good luck!

0

Share this post


Link to post
Share on other sites

Coalescing all your draw calls into one can help save you CPU time. If that's your bottle neck, that can increase your framerate. (Rouhgly how many "hulls" do you have?).

 

Like the other poster said though, you may be fill-rate bound (or possibly texture fetch bound). So you need to reduce your resolution, or find some way to draw less (or speed up your pixel shader)..

 

1920 x 1080 can be a lot for the Xbox. I don't think any AAA title runs at that resolution - they're usually 720p or less.

 

Also the jump from 30 FPS to 60 FPS is because you have vsync on. The difference might actually be very small (like 59 FPS to 61 FPS). If you're doing perf measurements, you should set IsFixedTimeStep to false, and SynchronizeWithVerticalRetrace on the GraphicsDeviceManager to false (in your game's constructor).

0

Share this post


Link to post
Share on other sites

Also as a side post. The hardware scaler for the Xbox from 720p to 1080p is nearly identical to actual 1080p. Most people can't tell the difference.

0

Share this post


Link to post
Share on other sites

The max number of hulls I ever draw is about 15.... but I think you guys are right, I just needed to lower my resolution. I didn't understand that most AAA games cheat the 1080p on consoles... I did some research and the only example I saw of a game truly running at 1920 x 1080 was Virtua Tennis 3 (not sure if that's really true). I guess I shouldn't assume so much from the back of the boxes...

 

Thanks for sending me in the right direction guys!

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