Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Kolgena on May 23, 2014, 03:22:31 pm

Title: Nebula and Sunshafts
Post by: Kolgena on May 23, 2014, 03:22:31 pm
I have a question about render distances in nebula:

Right now, it seems that ships will gradually blend into the nebula background color the further away they are, until at one point, they instead stop getting rendered at all. This is normally fine, except when you have sunshafts on. Then, when you're facing the sun and a ship gets close enough to pop into existence, it starts casting a giant sunshaft shadow out of nowhere, even if you can't see it yet.

Best way to reproduce: Fly somewhat far away from a friendly cap ship, position it roughly between you and a sun, start flying towards it.

Is this an engine limitation or something that needs to be tweaked in FRED? Btw, the missions in question are any of the retail FS2 nebula missions with cap ships, most notably The Great Hunt.
Title: Re: Nebula and Sunshafts
Post by: The E on May 23, 2014, 03:29:49 pm
This is an OpenGL limitation. Fog is created via the OGL fog functions, which simply clip objects out once they're too far away; With the current setup, we can't actually do anything about this, this'll have to wait until we move to the deferred renderer.
Title: Re: Nebula and Sunshafts
Post by: Kolgena on May 23, 2014, 03:34:22 pm
I'm guessing there are good reasons preventing the engine from doing the same (similar but asymptotic?) alpha blending as now, but somehow skip the clipping or set the clip distance to 9999999?
Title: Re: Nebula and Sunshafts
Post by: Aardwolf on May 24, 2014, 01:28:12 pm
So do the fog with the fragment shader instead? Then you can avoid that stupid effect where the fog at the edges of the screen is thinner than if you look directly at the object, too.

Huh... I wasn't aware fog caused objects to clip. You learn something new every day.
Title: Re: Nebula and Sunshafts
Post by: Swifty on May 26, 2014, 04:20:29 am
The fog is already done with the fragment shader. 

I can't think of an adequate way to ease in ship lightshaft visibility based on distance. Would turning off lightshafts in the renderer be an acceptable solution in nebula scenes?
Title: Re: Nebula and Sunshafts
Post by: Luis Dias on May 26, 2014, 05:13:17 am
No. Absolutely not. This is a problem that is rare to encounter and if its solution is to scrap off the one case where lightshafts make the best sense to exist, the best atmosphere, the coolest thing ever, **** the problem.
Title: Re: Nebula and Sunshafts
Post by: Kolgena on May 26, 2014, 03:58:45 pm
The fog is already done with the fragment shader. 

I can't think of an adequate way to ease in ship lightshaft visibility based on distance. Would turning off lightshafts in the renderer be an acceptable solution in nebula scenes?

Is there a reason why we can't change it so ships never clip out of existence? They can be 100% the same color as the background nebula (effectively invisible), but if the model itself never disappears, it should cast sunshafts, no?

(Also, IMO sunshafts ONLY make sense in nebula and look terrible to me in space missions. Reversing it would just be lulzy)
Title: Re: Nebula and Sunshafts
Post by: Swifty on May 27, 2014, 09:12:32 pm
We exclude rendering of ships out of fog distance to save on rendering time. At least that's what I think is why.

But if you guys insist, we'll just keep rendering ships in fog regardless of distance if lightshafts are turned on then. I'm just worried about potential rendering bugs this fix could create if any, especially if my assumptions are wrong.
Title: Re: Nebula and Sunshafts
Post by: Kolgena on May 27, 2014, 11:00:37 pm
Thanks Swifty!

Is rendering much more expensive in nebula because of all the blending? Space missions with similar complexity run just fine otherwise. (Also, how does the engine calculate damage/collisions in skirmishes for ships that aren't rendered because they're far away? For one, beam burn particles seem to render somewhat properly in absence of a rendered model)

Another thing that (may have) been there since forever: I'm pretty sure cap ships will blink into existence in front of suns in the skybox once you get close enough. I might be wrong though.
Title: Re: Nebula and Sunshafts
Post by: Aardwolf on May 28, 2014, 01:22:12 pm
Could you render them cheaper somehow because they are entirely fogged out? (Rhetorical question, yes you could... but would that sort of optimization be worthwhile?)
Title: Re: Nebula and Sunshafts
Post by: Luis Dias on May 28, 2014, 06:00:50 pm
That is an idea. Force the renderer to use the last available LOD when the distance is bigger than the fog's max for instance. Although there would be a difference in the outline.
Title: Re: Nebula and Sunshafts
Post by: Aardwolf on May 29, 2014, 10:34:37 pm
I was thinking more like...

Pass just the verts to the shader because the texcoords and normal vectors aren't going to matter. And you could also render all the subobjects without having to change any texture states.