Author Topic: Rendering engine stuff  (Read 8933 times)

0 Members and 1 Guest are viewing this topic.

Offline karx11erx

  • 27
  • D2X-XL and DLE-XP coder
    • Descent 2 & D2X-XL
Rendering engine stuff
Hi,

I have been implementing per pixel lighting D2X-XL, and I am looking into deferred lighting + shadow maps right now. Imo FS would lend itself ideally for that lighting method, as it's basically one huge, open "room" with a bunch of objects in it.

If you don't know what deferred lighting is: You first render the scene fully bright and collect all light sources that have an influence on the visible scene. In the lighting pass, you illuminate only those pixels that have actually been rendered. In order to do that, you need to render to textures and write additional information to multiple render targets (e.g. material properties) (-> "fat render buffer"). You can either derive pixel world coordinates from pixel coordinates and depth value, or store them in an extra floating point render target for more speed (requires more memory - no prob for modern gfx cards). This is all no rocket science and I have already implemented RTT and MRT in OpenGL. The advantage of this method is that you can process a tremendous number of lights very fast.

If shadow casting would be restricted to a single light source (sun) we'd only need a single shadow map and could do nice diffuse shadows.

I am also having a lot of experience in depth (Z) buffer usage, e.g. for soft blending of light effects.

In case you haven't heard of D2X-XL or me, take a look at http://www.descent2.de and http://www.descent2.de/worklog.html.
« Last Edit: April 03, 2011, 09:17:31 am by karx11erx »

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Rendering engine stuff
Well.....Not to make too fine a point of it, but that's more a suggestion for the SCP board, since it involves a few changes to the render architecture.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Rendering engine stuff
That would be super cool. Unfortunately FreeSpace (and its mods) often work with missions with multiple suns, but maybe you could just take one as the primary if it's necessary to have only one primary light source?

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Rendering engine stuff
Well, there are several possible optimizations here. In addition, using only one or two lights for shadow calculations is usually enough to give the sense of realism you want.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Rendering engine stuff
Agreed.

 

Offline sigtau

  • 29
  • unfortunate technical art assclown
Re: Rendering engine stuff
Perhaps the first sun in the list of suns in the mission file will be taken as the primary light source by the engine (so as to not break any compatibility)?
Who uses forum signatures anymore?

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Rendering engine stuff
The engine is already sorting all available lights in the scene by relative intensity for each model, so taking the first sun from the mission file is not the right way to do this, I think.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline sigtau

  • 29
  • unfortunate technical art assclown
Re: Rendering engine stuff
I dunno, in some of the last Capellan missions in the retail FS2 campaign, some of the more intense lights are suns that happen to be very small (about the size of a star on the skybox texture), so it would look strange to have just one very small sun controlling all of the light while the larger suns don't do anything.  Poor mission design, but eh.
Who uses forum signatures anymore?

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Rendering engine stuff
Yes, but that's a mission design question, not something that should be debated wrt the code implementation of lighting. And as I said, the code doesn't care where the light comes from, it just cares about how strong it is in relation to the other lights present in the scene.

To be exact, IIRC the engine tracks up to 256 lights at any given time, the 8 strongest of which getting rendered to screen.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Sushi

  • Art Critic
  • 211
Re: Rendering engine stuff
Yes, but that's a mission design question, not something that should be debated wrt the code implementation of lighting. And as I said, the code doesn't care where the light comes from, it just cares about how strong it is in relation to the other lights present in the scene.

To be exact, IIRC the engine tracks up to 256 lights at any given time, the 8 strongest of which getting rendered to screen.

Which often looks awful, especially when the suns get pre-empted by distant explosions and laser shots. You get ships that just flicker in and out of brightness.

Maybe we should also have one sun that we can guarantee is always rendered?

 

Offline karx11erx

  • 27
  • D2X-XL and DLE-XP coder
    • Descent 2 & D2X-XL
Re: Rendering engine stuff
Yes, but that's a mission design question, not something that should be debated wrt the code implementation of lighting. And as I said, the code doesn't care where the light comes from, it just cares about how strong it is in relation to the other lights present in the scene.

To be exact, IIRC the engine tracks up to 256 lights at any given time, the 8 strongest of which getting rendered to screen.

