Sky/water horizon blending?


(Rummie) #1

I am toying around with an island map and I wanted to have a nice horizon where the sky fades into the ocean. Now, I saw the shaderlab_1337 file and decided to give that a whirl, but it doesn’t work with terrain too well even though I messed with the terrain shader to have the blend used on the concrete in shaderlab_1337. Also, I wanted to use a skybox I had created in Terragen and not the sky used in shaderlab_1337. My results were not so good. I never get a true horizon - even with the original sky due to the terrain.

My intent is to get the same type of horizon as seen in battery. I have read many posts about the battery water and I understand how the water was made, what I do not understand is how the ocean seems to blend into the sky…

If someone could explain how to do this or point me to a tutorial, I would greatly appreciate it.


(ydnar) #2

Battery is fogged using a worldspawn fog shader.

The sky shader has q3map_noFog and a mask image that matches the fog color.

This is the same hack that BF1942, MoH and COD use to have both sky and distance fogging.

Look at Battery’s sky shader and water shaders to see how it works.

y


(Rummie) #3

Thanks Ydnar. I looked into it and compiled and apparently it doesn’t like my _fog key in the worldspawn. I get the error “Fog brushnumber out of range” when I try to load the map. Does this functionality only work in ET? I am using this in RTCW.


(pazur) #4

hi rummie,

this work only with ET and JA … RtCW crashes on worldspawn fog :bored:


(Rummie) #5

Boo! I figured as much. Thanks…


(pazur) #6

in the q3map2 alpha manual there is something about how to use _farplanedist without having a worldspawn _foghull or _fog key:


Leave a little "chimney" somewhere on your structural hull that the fog peeks through and the fog will work properly across the map:




"-" = fog
"_" = hull
      _
 ----|-|-------
 ____| |_______

http://www.shaderlab.com/q3map2/manual/drafts/ent_keys.htm

btw: the “real” fog causes a dramatic framedrop in RtCW… i have used wolf fog(fogvars) instead in my RtCW map. but u got to be careful with this wolf fog. u cant use lightmapped terrain or shaders with 3 or more stages (like in metal shaders with a environment stage)


(Rummie) #7

You know that’s funny - I just made a fog shader, threw a fog brush over the entire map and I do have lightmapped terrain and it did work and my performance is not bad at all… Why do you say lightmapped terrain won’t work? I used fogparms ( .4 .4 .4 ) 6144 in the shader. The compile was fine and it looks great in game.


(kat) #8

Lightmapped terrain sometimes causes blending problems if there are too many ‘layers’ to the terrain. A fog brush is generally ok but the skyportal fog (wolffog) has a real hard time with various things to do with layer/texture blending. The classic example is using water with wolf-fog, it really doesn’t like that…


(Gringo Starr) #9

I found that using a fog brush throughout the map causes a lot of blending issues, compared with skybox fog. While you only have terrain and maybe water now, wait till you add windows, decals, DG banners, etc… Also check explosions and flames and the player with cg_thirdperson 1. At the very least, I think you’ll be re-writing some stock DG shaders for your map. I hope it works, I just didn’t have luck with that method.


(Rummie) #10

grumble - ok thanks Gringo…

I will try the chimney method and see what that does, though I am still a bit unclear as to why that works. Perhaps I am missing something?


(pazur) #11

maybe my old graphic card was causing this framedrop with the real fog… dunno. in a test i had 80 fps before and after adding the real fog instead of skybox wolf fog i had like 30-40 :moo:


(neotic) #12

I tested a big difference with and without fog in my map. Enough that I plan on leaving out the global fog. Its just not worth it.


(neotic) #13
textures/neotic_skies/ruinsky2b
{
	nocompress
	qer_editorimage textures/neotic_skies/sky_clouds.tga
	q3map_lightrgb .980 0.572 0.172
	q3map_sunExt .980 0.572 0.172 175 225 65 3 16
	q3map_skylight 125 3
	q3map_nofog
	
	surfaceparm noimpact
	surfaceparm nolightmap
	surfaceparm nodlight
	surfaceparm sky
	
	skyparms textures/neotic_skies/env_r/sky 512 -
 
	sunshader textures/skies_sd/seawallsunfog
 
	
	{	fog off
		map textures/neotic_skies/sky_clouds.tga
		tcMod scale 2.5 2.5
		tcMod scroll 0.0015 -0.003
		rgbGen identityLighting
	}

	{
		fog off
		clampmap textures/neotic_skies/ruins_mask_ydnar.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		tcMod scale 0.956 0.956
		tcMod transform 1 0 0 1 -1 -1
		rgbGen const ( 0.925 0.376 0.141 ) 
	}

	{
		fog off
		clampmap textures/neotic_skies/ruins_mask_ydnar.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		tcMod scale 0.8 0.8
		tcMod transform 1 0 0 1 -1 -1
		rgbGen const ( 0.4 0.4 0.4 ) 
	}
}

That shader created this sky:

I’m not sure how; I’m still not the best with shaders yet. I love the sky, its exactly what I want except I need to blend yndar’s shaderlab_1337/water with it that sky. I’m not sure how to go about that. Should I just add another mask? Why are some of my masks acting as if they were the sun (its awesome, but i dont know why)?


(ratty redemption) #14

very nice orange sun set type lighting :slight_smile:

