3d in renpy

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
MadMinstrel
Newbie
Posts: 4
Joined: Mon Mar 11, 2013 5:12 am
Contact:

3d in renpy

#1 Post by MadMinstrel »

So, assuming I'm willing to get down and dirty with the renpy source, are there any real roadblocks I should know about before trying to implement Persona 4 style 3d scenes? Renpy seems to have most of what I'd want for my project except 3d.

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: 3d in renpy

#2 Post by SundownKid »

AFAIK, Ren'py cannot show anything in 3D. But, if you do manage to get it working, that would be cool - it would be great if you could use Ren'py as a frontend for a 3D visual novel. I've been wanting to look into 3D but it seems that you'd have to have some kind of extensive plugin just to make a visual novel with Unity or the like.

MadMinstrel
Newbie
Posts: 4
Joined: Mon Mar 11, 2013 5:12 am
Contact:

Re: 3d in renpy

#3 Post by MadMinstrel »

Well, don't get excited just yet. I'm still just assessing the viability. I wrote a 3d engine in C++/Opengl a while ago so I'm considering whether to port that to play nice with renpy, or to code my custom VN bits. The VN bits are actually harder to do than I imagined they would be, and Renpy has the advantage of actually having been battle tested by many users. And python is so much nicer to develop with than C++. In any case, though I'm happy to share the source, I just need it for myself so it'd be rough to use, nothing like Unity.

If I'm not mistaken renpy is already running in Opengl, so it shouldn't be that hard. It'd need geometry loaders, modelview transforms, some shaders and an animation system. That last bit is the hard part, because I haven't actually done that before. I hoping to sidestep the issue using a pc2 or alembic type system for the more complex animations, but it's clear skeletal animation will be necessary too. After that one could consider pathfinding, raycasting/mouse picking, physics, etc, but I don't actually need that for my project so somebody else would probably have to do that.

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: 3d in renpy

#4 Post by SundownKid »

I doubt anything like that is necessary for visual novels, or even RPGs, since you are just viewing the characters and environments. I could see being able to navigate around a 3D world as useful, though not in real time (more like a dungeon crawler).

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: 3d in renpy

#5 Post by DaFool »

Other way around would be better, I think... something that interprets Ren'Py code either in Unity3D or HTML5. I have so many cutscenes programmed in ATL I couldn't imagine having to redo them all over again just to use an engine more suited for realtime gameply.

ThisIsNoName
Veteran
Posts: 311
Joined: Fri Feb 10, 2012 10:15 pm
Contact:

Re: 3d in renpy

#6 Post by ThisIsNoName »

MadMinstrel wrote: If I'm not mistaken renpy is already running in Opengl, so it shouldn't be that hard. It'd need geometry loaders, modelview transforms, some shaders and an animation system.
If I remember right, PyTom said that the OpenGL was just used to display 2D graphics, and wasn't able to show 3d. There's been a couple people who've been able to create Doom-style scenes through software rendering, but I'm not sure if it would be fast enough to display in real time.

MadMinstrel
Newbie
Posts: 4
Joined: Mon Mar 11, 2013 5:12 am
Contact:

Re: 3d in renpy

#7 Post by MadMinstrel »

Hi. Unless we're talking about the ancient fixed function pipeline, Opengl doesn't really care if you're displaying 2d or 3d graphics, you're filling triangles with colors in any case. All the calculations that make stuff look 3d actually take place in the vertex shaders and are the responsibility of the programmer. PyTom probably meant that he simply hasn't written the necessary code to do it, not that it's impossible per se.

User avatar
muggy8
Regular
Posts: 29
Joined: Sat Mar 02, 2013 12:49 am
Contact:

Re: 3d in renpy

#8 Post by muggy8 »

Well the thing about trying to run 3D in ren.py is that ren.py operates of python which is an interpreted language. the problem with that is the machine needs time to translate each line into machine code then run the code for each and every single line and happens every time in a loop of any sort. an to run a game at say 30 fps your looking at 1/30th of a second for each frame. when in a compiled language like C++ or Java you can hit speeds like that no problem because the program is compiled already and you dont have to recompile each line.

but i'm not sure how accurate this is but here's something to look at: http://benchmarksgame.alioth.debian.org ... =gpp&box=1

from the looks of the table at the bottom. python is up to 100 times slower than compiled C++ and lets say your 3D application is only able to hit 30 fps and we take the avarage of that so lets say your only 50x slower so your python game is running at.... 0.6 fps.

