global fog/sky glitch


(Quaker-X) #1

I seem to have come across a problem with my global fog. I have a high cliff, the very top which sits high above the fog, then the very bottom with a small “beach” and water. The fog works perfectly on both levels (top of cliff and beach), however on the beach level, certain angles the sky appears through the fog.

Using the latest (2.5.7) Q3Map2. A few screens explaining the problem.

  1. Top of cliff, looks fine.

  2. Beach area, looks fine.

  3. Beach area again, this time showing the sky glitch to the right.

I’m sure theres some simple answer to this, always is. Thanks in advance.


(ydnar) #2

Does the fog have a surface?

y

Edit: Post your fog and sky shaders. :slight_smile:


(Quaker-X) #3

Fog shader:


textures/qxdm4/qxfog_global
{
	qer_editorimage textures/sfx/fog_grey.tga
	qer_trans 0.4
	surfaceparm nolightmap
	surfaceparm nonsolid
	surfaceparm trans
	surfaceparm fog
	fogparms ( 0.5 0.5 0.5 ) 1024
}

Sky shader: (modified slterra sky)


textures/qxdm4/qxdm4_sky
{
	qer_editorimage textures/qxdm4/sky_arc_masked.tga
	
	q3map_lightsubdivide 768
	q3map_backsplash 0 0
	q3map_sun 1 1 1 100 180 90
	q3map_surfacelight 50

	surfaceparm sky
	surfaceparm noimpact
	surfaceparm nolightmap
	
	skyparms textures/qxdm4/env/sky 512 -
	
	nopicmip
	nomipmaps
	
	{
		map textures/qxdm4/sky_clouds.tga
		tcMod scale 3 3
		tcMod scroll 0.005 -0.0125
		rgbGen identityLighting
	}
	{
		clampmap textures/qxdm4/sky_arc_masked.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 identityLighting
	}
}


(ydnar) #4

Your fog shader needs a surface stage in order to correctly fog stuff outside when the eye is inside the fog:


{
    map *white
    blendFunc GL_ZERO GL_ONE
}

Should do.

Also, you can compress the tcMod lines in the sky shader into one line:


    tcMod transform 0.956 0 0 0.956 -1 -1

Though I don’t recall if that’s actually required for RTCW/ET. Check the sky shader for Battery. That one is also based on the slterra sky, but with ET-specific fixes (like q3map_skyLight, which is superior to q3map_surfacelight for sky shaders).

y


(Quaker-X) #5

Like this?


textures/qxdm4/qxfog_global 
{ 
   qer_editorimage textures/sfx/fog_grey.tga 
   qer_trans 0.4 
   surfaceparm nolightmap 
   surfaceparm nonsolid 
   surfaceparm trans 
   surfaceparm fog 
   fogparms ( 0.5 0.5 0.5 ) 1024 
   { 
    	map *white 
    	blendFunc GL_ZERO GL_ONE 
   }
} 

No work for me, still same result.


(Quaker-X) #6

Anyone?


(]UBC[ McNite) #7

Adding the 2 lines like Ydnar suggested doesn’t change anything for me… although my prob is not clipping of brushes but correct clipping of the watersurface.

I guess it got something to do with the blending that s used in the watershader, because the fog clips all normal surfaces fine. Can’t figure out what it is though.
This is the thread to this prob in the ET forum:
http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&p=100629#100629


(ydnar) #8

Not all shaders can be fogged. Can you post your water shader?


(]UBC[ McNite) #9

Sorry, didn’t look at this forum for some days. This is the water-shader.

