Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Rendering large sprites using OpenGL?  (Read 3620 times)
0 Members and 1 Guest are viewing this topic.
Offline avm1979
« Posted 2011-04-08 19:47:16 »

I'm drawing the graphics for a nebula by mixing a bunch of tiles randomly taken from a texture atlas.  The tiles overlap by a lot, and that combined with randomly picking them helps make it look less tiled.

Here is a screenshot of what it looks like - the nebula is the purplish strip going diagonally across the screen.

The trouble is that each tile is rather large (around 512x512, though the texture area mapped to it is about half that and gets scaled up).  With the overlap, to have the nebula fill a screen's worth of space requires drawing about 2-3 times the area of the screen worth of tiles. So I might draw 40 512x512 tiles on a nebula-heavy screen.

This ends up being really slow on lower-end graphics cards, with a vast majority of the time spent in Display.update(). (I'm using LWJGL)

Is there something I can do to speed this up? What's the likely culprit? (fillrate?)


Another related question - what would be a fast way to draw the background image? It's just putting pixels on the screen, there's no stretching/blending/etc going on. Right now I'm just drawing it as a textured quad, with GL_BLEND disabled.

Offline kevglass

« JGO Spiffy Duke »


Medals: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2011-04-08 19:50:44 »

Quote
So I might draw 40 512x512 tiles on a nebula-heavy screen

Can you explain a bit more about why that is, seems like you'd still only have to fill a screen at any given time. Are you overdrawing or something?

Kev

Offline avm1979
« Reply #2 - Posted 2011-04-08 19:55:19 »

Can you explain a bit more about why that is, seems like you'd still only have to fill a screen at any given time. Are you overdrawing or something?

The nebula graphic on each tile extends about halfway onto adjacent tiles - covering about 4x the area of a single tile.  Since there are 16 choices of graphic for each tile (from the texture atlas), the are lots of visual combinations for the different overlaps. The goal is to avoid a tiled appearance.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 849
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2011-04-08 19:56:43 »

Quote
What's the likely culprit? (fillrate?)
Yes!

If you render it once to the framebuffer every frame, you can just as well render it once to a texture and render that texture every frame.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Offline lhkbob

JGO Knight


Medals: 32



« Reply #4 - Posted 2011-04-08 20:02:43 »

40 quads should be easy to draw even on crap hardware.  More likely its fill rate or texture memory that's causing a bottleneck on the low-end systems (or general crappy performance if most of the time is in Display.update()).

Try drawing one quad across the entire screen with blending and see if you get the same amount of bad performance. Or shrink your viewport to something ridiculous like 5x5 pixels (but do your regular drawing calls).  If you see greatly improved performance on the small screen, you're probably fill limited.


Riven made a post while I was writing this, but I'm adding it anyways.

Offline avm1979
« Reply #5 - Posted 2011-04-08 20:13:18 »

Quote
What's the likely culprit? (fillrate?)
Yes!

If you render it once to the framebuffer every frame, you can just as well render it once to a texture and render that texture every frame.

Hmm. These get pretty large, though - a map can be say 20,000 pixels wide, and a nebula can cover most of it. Pre-rendering 1024x1024 chunks to a texture as the view moves around might just work though, even if it's going to be a bit hairy.


Thing is, the frame rate plummets even if a relatively small amount of nebula is on-screen - so I suspect even optimizing it to a point where it's rendering the area only once would only still get me part of the way there. Is there another angle to take in trying to speed this up?

Offline avm1979
« Reply #6 - Posted 2011-04-08 20:16:35 »

Try drawing one quad across the entire screen with blending and see if you get the same amount of bad performance. Or shrink your viewport to something ridiculous like 5x5 pixels (but do your regular drawing calls).  If you see greatly improved performance on the small screen, you're probably fill limited.

Thanks, I'll try that - though the nebula rendering is already so close to drawing one big quad as to be almost the same Smiley

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 81
Projects: 15


★★★★★


« Reply #7 - Posted 2011-04-08 20:18:12 »

Is there another angle to take in trying to speed this up?

You could use a lower res texture on slower hardware like a 256x256 (or 128x128) instead of 512x512.

Obvious question but are you using mipmapping?
Offline avm1979
« Reply #8 - Posted 2011-04-08 20:30:59 »

Is there another angle to take in trying to speed this up?

You could use a lower res texture on slower hardware like a 256x256 (or 128x128) instead of 512x512.

So that would actually help even though the area drawn is the same? Cool, didn't know that.


Obvious question but are you using mipmapping?

Nope. I don't quite know how it works, but even if I was using it, wouldn't it only take effect if the texture was being scaled down, not up? (In my case, the texture is smaller than the quads it gets mapped to)

Offline Nate

« JGO Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #9 - Posted 2011-04-08 20:46:09 »

You could use a lower res texture on slower hardware like a 256x256 (or 128x128) instead of 512x512.

So that would actually help even though the area drawn is the same?
AFAIK, it won't help if you are fillrate limited, as the same number of texel lookups are done and the same number of pixels are drawn.

Are you using linear to scale up the nebula pieces? I think you could reduce the number of texel lookups by a factor of 4 with nearest. Drawing the pieces to a texture could also provide this benefit by avoiding scaling.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline avm1979
« Reply #10 - Posted 2011-04-12 15:19:36 »

Quick update - I tried rendering 10 partially transparent screen-sized quads on top of everything else, and it didn't affect the frame rate at all.  So seems like fillrate is out.  Looks like I have some more investigating to do.  Thanks for all the ideas, guys!  I'll post back here after I get this all sorted out.

Offline JESTERRRRRR

Senior Devvie


Medals: 12
Exp: 1 year



« Reply #11 - Posted 2011-04-13 23:13:36 »

I have nothing to contribute help wise, but, nice ship and nebula!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (17 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (86 views)
2014-12-05 12:39:02

SHC (97 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!