Shader problem!


(HeX|Black) #1

I decided to make a water with a reflection using the portal parameter. The problem is that the surface keeps flashing white while moving. It only occurs wherever there are many brushes together with the mirror surface. I would like help to remove the flashing.

Here is the shader:

textures/blacki_vesi/blacki_vesi_shader2
{
qer_editorimage textures/blacki_vesi/blacki_vesi2.tga
q3map_backsplash 10 30
surfaceparm nolightmap
surfaceparm nonsolid
surfaceparm trans
surfaceparm water
nopicmip
q3map_surfacelight 100
portal
{
map textures/blacki_vesi/blacki_vesi2.tga
tcMod scroll -0.0015 0.0010
tcMod turb 1 0.05 0.03 0.3
blendfunc gl_one gl_one_minus_src_alpha
depthWrite
}
{
map textures/blacki_vesi/pind.tga
blendfunc add
tcMod scroll -0.0005 0.0005
tcMod turb 1 0.02 0 0.1
}
}

Here are some screens of the problem:

The water working correctly in this picture (The reflection isnt noticable from the Thumbnail, view full image to see the reflection)

And moving my mouse around i see flashing of this

I hope this is fixable :X


(Zer0Cool) #2

Another guy asked the same a while ago and found no solution. How many fps do you have in this room?


(HeX|Black) #3

I have normal fps, there is no fps drop with that.

Edit: I think the problem can be fixed with “sort value” But i have no idea about the sort. Quote from Q3 Shader manual.

sort value

Use this keyword to fine-tune the depth sorting of shaders as they are compared against other shaders in the game world. The basic concept is that if there is a question or a problem with shaders drawing in the wrong order against each other, this allows the designer to create a hierarchy of which shader draws in what order.

The default behavior is to put all blended shaders in sort “additive” and all other shaders in sort “opaque”, so you only need to specify this when you are trying to work around a sorting problem with multiple transparent surfaces in a scene.

The value here can be either a numerical value or one of the keywords in the following list (listed in order of ascending priority):

  portal (1): This surface is a portal, it draws over every other shader seen inside the portal,     but before anything in the main view.
  Sky (2): Typically, the sky is the farthest surface in the game world. Drawing this after other opaque surfaces can be an optimization on some cards. This currently has the wrong value for this purpose, so it doesn't do much of anything.
  Opaque (3): This surface is opaque (rarely needed since this is the default with no blendfunc)
  Banner (6): Transparent, but very close to walls.
  Underwater (8): Draw behind normal transparent surfaces.
  Additive (9): Normal transparent surface (default for shaders with blendfunc's)
  Nearest (16): This shader should always sort closest to the viewer, e.g. muzzle flashes and blend blobs.

(pazur) #4

I also experimented with reflective water (but to me it looked more like ice so i never used in a map). Try to add sort 1 or play with higher values as well. In RTCW I didn’t see the problem you describe.

Here is the shader I experimented with:


textures/pazur/mirror_water_surface
{
	qer_editorimage textures/liquids/pool3d_3.tga
	qer_trans .5
	surfaceparm trans
	portal
	surfaceparm nonsolid
	{
		map textures/pazur/mirror1.tga
		blendfunc GL_ONE GL_ONE_MINUS_SRC_ALPHA
		depthWrite
	}
	{
		map textures/liquids/pool3d_5c.tga
		blendFunc GL_dst_color GL_one
		rgbgen identity
		tcmod scale .5 .5
		tcmod transform 1.5 0 1.5 1 1 2
		tcmod scroll -.05 .001
	}
	{
		map textures/liquids/pool3d_6c.tga
		blendFunc GL_dst_color GL_one
		rgbgen identity
		tcmod scale .25 .25
		tcmod transform 0 1.5 1 1.5 2 1
		tcmod scroll .025 -.001
	}
	{
		map textures/liquids/pool3d_3c.tga
		blendFunc GL_dst_color GL_one
		rgbgen identity
		tcmod scale .125 .25
		tcmod scroll .001 .025
	}
	{
		map $lightmap
		blendFunc GL_dst_color GL_zero
		rgbgen identity
	}
}

Add sort 1 just after the portal line. Example of a shader with this parameter:


textures/natter/grass
{
	qer_editorimage textures/natter/grass.tga
	q3map_notjunc
	q3map_nonplanar
	q3map_bounceScale 0.0
	q3map_fur 6 2 0.15
	q3map_forcesunlight
	q3map_globaltexture

	surfaceparm trans
	surfaceparm nonsolid
	surfaceparm noimpact
	surfaceparm nomarks
	nomipmaps
	sort 7
	surfaceparm nolightmap

	{
		map textures/natter/grass.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbGen vertex
		alphaGen vertex
	}
}

I had to use it in this shader because grenade explosions have been behind the shader.


(HeX|Black) #5

Actually that didnt work neither. I have the problem only when multiple brushes with that surface are close together, seeing another portal through a portal is the problem.


(pazur) #6

Ahh I see… I guess that is causing a HOM (hall of mirrors) effect? Correct?

Yea… you can’t have multiple reflections like a raytracing in Q3A engines :wink: (I mean you can but not with the default renderer).

Q3A Raytracing:

My idea would be to have only one brush with the reflective “mirror” shader. Like the water surface… nothing more.


(HeX|Black) #7

Yeah i guess its the hall of mirrors effect.I thought maybe i could block the view with area portal or hint brush but it didnt work.


(Roeltje) #8

[QUOTE=pazur;179787]
Q3A Raytracing:

Speaking about Raytracing, I did a project in school with a Raytracer a teacher of mine wrote.
His Raytracer is one of the fastest around on the globe (the only faster one is from intel (from the Q3 raytraced))

You can check out a vid of our project here:
http://www.photonstudios.nl/video_1/mediaplayer.html

you can also download the game yourself at http://www.photonstudios.nl/

I know this was completely off-topic, but just had to post it xD


(pazur) #9

Cool stuff Roeltje. I love realtime raytracing. I have seen it first in a demo (http://www.digitalekultur.org/en/demos.html) and I was really impressed.