Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Test Builds => Topic started by: portej05 on November 27, 2009, 12:08:17 pm

Title: Antipodes #4
Post by: portej05 on November 27, 2009, 12:08:17 pm
Hiya Folks,

This is Antipodes build #4

Antipodes is a staging ground for changes that will eventually make their way into trunk. Antipodes should not be considered stable.

Antipodes #4 has been completed by Hery, and contains the post-processing code.

This build includes trunk to 5681.

Antipodes 4 Executables (http://porteous.no-ip.org/FS2Files/Antipodes/Antipodes4/Antipodes4EXEs.zip)
Shaders and Tables for PostProcessing (http://porteous.no-ip.org/FS2Files/Antipodes/Antipodes4/pp_data.zip)

PDBs (for when you have troubles) can be found in this folder:
Antipodes 4 PDBs (http://porteous.no-ip.org/FS2Files/Antipodes/Antipodes4/Antipodes4PDBs.zip)

Note that they don't compress well. To use: Download matchine PDBs zip, unzip into the SAME location as the executables.
The PDBs have been versioned in the same fashion as the Antipodes executables, so multiple PDB versions can coexist in the same folder. (although, I recommend removing old ones due to their size)

This build adds post-processing to FSO. The main idea behind this rendering technique is to render the scene to a texture and then draw it to the back buffer applying some additional effects at the same time.
There is a huge number of post-processing effects, currently only bloom and few other, really simple ones are implemented. In addition to that there is a possibility to add new post-processing effects (if they are simple enough) without changing FSO code. It can be done by modifying shaders code and post_processing.tbl

Simple post-processing effects (such as contrast, saturation, film grain) can be controlled by a new SEXP: set-post-effect.

Post-processing is enabled by -post_process flag.
Bloom intensity can be controlled by -bloom_intensity X flag (when X = 0 ther's no bloom and the maximum value is 100).

Apart from that, post-processing patch introduces:
 * shader manager with support for main and post-processing shaders
 * wrappers for OpenGL textures, rendering buffers and FBOs

The new code is documented using doxygen-style comments.
Title: Re: Antipodes #4
Post by: Hery on November 27, 2009, 12:52:13 pm
Simple instruction what to do with the files from Shaders and Tables for PostProcessing:
1. Copy *.sdr files to data/effects directory
2. Copy *.tbl file to data/tables directory
3. Enable -post_process flag in the launcher
Title: Re: Antipodes #4
Post by: Reprobator on November 27, 2009, 02:18:24 pm
It seems like the post process is not applyed on the cockpit, is that normal?
However the cockpit doesn't pass thrgough object anymore! that's nice  ;)
Title: Re: Antipodes #4
Post by: Hery on November 27, 2009, 03:17:06 pm
That's a bug I was aware of but then I forgot :P Fortunately, the build is OK, since the problem is caused by highpass filter.

In order to fix it replace the content of brightpass-f.sdr with the following:
Code: [Select]
uniform sampler2D tex;

const float Luminance = 0.08;
const float fMiddleGray = 0.2;
const float fWhiteCutoff = 0.4;

// High-pass filter
void main() {
vec4 ColorOut = texture2D(tex, gl_TexCoord[0].xy);

ColorOut.rgb *= fMiddleGray / (Luminance + 0.001);
ColorOut.rgb *= (1.0 + (ColorOut.rgb / (fWhiteCutoff * fWhiteCutoff)));
ColorOut.rgb -= 6.0;

ColorOut.rgb /= (10.0 + ColorOut.rgb);

gl_FragColor = ColorOut;
}
Title: Re: Antipodes #4
Post by: Zacam on November 28, 2009, 01:41:27 am
And for those of you that didn't get this from any of the earlier packages (or lost it):
postprocess.fs2 (http://zacam.ueuo.com/fsu/postprocess.fs2)
Title: Re: Antipodes #4
Post by: Colonol Dekker on November 29, 2009, 11:41:45 am
Which version of Fred contains the post process sexps again?

Just the filename please, i've got a load of .exes and can't remember which one to use for BLOOM :D
Title: Re: Antipodes #4
Post by: MetalDestroyer on November 29, 2009, 01:42:40 pm
Which version of Fred contains the post process sexps again?

Just the filename please, i've got a load of .exes and can't remember which one to use for BLOOM :D

Quote from: portej05
Simple post-processing effects (such as contrast, saturation, film grain) can be controlled by a new SEXP: set-post-effect.
Title: Re: Antipodes #4
Post by: Colonol Dekker on November 29, 2009, 02:30:13 pm
Yes I know but I don't see an antipodean fred in the zip. So liek where is it?
Title: Re: Antipodes #4
Post by: Reprobator on December 01, 2009, 11:00:58 am
IS there an option somewhere to control the effect applied on the skyboxes pof?
I have one with a moon like planteoid wich is now full bright and has lost all its detail when using post process  ;)
Title: Re: Antipodes #4
Post by: Hery on December 01, 2009, 11:10:22 am
Currently, the only solution is to decrease bloom intensity using a launcher flag.
It is possible to hack a simple and not very good solution to this problem but I decided that's pointless since tone mapping (which will be introduced in the future) will solve the problem completely.
Title: Re: Antipodes #4
Post by: Reprobator on December 01, 2009, 12:26:06 pm
Ok, so i'll wait for tone mapping so.  :D
Title: Re: Antipodes #4
Post by: Commander Zane on December 02, 2009, 07:45:28 am
What does SSE stand for?
Title: Re: Antipodes #4
Post by: portej05 on December 02, 2009, 07:56:23 am
The basic gist of it is that they're vector instructions, and can offer performance improvements for certain cases (which is something we really need as much as possible in FSO).

Wikipedia has a writeup on it:
http://en.wikipedia.org/wiki/Streaming_SIMD_Extensions (http://en.wikipedia.org/wiki/Streaming_SIMD_Extensions)
Title: Re: Antipodes #4
Post by: portej05 on December 10, 2009, 11:27:08 pm
FRED builds!:

Antipodes #4 FRED (+PDBs) (http://porteous.no-ip.org/FS2Files/Antipodes/Antipodes4/fred2_open_antr.zip)
Title: Re: Antipodes #4
Post by: Colonol Dekker on December 11, 2009, 02:07:35 am
Yay! Now with added sex-pee hopefully :D
Title: Re: Antipodes #4
Post by: Talon 1024 on December 11, 2009, 02:49:09 pm
I made my own little unreleased post-processing demo a while back, but I adapted it for the newer post-processing EXE.  Here it is:

http://www.ciinet.org/kevin/Files/pprocess.fs2 (http://www.ciinet.org/kevin/Files/pprocess.fs2)
Title: Re: Antipodes #4
Post by: portej05 on December 14, 2009, 07:57:51 am
Antipodes #4 has now ended.
Thank you to all who took part.

The Post-Processing changes have been committed in 5715.

Enjoy!
Title: Re: Antipodes #4
Post by: pecenipicek on December 14, 2009, 08:17:44 am
woot!
Title: Re: Antipodes #4
Post by: Zacam on December 19, 2009, 03:59:14 pm
Updated shaders package linked here for completness sake: http://zacam.ueuo.com/fsu/FSU_and-PostProc_Shaders.7z
Title: Re: Antipodes #4
Post by: Rodo on December 19, 2009, 05:12:01 pm
With the new builds it runs faster than before, the only problem is that the bloom is affecting the background nebulae, is that gonna be managed somehow, like a command line or a mission property?.
Title: Re: Antipodes #4
Post by: Zacam on December 19, 2009, 06:06:57 pm
Set in the Custom Flags the following: -bloom_intensity ##

Where ## = 0-160
Title: Re: Antipodes #4
Post by: Commander Zane on December 19, 2009, 07:48:12 pm
With the new builds it runs faster than before, the only problem is that the bloom is affecting the background nebulae, is that gonna be managed somehow, like a command line or a mission property?.
It's always done that as far as the Antipodes go.
Title: Re: Antipodes #4
Post by: portej05 on December 20, 2009, 03:57:53 am
With the new builds it runs faster than before, the only problem is that the bloom is affecting the background nebulae, is that gonna be managed somehow, like a command line or a mission property?.
It's always done that as far as the Antipodes go.

Which bit? The bloom, the background nebulae or the speed :P
Title: Re: Antipodes #4
Post by: Commander Zane on December 20, 2009, 07:17:48 am
Blooming nebula.
Title: Re: Antipodes #4
Post by: portej05 on December 20, 2009, 07:27:44 am
Interesting, because Antipodes is just a trunk build with some extra stuff :P
I'll keep an eye out for it.
Title: Re: Antipodes #4
Post by: pecenipicek on December 20, 2009, 06:19:08 pm
there is one bug with postprocessing, not truly related to antipodes itself.

when using the mainhall script, any mission that is chosen, wont display, but instead a fullscreen greyish plate will be displayed where the mission should play out. aka, the post processing doesnt actually process the frames it should but processes a blank slate of sort, which gives the good grayness -.-

if my logic is correct, this is actually more lua(scripting) related probably, as the command that the script uses pulls the frames out of the wrong framebuffer.
Title: Re: Antipodes #4
Post by: Commander Zane on December 20, 2009, 07:21:14 pm
Something I seemed to notice in game was ship-to-ship collisions disable all the bloom effects as long as they are grinding hulls together, once they stop frotting the bloom comes back on.
Title: Re: Antipodes #4
Post by: pecenipicek on December 20, 2009, 07:45:39 pm
try it with weapon impacts too (get a rapidfire weapon or tablehack another to check...)
Title: Re: Antipodes #4
Post by: Hery on December 21, 2009, 03:50:20 am
Commander Zane: This (http://www.hard-light.net/forums/index.php?topic=66752.msg1318464#msg1318464) should solve the problem.

pecenipicek: Could you give me all data I need to reproduce this bug?
Title: Re: Antipodes #4
Post by: pecenipicek on December 21, 2009, 05:19:40 am
unfortunately, not at the moment no, but that bug was apparent since you first started to do the postprocessing. i will be able to give you all the neccesary data after 30th december, since i'm not at my usual pc...

however, here are the steps, use this script, save it as mainhall-sct.tbm in your tables folder
Code: [Select]
#Conditional Hooks
$Application: Freespace 2
$On Game Init: [
--Function to handle a section every frame
section = function(name, event, num, hidden)
if hidden == false then
divsize = 8
xadd = 159
yadd = 35
else
divsize = 256
xadd = 10
yadd = 10
end

--MENU COLOR
local xmargin = gr.getScreenWidth()/divsize
local ymargin = gr.getScreenHeight()/divsize

--Get corner coordinates for this box
local x1 = xmargin
local y1 = ymargin*num
local x2 = x1+xadd
local y2 = y1+yadd

--When the mouse is OVER this section...
if io.getMouseX() > x1 and io.getMouseX() < x2 and io.getMouseY() > y1 and io.getMouseY() < y2 then
if hidden == false then
--Draw the inside box
gr.setColor(0, 255, 0)
gr.drawRectangle(x1+5, y1+5, x2-5, y2-5, false, false)

--Draw the little target lines now
local x = x1+(x2-x1)/2
local y = y1-20

--Top target line
gr.drawLine(x, y, x, y+15)

--Bottom target line
y = y2+10
gr.drawLine(x, y, x, y+15)

--Left target line
x = x1-20
y = y1+17
gr.drawLine(x, y, x+15, y)

--Right target line
x = x2+5
gr.drawLine(x, y, x+15, y)
end

--Handle the button click
if io.isMouseButtonDown(MOUSE_LEFT_BUTTON) then
gr.drawRectangle(x1, y1, x2, y2, false, false)
if event == "GS_EVENT_NEW_CAMPAIGN" or event == "GS_EVENT_OPTIONS_MENU" then
mn.unloadMission()
g_missionLoaded = nil
g_splashScreen = nil
end
ba.postGameEvent(ba.GameEvents[event])
end
end

--Draw the outline
gr.setColor(255, 255, 255)
gr.drawRectangle(x1, y1, x2, y2, false, false)

if hidden == false then
--Draw the name
gr.drawString(name, x1 + ( (x2-x1) - gr.getStringWidth(name) ) / 2, y1+15)
end
end
]

$Application: Freespace 2
$State: GS_STATE_MAIN_MENU
$On State Start: [
logolist = {"43_logo","1610_logo"}                --This is a list of logos. Basically the same Logo, only adapted for 4:3 aspect ratio displays and 16:10 ones
shiplist = {"GTF Hercules" "GTF Myrmidon" "GTF Perseus"} --Put your ship classes in quotes here
missionlist = {"Mainhall.fs2"}                    --List of missions to be used
backgroundlist = {"43_mainhall", "1610_mainhall"} --List of backgrounds. Again, divided into 4:3 and 16:10 ones
splashscreen = "2_PreLoad"                        --Splashscreen displayed while the mission loads
usemission = false                               --If false, the single- and multiplayer UI will use the same layout. If true, one of the missions defined in the missionlist will play in the background of the single player UI
rotConst = 7                                      --Modify this to make the ship turn faster to slower

screenWidth = gr.getScreenWidth()
screenHeight = gr.getScreenHeight()
aspectRatio = screenWidth/screenHeight

if aspectRatio == 1.6 then
logo = logolist[2]
background = backgroundlist[2]
else
logo = logolist[1]
background = backgroundlist[1]
end

imgWidth = gr.getImageWidth(logo)
imgHeight = gr.getImageHeight(logo)
renderX1 = 0 --screenWidth * 0.2
renderX2 = screenWidth --* 0.99
renderY1 = 0 --screenHeight * 0.1
renderY2 = screenHeight --* 0.9
rendermidX = (renderX1+renderX2)/2
imageX = 0 --(screenWidth*0.5)-imgWidth/2
imageY = screenHeight - imgHeight

if ts.isCurrentPlayerMulti()==true or usemission==false then
numChoices = table.getn(shiplist)
randomShip = tb.ShipClasses[shiplist[math.random(1,numChoices)]]
shipName = randomShip.Name
init = 42
end
]
+Override: true
$On State End: [
if g_missionLoaded then
mn.unloadMission()
g_missionLoaded = nil
g_splashScreen = nil
end
]
+Override: true
$On Frame: [
if ts.isCurrentPlayerMulti()==true or usemission==false then

--Draw background image
local tex = gr.loadTexture(background)
if tex:isValid() then
gr.drawImage(tex, 0, 0, gr.getScreenWidth(), gr.getScreenHeight())
end

if rotate_pct then
rotate_pct = rotate_pct + rotConst*ba.getFrametime()
if rotate_pct > 100 then
rotate_pct = rotate_pct - 100
end
else
rotate_pct = 40
end

randomShip:renderTechModel(renderX1, renderY1, renderX2, renderY2, rotate_pct)

gr.setColor(255,255,255)
gr.drawString(shipName,rendermidX-gr.getStringWidth(shipName)/2,renderY2)
else
if not g_splashScreen then
--Don't need cursor
io.setCursorHidden(true)

--Draw splash image
local tex = gr.loadTexture(splashscreen)
if tex:isValid() then
gr.drawImage(tex, 0, 0, gr.getScreenWidth(), gr.getScreenHeight())
end

--Draw "Loading..."
gr.setColor(255, 255, 255)
gr.CurrentFont = gr.Fonts['font02']
local loadString = "Loading..."
local x = (gr.getScreenWidth()-gr.getStringWidth(loadString))/2
local y = (gr.getScreenHeight()-gr.CurrentFont.Height)/2
gr.drawString(loadString, x, y)

--Done with splash
gr.CurrentFont = gr.Fonts['font01']
g_splashScreen = true
elseif not g_missionLoaded then
if init2 == nil then
missionName = missionlist[math.random(1,table.getn(missionlist))]
init2 = 42
end
mn.loadMission(missionName)
io.setCursorHidden(false)
g_missionLoaded = true
end
end

if g_missionLoaded then
mn.simulateFrame()
mn.renderFrame()
end

if g_missionLoaded or ts.isCurrentPlayerMulti()==true or usemission==false then
if ts.isCurrentPlayerMulti()==true then
if ts.isPXOEnabled()==true then
section("Multiplayer", "GS_EVENT_PXO", 1, false)
else
section("Multiplayer", "GS_EVENT_MULTI_JOIN_GAME", 1, false)
end
else
section("Ready Room", "GS_EVENT_NEW_CAMPAIGN", 1, false)
end
section("Campaign Room", "GS_EVENT_CAMPAIGN_ROOM", 2, false)
section("Tech Room", "GS_EVENT_TECH_MENU", 3, false)
section("Barracks", "GS_EVENT_BARRACKS_MENU", 4, false)
section("Options", "GS_EVENT_OPTIONS_MENU", 5, false)
section("Exit", "GS_EVENT_QUIT_GAME", 6, false)
section("F3", "GS_EVENT_LAB", 1, true)
end
]
+Override: true
#End

rename any mission to "Mainhall.fs2" and enable any postprocessing effect via sexp's in that mission (i am not sure if bloom affects it but i believe that it does), and run the game. if i described the steps right you should get a grey screen with 5 or 6 buttons replacing the usual mainhall buttons.

normally, it should display the mission playing out in real time as the mainhall "background".

mods used do not really matter.


i believe that these two commands would be used in scripting for rendering something out(look below this text), and i believe that its worth checking from which framebuffers the functions pull data from, as obviously its something not used in your postprocessing pipeline. (or its just pulling from a wrong FB, ie, not pulling the final rendered out frame but one of the intermediate framebuffers or even just the first state of the base FB, not that i have any idea how all that works. just saying from what would seem logical to a 3D artist)

mn.simulateFrame() and mn.renderFrame()

also, portej, i deeply apologise for reporting this after antipodes #4 has ended, i unfortunately forgot about that gem completely back when postproc was unveiled, and it just very recently bit me back in the ass when i was tweaking the effects for TAP.
Title: Re: Antipodes #4
Post by: The E on December 21, 2009, 05:23:28 am
mn.simulateframe() runs the AI and all that, mn.renderFrame() renders it.
Title: Re: Antipodes #4
Post by: pecenipicek on December 21, 2009, 05:36:05 am
i'd still check both in the code just in case. who knows where it might be bugged anyway. do take note that i am not a programmer and that i'm kinda figuring out this as i go and how the script works. thankfully i've dabbled in c++ enough to be able to identify major parts of a program if its not obfuscated too much.
Title: Re: Antipodes #4
Post by: Commander Zane on December 21, 2009, 07:20:07 am
Commander Zane: This (http://www.hard-light.net/forums/index.php?topic=66752.msg1318464#msg1318464) should solve the problem.
Wait, what? What bug?
Title: Re: Antipodes #4
Post by: pecenipicek on December 21, 2009, 08:55:55 am
Zane, this is in relation to my problems, not yours. You just have to grab that file and overwrite another one in your tables folder.
Title: Re: Antipodes #4
Post by: Hery on December 27, 2009, 07:22:32 am
Solution to the problems with mainhall scripts was committed and will appear in the next nightly build.
Title: Re: Antipodes #4
Post by: pecenipicek on December 27, 2009, 07:55:58 am
what was the bug anyway?
Title: Re: Antipodes #4
Post by: portej05 on December 27, 2009, 08:03:25 am
also, portej, i deeply apologise for reporting this after antipodes #4 has ended, i unfortunately forgot about that gem completely back when postproc was unveiled, and it just very recently bit me back in the ass when i was tweaking the effects for TAP.

Hey no probs! :)
Better to have a bug report late than none at all :)
Title: Re: Antipodes #4
Post by: Hery on December 27, 2009, 09:40:33 am
The problem was that current simple effects configuration was initialized when a mission was loaded. Unfortunately, there is separate code which handles "normal" mission loading and mission loading called from lua scripts. I was unaware of that and when script loaded a mission simple effects configuration was invalid. Contrast was set to 0, hence the grey screen.
Title: Re: Antipodes #4
Post by: pecenipicek on December 27, 2009, 09:42:41 am
ah. excellent. i will test this when i get back home... 3 more daays :D
Title: Re: Antipodes #4
Post by: pecenipicek on December 30, 2009, 06:59:30 pm
post effects do work now, but spec maps are...whacked. i get full enviroment reflection in ship lab and ingame.

btw, nightly build, 29 Dec 2009 - Revision 5749

needs more testing however, will return when i have proper data.
Title: Re: Antipodes #4
Post by: Zacam on December 30, 2009, 08:41:08 pm
Are you on an NV Card or an ATI card? (I forget)

I went through with Fury to re-do the Unified shaders yet again to resolve some ATI based issues while still keeping the specular increase when shaders where used down to a more acceptable level on the nV cards.

[attachment deleted by admin]
Title: Re: Antipodes #4
Post by: pecenipicek on December 30, 2009, 11:53:54 pm
nvidia, tried and true. gtx260 :p


i will test the shader as it does look like a shader bug, but having a mirror instead of a model kinda... sucks :p


isnt this amusing? http://img705.imageshack.us/img705/8048/screen0085.jpg


occurs only with that particular model and i have no idea why. the shine map aplha is near white at a few small spots on the hull... not on the whole hull... (at first i thought it was because of normal mapping, and it is in a little way. something in the shader order got messed up somewhere...
Title: Re: Antipodes #4
Post by: Commander Zane on December 31, 2009, 02:57:18 am
That looks awesome. :lol:
Title: Re: Antipodes #4
Post by: pecenipicek on December 31, 2009, 03:16:29 am
if it were the intended effect, i'd agree XD :p you can achieve a similar effect by giving any model a full opacity alpha channel in the spec map.
Title: Re: Antipodes #4
Post by: Zacam on December 31, 2009, 07:53:58 am
PM the textures if you want, I might be able to suss out the issue.
Title: Re: Antipodes #4
Post by: Aardwolf on December 31, 2009, 02:24:24 pm

isnt this amusing? http://img705.imageshack.us/img705/8048/screen0085.jpg


occurs only with that particular model and i have no idea why. the shine map aplha is near white at a few small spots on the hull... not on the whole hull... (at first i thought it was because of normal mapping, and it is in a little way. something in the shader order got messed up somewhere...

My first observation is that your model has no smoothing info --- or at least, it doesn't look like it does.
Title: Re: Antipodes #4
Post by: pecenipicek on December 31, 2009, 04:36:11 pm

isnt this amusing? http://img705.imageshack.us/img705/8048/screen0085.jpg


occurs only with that particular model and i have no idea why. the shine map aplha is near white at a few small spots on the hull... not on the whole hull... (at first i thought it was because of normal mapping, and it is in a little way. something in the shader order got messed up somewhere...

My first observation is that your model has no smoothing info --- or at least, it doesn't look like it does.
which matters **** all in relation to ENVIROMENT MAP REFLECTIONS.