Ground Fog!, without shaders.
Moderator: Moderators
Re: Ground Fog!, without shaders.
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.
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.
to test create texture with this replace some parts:
withfunction widget:Initialize()
fog = gl.CreateList(DrawPlaneModel)
sphere = gl.CreateList(DrawSphereModel)
end
andfunction widget:Initialize()
fog = gl.CreateList(DrawPlaneModel)
sphere = gl.CreateList(DrawSphereModel)
textest = gl.CreateTexture(256,256)
end
with:local Fog = function(r,g,b,a)
gl.ResetMatrices()
also make a local textest variable, in the globals on the start of the file.local Fog = function(r,g,b,a)
gl.ResetMatrices()
gl.Texture(textest,true)
Re: Ground Fog!, without shaders.
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.
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#
-
- Posts: 854
- Joined: 28 Jan 2005, 18:15
Re: Ground Fog!, without shaders.
*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.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#
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.
you forgot one thing: the reason for the massive rewrite: this uses only 4 vertices for every fog plane layer.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.
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.
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.
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.
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
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.
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.
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.
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
Re: Ground Fog!, without shaders.
It ain't rocket science boys and girls.
Verbatim:
Verbatim:
Code: Select all
local fogHeight = gndMax * 0.5
local fogAtten = 0.01
local fogColor = { 0.7, 0.7, 0.9 }
- clumsy_culhane
- Posts: 370
- Joined: 30 Jul 2007, 10:27
Re: Ground Fog!, without shaders.
Yay ! trepan returns!
-
- Posts: 854
- Joined: 28 Jan 2005, 18:15
Re: Ground Fog!, without shaders.
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.
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.
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.
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?
and for all: this is just a small test version, don't complain yet.
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?
very good idea, really, not.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.
and for all: this is just a small test version, don't complain yet.
Re: Ground Fog!, without shaders.
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.
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
Re: Ground Fog!, without shaders.
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
be sure to use a 24 bit z buffer
- Attachments
-
- unit_ground_fog.lua
- (10.05 KiB) Downloaded 33 times
Re: Ground Fog!, without shaders.
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.
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.
- The_Big_Boss
- Posts: 88
- Joined: 17 Jul 2006, 04:00
Re: Ground Fog!, without shaders.
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?
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.
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.
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.Noruas wrote:http://www.youtube.com/watch?v=bb4Hev7zhUY
Heres a youtube video that uses the fog widget to use.