Two questions about shaders

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
UglyFoot
Posts: 139
Joined: Fri Jul 22, 2011 12:35 pm

Two questions about shaders

Post by UglyFoot »

I'm trying to change the color of a white fade using a shader but I'm having problems. This is the shader script:

Code: Select all

textures/vr2/blue_cube
{
	qer_editorimage textures/vr2/cube.tga
	surfaceparm trans
	cull disable
	polygonoffset
	q3map_nolightmap
	qer_trans 1
	{
		map textures/vr2/cube.tga
		rgbGen const ( 0 1 1 )
		blendfunc blend
	}
}
cube.tga has the white fade and I tried to change it to cyan (0 1 1), what I'm doing wrong?

I have also a question about gtkradiant. Would be useful to see the two shades in the textures window but when I don't set the editorimage key it puts a "shader image missing" and when I set it with the shader as a texture it puts the same. If I'm not wrong netradiant puts the shader image even without the need of the key, can't gtkradiant (1.5) do the same?
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: Two questions about shaders

Post by obsidian »

You won't need polygonOffset for your cube.

rgbGen const just assigns the surface with a constant vertex colour value, it does not alternate between colours.

To do what I think you want (have it fade between white and cyan in a loop), you'll need to do a few things:
  • 2 shader stages - one for the default white (texture and blendFunc) and a second the exact same except with rgbGen const in the colour of your choice
  • alphaGen wave in both shader stages. This will modify the vertex alpha of each stage.
  • opposite phase values (0 and 0.5) for alphaGen wave. This will make only one stage fully visible at a time.
The basic idea is that you want the white stage to be opaque and then fade to transparent, while the cyan stage starts as transparent and fades to opaque.

See the shader manual in my signature for details.
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
UglyFoot
Posts: 139
Joined: Fri Jul 22, 2011 12:35 pm

Re: Two questions about shaders

Post by UglyFoot »

The idea it's change the color of the white fade to another color, without alternate. But the result is a cube with much more brightness that the white one has.

About polygonoffset, if I don't put it I have Z-fighting on the faces which are touching another face. I've tried sort banner too but for some reason it doesn't work, the part of the cube which is in front of the sky becomes invisible.
Post Reply