How do you replace the screen contents in DrawWorld?

How do you replace the screen contents in DrawWorld?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
aeonios
Posts: 202
Joined: 03 Feb 2015, 14:27

How do you replace the screen contents in DrawWorld?

Post by aeonios »

I'm currently working on applying HDR to dynamic light rendering. Since spring doesn't support HDR by default this involved copying the screen texture to an offscreen HDR buffer, drawing the dynamic lights to that, apply tone mapping and then write the HDR texture back to the screen. This has to be done entirely during DrawWorld because, first it's the only time when you can use deferred rendering, and also because other things need to draw to the screen after that so the texture needs to be written back immediately and not during DrawScreenEffects.

Unfortunately it seems like texrect always wants to use worldspace coords during DrawWorld, and I can't figure out how to force it to use screenspace texcoords. Is there some way of getting around that?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: How do you replace the screen contents in DrawWorld?

Post by Kloot »

1) wrong; Draw{Units,Features,Ground}PostDeferred were added with a very specific purpose.
2) ever heard of {Push,Pop,Load,Mult}Matrix and LoadIdentity?
3) general protip: spend less time running your mouth about engine internals and more reading docs.
aeonios
Posts: 202
Joined: 03 Feb 2015, 14:27

Re: How do you replace the screen contents in DrawWorld?

Post by aeonios »

Kloot wrote:1) wrong; Draw{Units,Features,Ground}PostDeferred were added with a very specific purpose.
A very undocumented purpose. Also they're only even called under certain special circumstances which do not apply to what I am doing. Also they are, respectively, for drawing units, features and ground, not the screen.
Kloot wrote:2) ever heard of {Push,Pop,Load,Mult}Matrix and LoadIdentity?
If it was raw openGL that would work, but this is openGL in the context of whatever spring happens to expect at any given time, which is an entirely different matter. I tried using glOrtho which not only did not work but it also screwed up the camera in strange ways.

It probably should have been screwed up anyway since I wasn't using the power-of-two size of the screen buffer, but the kind of screwed up it should have been and the kind I got were two different things.

TexRect also has a bunch of undocumented input params which I have no idea what they do. The deferred rendering widget seems to treat them as screen coords, but I did not have any success in doing so.
That does work for drawing a billboard centered at screen (0,0) but the texture width/height needs to be scaled in some non-intuitive way for it to fill the screen properly, and I have no idea how to do that.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: How do you replace the screen contents in DrawWorld?

Post by Kloot »

A very undocumented purpose.
Again, wrong...
Also they are, respectively, for drawing units, features and ground, not the screen.
Interesting narrative you've made up there, but "drawing" (as explained in the docu, which together with the event framework itself happens to have been written by me) is not their raison d'etre.
Also they're only even called under certain special circumstances which do not apply to what I am doing.
They do apply, you just lack the knowledge to recognize it.

The larger point, which you unsurprisingly also failed to pick up on, would be that DrawWorld is not "the only time when you can use deferred rendering".
TexRect also has a bunch of undocumented input params
Nope, all possible parameters and their meanings are listed on https://springrts.com/wiki/Lua_OpenGL_Api#Draw_Basics. Try thinking of an actually valid excuse or drop the BS.
If it was raw openGL that would work, but this is openGL in the context of whatever spring happens to expect
Spring expects only that its matrices (and other GL state) contain the same numbers at the end of DrawWorld as at the start, any code in between can be as raw or well-done as needed.


You seem eager to do things the hard way and I don't feel like riding more waves of fact-free creative nonsense, so gl and hf.
aeonios
Posts: 202
Joined: 03 Feb 2015, 14:27

Re: How do you replace the screen contents in DrawWorld?

Post by aeonios »

Kloot wrote:The larger point, which you unsurprisingly also failed to pick up on, would be that DrawWorld is not "the only time when you can use deferred rendering".
That turns out to be the only useful thing you've said, albeit too late. I managed to get it to work by running the deferred shaders in DrawScreenEffects, which seems to work just as well, even though it makes for the most inside out and backwards deferred renderer ever.
Kloot wrote:Nope, all possible parameters and their meanings are listed on https://springrts.com/wiki/Lua_OpenGL_Api#Draw_Basics. Try thinking of an actually valid excuse or drop the BS.
Oh and if you want to talk about BS, if you think that the letters "s" and "t" count as 'documentation' or 'meaning' then you must be seriously delusional.
Post Reply

Return to “Lua Scripts”

cron