About OpenGL Support

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
lunasspecto
Regular
Posts: 160
Joined: Wed Aug 22, 2007 7:59 pm
Location: USA: New York City (school) and Massachusetts (home)
Contact:

About OpenGL Support

#1 Post by lunasspecto » Tue Feb 16, 2010 9:56 pm

I think OpenGL is supposed to fix the aspect-ratio problem.
from the virtual desk of Kazuki Mishima

User avatar
jack_norton
Lemma-Class Veteran
Posts: 3984
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: Question for people with completed games

#2 Post by jack_norton » Wed Feb 17, 2010 3:53 am

openGL will only accelerate reandering but won't fix any aspect ratio :)
Most games nowadays are full 3d so there isn't that problem anymore... but for us doing 2d games, is still there.
follow me on Image Image Image Image
computer games

bobbk
Regular
Posts: 46
Joined: Tue Feb 09, 2010 8:36 am
Contact:

Re: Question for people with completed games

#3 Post by bobbk » Wed Feb 17, 2010 4:52 am

I didn't realize the engine was going to use OpenGL in a future release

I read someone thought that would allow Ren'Py to use multiple resolutions, I don't know if that's true.

User avatar
number473
Regular
Posts: 195
Joined: Tue Dec 15, 2009 4:20 am
Projects: The Duke's Daughter
Location: Cape Town
Contact:

Re: Question for people with completed games

#4 Post by number473 » Wed Feb 17, 2010 8:51 am

It would make it possible, but that isn't necessarily generally true. If you used the OpenGL and had vector graphics, you could easily resize them to whatever screen size you wanted. But in the case of bitmap images, that advantage doesn't exist. You would have to resize the images anyway, or have separate image files for each resolution. That makes for big files, or poor image quality in the case of scaling images up. Since most VNs use bitmap images, i don't know...
Mental weather report: Cloudy with a possibility of brain storms.

User avatar
Sin
Veteran
Posts: 298
Joined: Thu Oct 18, 2007 3:43 am
Contact:

Re: Question for people with completed games

#5 Post by Sin » Wed Feb 17, 2010 9:40 am

number473 wrote:It would make it possible, but that isn't necessarily generally true. If you used the OpenGL and had vector graphics, you could easily resize them to whatever screen size you wanted. But in the case of bitmap images, that advantage doesn't exist. You would have to resize the images anyway, or have separate image files for each resolution. That makes for big files, or poor image quality in the case of scaling images up. Since most VNs use bitmap images, i don't know...
Actually, this is not true. The limitations of software rendering(2D) does not apply to hardware rendering(3D). They work entirely different. You are not painting/bliting bitmaps.

OpenGL and DirectX enables you to use a single image and have it automatically scale to whatever dimensions you need. Of course if the source image is small, it will look blurry when scaled up, but if the source image is larger it will look sharp in higher resolutions as well as lower resolutions (since it has more source pixels to work with).

The aspect ratio issue does not exist in 3D rendering either. 3D rendering is resolution agnostic by default. PyTom would have to specifically implement the limitation for that to be the case.

I'm curious to see how PyTom will implement OpenGL, as someone who's experienced the amount of work it requires first hand. (And I used DirectX, which arguably is the simpler API of the two)

User avatar
PyTom
Ren'Py Creator
Posts: 15269
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: About OpenGL Support

#6 Post by PyTom » Wed Feb 17, 2010 11:51 am

Since people might be a little confused (or in the case of Eric, interested) in Ren'Py's upcoming OpenGL support, I thought I would open up this thread to answer questions and manage expectations.

Ren'Py is a 2D engine, like most visual novel engines. What GL Ren'Py will do is to shift a lot of the image processing to the system's GPU, which is capable of performing massively parallel processing of image-like data. Although I haven't totally characterized the result yet, preliminary tests show this giving a large speedup in the image primitives Ren'Py uses: blitting, blending, and image-controlled blending.

There are a couple of things I'm planning on doing with that speed. The first has to do with fullscreen modes. Right now, we command the system's screen to switch from it's native resolution to one close to what the game's resolution is. This is what causes the aspect ratio problems. Improved drawing speed will allow the screen to stay in its native resolution, while Ren'Py takes care of drawing letterbox bars as necessary.

Similarly, this will allow us to adjust the size of the game in windowed mode. While the game will have a default size, the user will be able to resize the window, and Ren'Py will begin using the new size, with letterboxes added as appropriate.

GL Ren'Py will also command a sync-to-vblank. This should prevent the tearing that is possible when moving something horizontally on the screen.

For the first release of GL Ren'Py, this is pretty much it for "new" features. Things should look nicer, but in a relatively subtle way. While, in the future, I might add some support for perspective transforms, that would come later. For

I'm not sure where this talk about vector graphics is coming from. I don't have any plans to support SVG or similar in Ren'Py. While I could be convinced to change that if there was a relatively small and open SVG library that's easy to use, I'm not sure this is a GL-related issue.


Technical side of things:

GL Ren'Py is based on texture grids. When we load an image, it gets chopped up into a series of textures. Each side of a texture is either 512, 256, 128, or 64 pixels wide (the textures do not have to be square: 64x512 is a valid size). Textures include a 1 pixel border when they overlap with other textures.

The maximum image size is limited only by available ram, rather than by GPU limits.

Texture grids can be drawn to the screen using one of three operations. Each operation takes a transformation matrix to use, and can also adjust the alpha of the result.) The three operations are:

- Blit: draw a single texgrid normally.
- Blend: draw two texgrids, using a blending factor to interpolate between them.
- Imageblend: draws two texgrids, using a blending factor to interpolated betwen them. A third image is used to adjust the blending factor.