enjoy :D

AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: 3d in renpy

#9 Post by AxemRed »

Fixed function OpenGL doesn't care about the difference between 2D and 3D either. Shaders are problematic since they're not universally supported, and even if they're supported (possibly through software emulation) may be too slow.

The speed of Python is entirely irrelevant since all the heavy lifting is handled by C code and the GPU.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: 3d in renpy

#10 Post by PyTom »

The thing with OpenGL is that, while it doesn't care about 2D vs 3D, it does care how you render things. Right now, Ren'Py assumes you're doing 2D rendering. For example, it doesn't set up a depth buffer, and it uses an orthographic projection, so there's no perspective.

That being said, this is something we can change, and that likely will change over time.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4084
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: 3d in renpy

#11 Post by jack_norton »

3d and shaders would be interesting to me for adding nice effects (also, additive alpha blending would be great).
I have no interest in full 3d right now since it's really expensive to make a game with it and the results are in most cases worse looking than a good 2d hand-painted art :)
follow me on Image Image Image
computer games

MadMinstrel
Newbie
Posts: 4
Joined: Mon Mar 11, 2013 5:12 am
Contact:

Re: 3d in renpy

#12 Post by MadMinstrel »

PyTom wrote:The thing with OpenGL is that, while it doesn't care about 2D vs 3D, it does care how you render things. Right now, Ren'Py assumes you're doing 2D rendering. For example, it doesn't set up a depth buffer, and it uses an orthographic projection, so there's no perspective.
Well, a depth buffer is going to be necessary, but the idea is to render the scene to texture and treat it just like any other background image on the VN side. That way less of the current renpy code will need changes. Alternatively we can just call the renpy bits just before the next frame. In any case, perspective vs orthographic just means the renpy-generated verts simply go through a different transform matrix (or don't, if you're currently drawing them directly in ndc space) - it won't be a problem.

TrickWithAKnife
Eileen-Class Veteran
Posts: 1261
Joined: Fri Mar 16, 2012 11:38 am
Projects: Rika
Organization: Solo (for now)
IRC Nick: Trick
Location: Tokyo, Japan
Contact:

Re: 3d in renpy

#13 Post by TrickWithAKnife »

Personally I don't feel a great need for proper 3D, but I could see how 3D elements could be useful.
For example, being able to show semi-3D buildings in the background, and when the scene moves it shows that it is 3D, or having 2D images that can be turned in different angles. The scrolling text effect from Star Wars could be another example of how 3D could be used in a simplier form.

Look at it this way - if you create the functionality, people will find a way to use it.
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.

If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: 3d in renpy

#14 Post by Ryue »

muggy8 wrote:Well the thing about trying to run 3D in ren.py is that ren.py operates of python which is an interpreted language. the problem with that is the machine needs time to translate each line into machine code then run the code for each and every single line and happens every time in a loop of any sort. an to run a game at say 30 fps your looking at 1/30th of a second for each frame. when in a compiled language like C++ or Java you can hit speeds like that no problem because the program is compiled already and you dont have to recompile each line.

but i'm not sure how accurate this is but here's something to look at: http://benchmarksgame.alioth.debian.org ... =gpp&box=1

from the looks of the table at the bottom. python is up to 100 times slower than compiled C++ and lets say your 3D application is only able to hit 30 fps and we take the avarage of that so lets say your only 50x slower so your python game is running at.... 0.6 fps.

enjoy :D
I made a few tests myself when I worked on the 3d part of my dungeon crawler. The calculations themselves are not a problem if they are optimized enough. The main problem is the displaying itself. At least if you use a 1366 wide viewport you need to display 1366 1 pixel broad slices and that takes up to 3 seconds on my machine.
Although I must admit I only tried the direct approach there, so there IS ver probably a way to optimize that too so that it would function. But that takes quite a lot of knowledge of how to work with pics in python/renpy and probably also a lot of time too.
(there is a 3d demo out there from what I saw, but it doesnt work on my machine....always getting an error when I tried it)

So, assuming I'm willing to get down and dirty with the renpy source, are there any real roadblocks I should know about before trying to implement Persona 4 style 3d scenes? Renpy seems to have most of what I'd want for my project except 3d.
Does it have to be REAL 3d? From how I remember persona it is mostly tilebased. And you could "simulate" 3D with pseudo 3d for it (similar to how I made my dungeon crawler, just for you it is more an isometric view angle)

Post Reply

Who is online

Users browsing this forum: No registered users