Ground Fog!, without shaders. - Page 3

Ground Fog!, without shaders.

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

Moderator: Moderators

user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

i have been testing gl.CreateTexture on this, i get always nice results, better than the old method, except when i try to use the depth component on this, i lag down to lower than 1 FPS.

trepan fog uses the depth component, and it hardly lags.

the gl.CreateTexture would be good for a better fog, fog of war, or whatever.
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

to test create texture with this replace some parts:
function widget:Initialize()
fog = gl.CreateList(DrawPlaneModel)
sphere = gl.CreateList(DrawSphereModel)
end
with
function widget:Initialize()
fog = gl.CreateList(DrawPlaneModel)
sphere = gl.CreateList(DrawSphereModel)
textest = gl.CreateTexture(256,256)
end
and
local Fog = function(r,g,b,a)
gl.ResetMatrices()
with:
local Fog = function(r,g,b,a)
gl.ResetMatrices()
gl.Texture(textest,true)
also make a local textest variable, in the globals on the start of the file.
Sheekel
Posts: 1391
Joined: 19 Apr 2005, 19:23

Re: Ground Fog!, without shaders.

Post by Sheekel »

could this be taken 1 step further and implement fog of war!

I assume you could set up mapX by mapY dimensional grid for the fog of war cells, and sets each one to revealed or hidden, 0 = hidden, 1 = revealed.

Code: Select all

for all" hidden" positions
    for each unit on team
       check los
       if los is in new grid#
       disable groundfog at that grid#

Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Re: Ground Fog!, without shaders.

Post by Archangel of Death »

Sheekel wrote:could this be taken 1 step further and implement fog of war!

I assume you could set up mapX by mapY dimensional grid for the fog of war cells, and sets each one to revealed or hidden, 0 = hidden, 1 = revealed.

Code: Select all

for all" hidden" positions
    for each unit on team
       check los
       if los is in new grid#
       disable groundfog at that grid#

*Throws everything he just wrote into a trashbin*While initially I thought "messing with LOS in lua is just asking for 0.001fps", I think it might be doable after some thinking on it. First you'd have to limit it to only units within a certain cylinder area around the camera (so that it doesn't kill you whenever you aren't using a non-top down view). Then you'd want to limit the number of units you actually process in a frame to some number (eg, after doing 10 stop and pick up at 11 next frame). Only update the list of units every dozen or so frames. Might make for a noticeable update lag even with few units, but should keep the CPU load down enough.
I'm not sure how fast Spring.GetPositionLosState is, but if you split the processing over multiple frames it should be possible to get it to work without absolutely killing the computer.
edit again: Instead of going through the whole map to add/remove fog, could just limit it to an area around the camera. Definite speed advantage, but then for players using non-top down views the whole map won't be updated for them (though doing that would be awfully slow anyway).
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

While initially I thought "messing with LOS in lua is just asking for 0.001fps", I think it might be doable after some thinking on it. First you'd have to limit it to only units within a certain cylinder area around the camera (so that it doesn't kill you whenever you aren't using a non-top down view). Then you'd want to limit the number of units you actually process in a frame to some number (eg, after doing 10 stop and pick up at 11 next frame). Only update the list of units every dozen or so frames. Might make for a noticeable update lag even with few units, but should keep the CPU load down enough.
you forgot one thing: the reason for the massive rewrite: this uses only 4 vertices for every fog plane layer.

so for some time expect no fog of war.

and please try to understand what gl copy to texture does before asking for using a grid to make fog of war.

gl copy to texture, is the only possible current way to make such a thing without lagging down to 0.08 FPS (less than using the depth component as a texture)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Ground Fog!, without shaders.

Post by Argh »

Almost done getting this working... still haven't gotten the texture part working, but it's now functional, as a Gadget. Working on doing something with a texture... might be interesting...
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

the texture is not important, it looks really bad, the only way would be making a image then rendering stuff into it
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Ground Fog!, without shaders.

Post by Argh »

Well, using more but smaller quads would work- even a couple of hundred quads is nothing, compared to the rest of the load. The only reason I'm bringing this up is that if it worked that way, and used a random projection of the texture coordinates, it could produce a much more realistic-looking fog, with layers of detail, by using an alpha. Real fog is basically a cloud on the ground. It'd be awesome, if it looked that way from the air, and it'd really help it look good when the planes are clipping through terrain, imo.

At any rate, after I'm screwing around with that idea, I'll post the code, it works, as a Gadget, and minor quibbles aside, it's very cool :-)
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

copy to texture would be used to copy a transparent texture on some parts, to make it look smooth, and less dense closer to the camera.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Ground Fog!, without shaders.

Post by Argh »

Here is the revised ground fog, as a Gadget. To use it, simply put a LuaRules/Gadgets folder into a map file, then run the map.