Depending on the system, these can be implemented either using the fixed-function pipeline or fragment shaders (pixel shaders in DX).

There is (or rather is going it be) render to texgrid support, which is needed (along with the blends) for doing Dissolve and ImageDissolve properly. Simply doing an alpha-blit won't cut it.

There are a couple of things I'm still not sure about the design of, yet.

- I'd like to be able to do native-resolution text.
- I'm not sure if mipmapping is necessary.

I want to experiment with both before committing to a design.

Graphics Programming isn't my specialty. (Languages is.) So this has been quite the learning experience for me, and if people want to point out flaws in my design, please do.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Wintermoon
Miko-Class Veteran
Posts: 701
Joined: Sat May 26, 2007 3:41 pm
Contact:

Re: About OpenGL Support

#7 Post by Wintermoon » Wed Feb 17, 2010 5:14 pm

PyTom wrote:This is what causes the aspect ratio problems. Improved drawing speed will allow the screen to stay in its native resolution, while Ren'Py takes care of drawing letterbox bars as necessary.

Similarly, this will allow us to adjust the size of the game in windowed mode.
Yuck.

I realize that this is just my subjective and somewhat controversial opinion, but it's one I feel very strongly about. OpenGL texture stretching look like shit. Bilinear filtering even more so than simple point scaling.

User avatar
PyTom
Ren'Py Creator
Posts: 15269
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: About OpenGL Support

#8 Post by PyTom » Wed Feb 17, 2010 5:38 pm

Does it look worse than the hardware scaling found in video cards, which gets the aspect ratio wrong quite often?

Ideally, there would be no scaling, but that doesn't seem to be practical anymore.

(I'll note that the scaling algorithm implemented in Ren'Py right now is the OpenGL one.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Wintermoon
Miko-Class Veteran
Posts: 701
Joined: Sat May 26, 2007 3:41 pm
Contact:

Re: About OpenGL Support

#9 Post by Wintermoon » Wed Feb 17, 2010 7:45 pm

PyTom wrote:Does it look worse than the hardware scaling found in video cards, which gets the aspect ratio wrong quite often?
No, but it looks worse than switching resolution on a CRT monitor, and it look looks worse than black bars on an LCD monitor.

To me, the ideal setup would be:
  • Screen resolution set to the smallest aspect-ratio-preserving native resolution of the monitor that is equal or larger than the logical resolution of the game.
  • Viewport set to the largest integer multiple of the logical screen resolution that is smaller or equal to the screen resolution.
  • If the viewport is larger than the logical resolution of the game, use point scaling (GL_NEAREST) to scale up from the logical resolution to the viewport.
  • If the viewport is smaller than the screen resolution, add a black border.
  • When running in a window, only allow the window to be resized to integer multiples of the original resolution.
Alternately, create the game for a ridiculously huge logical resolution and downscale. OpenGL downscaling looks much better than OpenGL upscaling. The downside of this approach is huge graphics files, but since graphics generally take only a small fraction of the game download size, this may be an acceptable compromise.

A third alternative would be to perform scaling in software, before handing it over to OpenGL, or in a very clever pixel shader within OpenGL. This at least allows you to use a better scaling algorithm than bilinear filtering.
Last edited by Wintermoon on Wed Feb 17, 2010 9:51 pm, edited 1 time in total.

Counter Arts
Miko-Class Veteran
Posts: 645
Joined: Fri Dec 16, 2005 5:21 pm
Completed: Fading Hearts, Infinite Game Works
Projects: Don't Save the World
Organization: Sakura River
Location: Canada
Contact:

Re: About OpenGL Support

#10 Post by Counter Arts » Wed Feb 17, 2010 8:29 pm

Just checking but is GL Ren'py implemented so that particles get the great performance increase from using a graphics card?
Fading Hearts is RELEASED
http://www.sakurariver.ca

User avatar
PyTom
Ren'Py Creator
Posts: 15269
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: About OpenGL Support

#11 Post by PyTom » Wed Feb 17, 2010 10:25 pm

Hm...

There's no particle-specific acceleration, but our current particle framework will benefit from the improved rendering performance. I may consider adding a new particle system (or integrating something like lepton), but that would be another step.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
number473
Regular
Posts: 195
Joined: Tue Dec 15, 2009 4:20 am
Projects: The Duke's Daughter
Location: Cape Town
Contact:

Re: About OpenGL Support

#12 Post by number473 » Thu Feb 18, 2010 4:13 am

I think I may have totally misunderstood >_<

I also didn't necessarily mean that you would necessarily have Ren'Py handle svg as a built in feature or something - I was just supposing that once it had OpenGL support it would be possible to set that up. I did a google search when the subject first came up (for svg OpenGl converters or stuff like that) and I got some hits, but I'll admit that I didn't research it very thoroughly.
Mental weather report: Cloudy with a possibility of brain storms.

User avatar
ksotaku100
Regular
Posts: 65
Joined: Fri Dec 25, 2009 8:12 pm
Contact:

Re: About OpenGL Support

#13 Post by ksotaku100 » Wed Mar 03, 2010 10:19 pm

Will it also enable the capability to record using a game recorder, like Fraps, for example?

User avatar
PyTom
Ren'Py Creator
Posts: 15269
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: About OpenGL Support

#14 Post by PyTom » Wed Mar 03, 2010 10:31 pm

Yes. But AFAIK that ability already exists. Certainly, I was able to make Ren'Py screencasts and post them on youtube.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users