Page 3 of 6
Re: Ground Fog!, without shaders.
Posted: 06 Mar 2008, 02:01
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.
Re: Ground Fog!, without shaders.
Posted: 06 Mar 2008, 02:10
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.
Re: Ground Fog!, without shaders.
Posted: 06 Mar 2008, 21:42
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#
Re: Ground Fog!, without shaders.
Posted: 06 Mar 2008, 22:39
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).
Re: Ground Fog!, without shaders.
Posted: 06 Mar 2008, 23:59
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)
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 00:24
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...
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 00:30
by user
the texture is not important, it looks really bad, the only way would be making a image then rendering stuff into it
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 00:41
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

Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 00:45
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.
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 04:39
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.
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 05:15
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 }
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 07:02
by clumsy_culhane
Yay ! trepan returns!
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 07:05
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.
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 07:42
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.
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 16:02
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.
Re: Ground Fog!, without shaders.
Posted: 07 Mar 2008, 17:55
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.
Re: Ground Fog!, without shaders.
Posted: 08 Mar 2008, 18:13
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
Re: Ground Fog!, without shaders.
Posted: 08 Mar 2008, 22:12
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:
to probaby around:
i think that 0 spacing can be used too.
probably i will release a test version of rain soon.
Re: Ground Fog!, without shaders.
Posted: 18 Mar 2008, 04:24
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?
Re: Ground Fog!, without shaders.
Posted: 20 Mar 2008, 01:07
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.
that is trepan fog.