// after siwa_water2:
textures/river2nd_t/rv2nd_water // surface of water - no proper fogclipping
{
	// nocompress // no idea why this is here
	qer_editorimage textures/river2nd_t/rv2nd_water.tga
	qer_trans 0.5
	qer_nocarve

	q3map_globaltexture

	// surfaceparm nomarks
	surfaceparm nonsolid
	// surfaceparm trans //disabled to make surface opaque
	surfaceparm water

	// surfaceparm fog // fog inside the watershader 
	// fogparms ( 0.08 0.18 0.17 ) 2048 // disabled cuz doesnt work

	cull none
	nopicmip

	deformVertexes wave 64 sin .25 .25 0 .5 

	nofog //disable to have the water clipped by fog but it makes the surface transparent then and u get worldspawn fog in the water
	// waterfogvars ( 0.08 0.18 0.17 ) 0.2 // ( 0.11 0.13 0.15 ) 0.2

	{
		fog on
		map textures/river2nd_t/rv2nd_water.tga
		blendFunc blend
		alphaFunc GE128
		rgbgen identity
		tcmod scale 1 1 //0.5 0.5
		tcmod scroll -0.2 -0.1//-.02 -.001
	}
	{
		fog on
		map textures/liquids_sd/seawall_ripple1.tga
		blendFunc GL_ONE GL_ONE
		rgbGen wave sin 0.3 0.02 0 0.25
		tcmod scale 0.01 0.01 // me: 0.04 0.05
		tcmod scroll .0025 -.0015 // -.001 -.0002
	}
	{
		fog on
		map textures/liquids_sd/seawall_ripple1.tga
		blendFunc GL_ONE GL_ONE
		rgbGen wave sin 0.1 0.03 0 0.4
		tcmod scale 1 1
		tcmod scroll .009 -.006 //old:.005 .003
	}
	{
		fog on
		map textures/liquids_sd/siwa_shimshim1.tga
		blendFunc GL_ONE GL_ONE
		rgbGen wave sin 0.4 0.02 0 0.3
		tcmod transform 0 1.5 1 1.5 2 1
		tcmod scroll .01 .01 //.005 -.001
	}
}

From what I found out it seems to be the blendings… the Battery ocean1 works fine with fog, but I wasn’t able to make it non-transparent. The ocean0 clips even better, but using my textures in it makes it look as if the different blends are (z-)fighthing each other then. However I need opaque water for the gameplay.

My derivate of the ocean1 shader:

textures/river2nd_t/rv2nd_water1
{
	q3map_baseshader textures/river2nd_t/river_base
	cull none
	deformVertexes wave 1317 sin 0 2.5 0 0.15
 	deformVertexes wave 317 sin 0 1.5 0 0.30
//	{
//		map textures/liquids_sd/seawall_specular.tga //disabled this assuming its for the sun-on-water-effect, but it made no significant difference to my prob
//		blendFunc GL_ONE GL_ONE
//		rgbGen vertex
//		tcGen environment
//		depthWrite
//	}

	{ 
		map textures/river2nd_t/rv2nd_water_02_d03.tga
		blendFunc blend
		rgbGen identity
		// alphaGen const .8
		tcmod scale 1 1 //0.5 0.5 //from siwa
		tcmod scroll -0.2 -0.1 //-.02 -.001 battery: 0.005 0.03
	}
	{
		map textures/liquids_sd/seawall_ripple1.tga
		blendFunc GL_SRC_ALPHA GL_ONE
		rgbGen wave sin 0.2 0.1 0 0.2
		alphaGen vertex
		tcMod turb 0 0.05 0 0.15
		tcmod scale 0.01 0.01 // me: 0.04 0.05
		tcmod scroll .0025 -.0015 // -.001 -.0002
	}
	{ 
		map textures/liquids_sd/seawall_ripple1.tga
		blendFunc GL_SRC_ALPHA GL_ONE
		rgbGen wave sin 0.15 0.1 0.1 0.15
		alphaGen vertex
		tcMod turb 0 0.05 0.5 0.15
		tcmod scale 1 1 //0.5 0.5 //from siwa
		tcmod scroll .009 -.006 //old:.005 .003
	}
}

Should I say that I have no clue here what I m doing? lol… this is real trial and error when I mess with the shaders :smiley:

This is the original thread on this prob in the ET forum where I posted a lot more details on what I tried so far:
http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=10247

This is another thread on bad clipping and fog, this time for sky-fog and terrain:
http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=10396


(ydnar) #10

ET fog is another pass, and needs the shader to be written to the z-buffer. Since you disabled the stage with z-write, it won’t be fogged.

Additionally, your first stage uses blendFunc blend, which will result in sorting errors because Q3 engine surfaces are not depth sorted.

Take the Battery ocean shader as-is, and simply remove the first stage blendFunc to make it opaque.

y