Works, is fast. However, it's not nearly as pretty as Trepan's shader implementation, the only problem with that one being that I haven't (yet) figured out how to adjust the height, color, etc., whereas this is very easy to use. The big things that make this one not as pretty are that the planes obviously clip through terrain, so you have to put it above your terrain, if you don't want people to see that, and when the camera goes below the fog level, the change in the opacity of the fog is very abrupt and doesn't feel natural. But it's very fast, and easy to work with, so I'll include it with the example map for World Builder until we have something that works better- I'd rather have stuff that was easy for mappers to use than black-box stuff that's not easy to customize, in the initial release.
Attachments
unit_ground_fog.lua
(8.62 KiB) Downloaded 40 times
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Ground Fog!, without shaders.

Post by trepan »

It ain't rocket science boys and girls.

Verbatim:

Code: Select all

local fogHeight = gndMax * 0.5
local fogAtten  = 0.01
local fogColor  = { 0.7, 0.7, 0.9 }
User avatar
clumsy_culhane
Posts: 370
Joined: 30 Jul 2007, 10:27

Re: Ground Fog!, without shaders.

Post by clumsy_culhane »

Yay ! trepan returns!
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Re: Ground Fog!, without shaders.

Post by Archangel of Death »

user, I was specifically refering to the issue of determining where los begins/ends for the purpose of removing fog from certain areas, not considering the implementation of the fog itself (since that involves all that stuff I just gloss over with glassy eyes! gl.whatnow? :? ). So in the purely hypothetical situation that some lua god/goddess came along and through some magic blessed us with a super fast fog that could potentially be used for fog-of-war, I was bringing up the problematic issues with los just being an intense thing to mess with in a timely way.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Ground Fog!, without shaders.

Post by Argh »

Maybe I can figure out a way to run user's code if GLSL fails, as a fallback...

Oh, and as for fog of war... it shouldn't be that hard... just get the position of every object every second or two, then use them to add / remove states in a 2D array, then draw all of the ones, don't draw the zeros.

It'd be better to grab positions of a handful of Units each frame, by cycling in a for-->next loop through all UnitIDs, to update the array a little bit at a time, to keep it from being a massive CPU hog during an update during late game, but it shouldn't be that hard.

I'm not personally interested in trying to implement this, though, I've always hated hiding the map from people.
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

if some thing is wrong with this, follow these steps:

1. post here.
2. explain.
3. probably i will fix it.

argh: change the spacing between layers, this is really easy to use, if you want it fixed then wait.

trepan: how does your widget use the depth component and hardly lags?, and what are all the texture formats?, and how do i fix the issue this has when using gl create texture?
Oh, and as for fog of war... it shouldn't be that hard... just get the position of every object every second or two, then use them to add / remove states in a 2D array, then draw all of the ones, don't draw the zeros.
very good idea, really, not.

and for all: this is just a small test version, don't complain yet.
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

just a update,

AutoAdjustHeight makes the height automatically get adjusted to the half of the max ground height, like trepan fog.

FogInsideAmbientOpacity is the increase in the alpha when going with the camera inside the fog, 0.2 makes the alpha don't change.

LayerSpacing is the distance between each layer, should be really small.

to use a texture, uncomment the gl texture line.

and do not use alpha test, it doesn't works.
Attachments
unit_ground_fog.lua
(10.01 KiB) Downloaded 22 times
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

wow, using this last one made by me with the depth component 24 as a texture, 18 layers is really awesome, i will post it here.

be sure to use a 24 bit z buffer
Attachments
unit_ground_fog.lua
(10.05 KiB) Downloaded 33 times
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

haven't made nothing good, or new for this since the last release, because i have been working on some really cool stuff, or just playing with editing the spring shaders.

to make this look as better as possible, change:

Code: Select all

      LayerSpacing = 0.006,


to probaby around:

Code: Select all

      LayerSpacing = 0.0001,


i think that 0 spacing can be used too.

probably i will release a test version of rain soon.
User avatar
The_Big_Boss
Posts: 88
Joined: 17 Jul 2006, 04:00

Re: Ground Fog!, without shaders.

Post by The_Big_Boss »

Very nice.

Could this be modified into dynamic fog? Where an explosion pushes the fog away from the source, and then it rolls back into place like water?
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Ground Fog!, without shaders.

Post by user »

maybe, maybe using a vertex displacement function that i made for the most recent animated water widget, i made it have waves.
or maybe using trepan fog, editing his fragment shader a bit.
or maybe making it use lots of quads and a vertex shader.

my fog is not very good compared to trepan fog.
Noruas wrote:http://www.youtube.com/watch?v=bb4Hev7zhUY

Heres a youtube video that uses the fog widget to use.
that is trepan fog.
Post Reply

Return to “Lua Scripts”