Which often looks awful, especially when the suns get pre-empted by distant explosions and laser shots. You get ships that just flicker in and out of brightness.

Maybe we should also have one sun that we can guarantee is always rendered?
D2X-XL tracks an arbitrary amount of lights per level and choses the 32 closest to each face it renders when doing per pixel lighting.

With deferred lighting you wouldn't even have to care about the number of lights, and having to create 4 shadow maps is no big deal either.

I dunno how optimized model rendering is like now, but it would be easily feasible to do something about that, too.

An idea coming to my mind when reading about lighting flaws in the above post is that the engine should prioritize certain lights depending on type. What I can also tell for sure that 8 lights per scene in an environment like Freespace just is not enough.

Thing is, I don't know the code and I don't want to spend weeks and months digging through it, only slowly understanding it and screwing around a lot before really knowing where to get my hands on. So I'd like to collaborate with someone who knows the code well and just help with injecting new tech into it. Rendering to a texture is very easy once you have created a suitable render target: All you need to do is tell OpenGL to render to it instead of the hardware's back buffer. So I would like to just point out such things and let some person who knows where the back buffer is selected change the code (which I could provide). I would also provide code encapsuled in classes that would manage render targets and stuff.

So as I said I would appreciate help when having to interface such modules with the existing code.

Where can I get the source code please (SVN access?)? I cannot seem to find it.
« Last Edit: April 03, 2011, 02:32:26 pm by karx11erx »

 
 

Offline karx11erx

  • 27
  • D2X-XL and DLE-XP coder
    • Descent 2 & D2X-XL
Re: Rendering engine stuff
Thx. Is there a Visual Studio solution available for building FS2Open?

Edit: Found them.

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Steam
    • Twitter
    • ModDB Feature
Re: Rendering engine stuff
Thx. Is there a Visual Studio solution available for building FS2Open?

Several. MSVC 6, 2003, 2005, 2008 and 2010 should all be able to compile, though the Projects files for 2003 were dropped due to no supporting members, and the 2005 will probably soon as well. Lots of us on 2008 and several of us on 2010.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Rendering engine stuff
Thing is, I don't know the code and I don't want to spend weeks and months digging through it, only slowly understanding it and screwing around a lot before really knowing where to get my hands on. So I'd like to collaborate with someone who knows the code well and just help with injecting new tech into it. Rendering to a texture is very easy once you have created a suitable render target: All you need to do is tell OpenGL to render to it instead of the hardware's back buffer. So I would like to just point out such things and let some person who knows where the back buffer is selected change the code (which I could provide). I would also provide code encapsuled in classes that would manage render targets and stuff.

The problem is that, at the moment, we do not have a dedicated graphics coder. Some of us are in the process of trying to learn how it all works, but we're still beginners. Also note that, for the moment, graphical improvements are not all too high on our list of priorities (which is why the lack of an OpenGL person isn't that big a deal for us).

Now, regarding the graphics code itself, there is an interface layer in place that was previously used to switch between the OpenGL and Direct3D codepaths, refer to gr_init_sub(int mode, int width, int height, int depth) in code\graphics\2d.cpp and gr_opengl_init() in code\graphics\gropengl.cpp for details.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Rendering engine stuff
Yeah, while we don't currently have an active dedicated OpenGL guru, it is one of the areas that has been overhauled the most heavily, and therefore, is supposed to be one of the more readable areas at this point.  Someone who has spent more time looking at it would have to attest to that though.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline karx11erx

  • 27
  • D2X-XL and DLE-XP coder
    • Descent 2 & D2X-XL
Re: Rendering engine stuff
Also note that, for the moment, graphical improvements are not all too high on our list of priorities
Oh.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Rendering engine stuff
Really, that's just a convenient argument.  We don't have a graphics coder, so we fix other bugs and code other features instead.  Prettier graphics are always welcome.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Rendering engine stuff
Also note that, for the moment, graphical improvements are not all too high on our list of priorities
Oh.

That's mostly because of relatively few people with the knowledge to do them. If you have something to contribute and someone on the team is willing to partner as you suggested there's no harm in at least trying.

  

Offline Kolgena

  • 211
Re: Rendering engine stuff
As for the user-base, many of us go crazy excited when the words "shadow mapping" comes up. There's definitely a point to getting a renderer upgrade, if you're able to do it.