and if you haven`t already, you could try blending the water horizon with the sky using alphamod volume brushes around the outer verts of your water.


(ydnar) #15

Very nice.

One thought though, you should replace the two passes of the last texture with a new, slightly colorized (red/orange) version of the mask texture. Each additional pass on the sky adds a lot of overdraw.


(neotic) #16

mmh ratty, i read up on alphamod volume brush blending. i’m just not sure how to use that here. in that picture of the sky, well that is the only corner that is orange like that, it blends back to gray everywhere else in the sky. so i’d have to blend the water into orange, gray, and blend the orange with the gray as well. i’m just not sure how to go about this. right now i’m playing with the idea of fog which i don’t really want, but it might be the only way to blur the destinct edges of the water.

im going to try that yndar, just to see what it looks like :slight_smile:


(Mr_Tickles) #17

All you have to do is just fade out the edges of the water. Nothing more, you don’t need to blend it into another texture. With the added bonus that it should blend into your sky aswell. :slight_smile:


(neotic) #18

Would it look something like this? I am so lost on what to blend it to, so I made a all white alpha channel, or should it have been black? Or do I just stick a alpha_0 volume brush at the end of this shader’s vertices? I “might” be able to figure this out for myself but that will have to wait till tomorrow afternoon, when I can experiment again… i hate work 8(


textures/neotic_skies/water_blend  // ocean - transparency blend
{
	qer_editorimage textures/liquids_sd/sea_bright_na.tga
	q3map_baseshader textures/battery/ocean_0
	cull none
	surfaceparm trans
	surfaceparm nomarks
	surfaceparm nonsolid
	surfaceparm pointlight
	{ 
		map textures/neotic_skies/white.tga  // transparency
		blendFunc blend
		alphaGen const 0.6  //IMPORTANT MUST MATCH VALUE OF APLHAMOD BRUSH

	}
	{ 
		map textures/liquids_sd/sea_bright_na.tga  // ocean
		blendFunc blend
		rgbGen vertex

	}
}

Ill try again after I get off lifeguarding tomorrow… damn sun doesn’t help me think though! heheh. I am so lost… been reading every thread on this since I got home and I still can’t make much of the blending in reference to my situation.


(Mr_Tickles) #19

An all white alpha channel is not so good for blending textures together, but if you just want to fade it out I think it may be good :slight_smile:

The alpha channel i’ve used below is just a brightened copy of the rgb image.

textures/neotic_skies/water_fade
{
	qer_editorimage textures/neotic/red_water.tga
	qer_trans .5
	q3map_forcemeta
	q3map_nolightmap
	surfaceparm nonsolid
	surfaceparm nomarks
	surfaceparm trans
	q3map_tcgen ivector ( 256 0 0 ) ( 0 256 0 )
	deformVertexes wave 10 sin 0 2 0 .5
	surfaceparm water
	nopicmip
	cull disable  // uncomment to debug
	polygonoffset
	{
		map textures/neotic/water_with_bright_alpha_channel.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbgen vertex
		alphagen oneminusvertex  // inverses the value of the volume alpha
		alphafunc LT128
	}
}

That should do it hopefully :slight_smile:

All you need to do is create a largish water brush (the larger the brush, the wider the blend) and apply the above shader to the surface. Then create an Alpha_0 brush on the two vertexes which are furthest away from the maps edge. If you want to do a corner piece, you need to use multiple Alpha mod brushes. Alpha_0 on the inside corner, and Alpha_25, _50, or even _75 on the two corners adjacent to the _0.

Plus, with these, if you’re just blending to nothing, there is no need to overlay them on anything, just treat them as normal water brushes. Also, you may need to use nodrawwater on the sides of the brush if you’re going to attach them to other piece of water.

Edit:

Sorry, i’ve just tried doing a few test maps with this and can’t seem to get as smooth a blend as i’d hoped. It’s being a bit of a bitch :smiley:

Ydnar, is the blending in the alpha mods done with a gradient style formula or is it done manually from one edge to another? What I mean is, is it possible to have q3map_alphamod scale <any number> or is it just limited to 0, 25, 50, and 75?

[Edit 2]
Ho kay!..
Right…
I’ve played round with it some more and altered the shader above, note the alphaFunc GE128 is now alphaFunc LT128. I’m not too sure on the mechanics of the differences in the GE or LT, but the LT seems to give a better fade out. Fortunately the blending looks very nice now… Unfortunately though it’s the other side that’s giving me problems, I can’t seem to quite match it up with another body of water as shown in the below screenshots. (I hope you can make them out…)

This shows what happens with the alphamod_0

This shows what happens with the alphamod_25

For some reason, the alphamod_0 wants to blend both sides of the water body. So… to bring that back a bit I used the alphamod_25. However, that makes the water more translucent and so the colour doesn’t match up. So… I tried an in-between value, alphamod_10, but for some reason that just makes the whole water disappear (ydnar, that’s my reasoning for the question about the alphamods in edit 1).

I tried darkening the water image for the alphamod_25, but I soon realized the colour was fine and it was just the opacity of it. So… I lightened the alpha channel, this gave the same results as i’d used alphamod_0, which I suppose would be expected.

Also, it seems if you try to overlap an alphamod affected texture with another texture which has an alpha channel, but not necessarily alphamodded, then the alphamod gets confused and sets the vertexes it contains to invisible, which is why I think it could be a good idea to make it so that you have to func_group the alphamods, it would save much trouble and then you would be able to overlap these alphamodded brushes without worry that one would affect another. I could be wrong about that though, I need to do some more testing… :frowning:
[/Edit 2]

[Edit 3]
Reading through my post again, it seems as if I should try to reduce the opacity of the water body i’m trying to link to. This would probably work, but it could also cause knock on effects, i.e. i’d have to change the opacity of the foam aswell. Although that may be the way to do it. I’ll post again the results of that once i’ve tried it :slight_smile:

Hope this is helping people, sorry for all the talk about how I went about doing things, just thought you may want to know.
[/Edit 3]


(neotic) #20

Woooh we, cant wait to dig into that post after work. Thunderstorms woke me up… maybe theyll cancel work for me! Thanks already tickles!