help with rgbgen wave


(The5thHorsemen) #1

I’m trying to create a lightning bolt …

I’m trying to make a shader that will peak for second and and then stay off for about 10 or more second’s

I can get the flash but I can’t sem to figure out the right value’s to have it shift from peak to off and then have it stay off …

here’s what I have so far…


//lighning

textures/5th_test/litng
{
    qer_editorimage textures/5th_test/litng.tga
    qer_trans 0.5
    qer_nocarve
//    cull disable
//    deformVertexes autoSprite
    q3map_surfacelight	 5000
    surfaceparm nomarks
    surfaceparm nonsolid
    surfaceparm trans
    surfaceparm pointlight

	{
		map textures/5th_test/litng.tga
		blendfunc GL_ONE GL_ONE
		rgbgen wave Inversesawtooth 0.0 5 0 1
	}
 }

I seem to be unable to come up with the right wave value’s to get the effect I’m looking for …


		rgbgen wave Inversesawtooth 0.0 5 0 1

any idea’s would be appreciated.


(Shallow) #2

How I’d do it: Your main wave should have a fairly high amplitude like 8 or 10 and a big negative base so that only the very top of the waveform gives a positive value (e.g. amplitude 10, base -9). I’d probably add an rgbGen wave noise to the same stage, to make it flickery insead of just flashing.

Might be mileage in using a long square wave to eliminate every other peak or alternating groups of peaks, but the inversesawtooth (or triangle?) plus noise should be enough really.


(Fracman) #3

You could just use noise instead of InverseSawtooth in your shader:
rgbgen wave noise 0.0 5 0 2
This should give you a much more natural behavior of the lighting.


(The5thHorsemen) #4

it’s getting there…

it still needs allot of tweaking but I’m allot closer…

the noise seems to work the best…

//lighning

textures/5th_test/litng
{
    qer_editorimage textures/5th_test/litng.tga
    qer_trans 0.5
    qer_nocarve
//    cull disable
//    deformVertexes autoSprite
//    q3map_surfacelight	 5000
    surfaceparm nomarks
    surfaceparm nonsolid
    surfaceparm trans
//    surfaceparm pointlight

	{
		map textures/5th_test/litng.tga
		blendfunc GL_ONE GL_ONE
		rgbgen wave noise -9 10 0 2 
	}
 }

here are 2 shots from the test…

any idea’s on how to set up a target speker to trigger in sync with the wave?


(Fracman) #5

you don’t necessarily need to sync the flash with the sound, some lightings only appear between clouds and don’t make noise at all, so you could use random lightning and random sounds :wink:

But if you absolutely want to sync, you could use a func_timer with random timer, targetting a brush that gets the lighting shader (You’ll have to remove the “noise” from RGB Gen!) and a target_speaker (the sound file should have a minor delay between its start and the thunder sound).


(ydnar) #6

If you have Enemy Territory, look at the console background shader to see how I set up the lightning rgbGen/alphaGen there.

y


(The5thHorsemen) #7

I tried out the ET shader …

but it will say image error somthing about tried FUNC 6 …

so I canceled out part’s of the shader untill it worked…

but now it crash’s if you are in spec mode and go out side the binding box.

I get a message Max verticales reached unable to full in cloudysky side…

it does look nice though when it 's working…


textures/5th_test/wurzburg_sky
{
	qer_editorimage textures/5th_test/wurzburg_view.tga
        q3map_lightStyle 2
	surfaceparm noimpact
	surfaceparm nolightmap
	q3map_globaltexture
	q3map_lightsubdivide 512
	q3map_surfacelight 40
	surfaceparm sky
	q3map_sun 0.937252 0.932634 1.000000 50 30 45.69
	skyparms env/wurzburg/sky 512- -
    {
		map textures/5th_test/wurzburg_clouds.tga
		rgbGen identityLighting
		tcMod scale 1.5 .75
		tcMod scroll 0.01 -0.005
	}
	{
		map textures/5th_test/wurzburg_clouds.tga
		blendFunc GL_DST_COLOR GL_ONE
		rgbGen identityLighting
		tcMod scale 1.25 .85
		tcMod transform 0 1 1 0 0 0
		tcMod scroll 0.03 -0.015
	}
	{
		map textures/5th_test/ydnar_lightning.tga
		blendFunc GL_SRC_ALPHA GL_ONE
		rgbGen wave triangle -8 9 0.33 0.137
//		alphaGen wave noise -3 4 0 2.37
		tcMod scale 2 1
		tcMod scroll 0.002 -0.0025
//	}
//	{
//		clampmap textures/5th_test/colditz_mask.tga
//		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
//		rgbGen identityLighting
//		tcMod scale 0.85 0.5
//		tcMod transform 1 0 0 1 -0.075 0.42
	}
}

here is the original shader I found in et…

console-16bit
{
	nopicmip
	{
		map textures/skies_sd/wurzburg_clouds.tga
		rgbGen identityLighting
		tcMod scale 1.5 .75
		tcMod scroll 0.01 -0.005
	}
	{
		map textures/skies_sd/wurzburg_clouds.tga
		blendFunc GL_DST_COLOR GL_ONE
		rgbGen identityLighting
		tcMod scale 1.25 .85
		tcMod transform 0 1 1 0 0 0
		tcMod scroll 0.03 -0.015
	}
	{
		map textures/skies_sd/ydnar_lightning.tga
		blendFunc GL_SRC_ALPHA GL_ONE
		rgbGen wave triangle -8 9 0.33 0.137
		alphaGen wave noise -3 4 0 2.37
		tcMod scale 2 1
		tcMod scroll 0.002 -0.0025
	}
	{
		clampmap textures/skies_sd/colditz_mask.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbGen identityLighting
		tcMod scale 0.85 0.5
		tcMod transform 1 0 0 1 -0.075 0.42
	}
}

(ydnar) #8

Right.

There were a couple bugs in the renderer that were fixed to get that shader to work in ET.

If you want to use it in lesser games :cough: swap the alphaGen and the rgbGen (make the rgbGen use noise), and remove one of the cloud stages. Quake 3 only supports up to 3 stages per sky shader before borking.

y


(The5thHorsemen) #9

ok I redid the whole thing…

here is the skybox as it is now…
http://spiderdemon007.home.comcast.net/storm.zip

I left out the lighting bolt md3 it just want looking very good…

I used just about every suggestion here and came up with a really cool stormy skybox that I use along with a matching style’s light that really makes this skybox shine…

I made my own image’s from a few Phtotshop How to site’s,
tutuorial’s on lightning , I found on the net.

here are 2 screen shots :
they look much better ingame…

here is the final shader…

//lightning sky


textures/5th_starsky/stormsky_skybox
{
	qer_editorimage textures/5th_test/wurzburg_view.tga
	surfaceparm noimpact
	surfaceparm nolightmap
	q3map_globaltexture
	q3map_lightsubdivide 512
	q3map_surfacelight 40
	surfaceparm sky
	q3map_sun 0.937252 0.932634 1.000000 50 30 45.69
	skyparms env/5th_starsky/starzsky 512- -
    {
    map textures/5th_clouds/clouds-5.tga
    blendfunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
    tcMod scale 3 3
    tcMod scroll 0.003 0.005
	}
	{
		map textures/5th_clouds/ltg_1.tga
		blendFunc GL_SRC_ALPHA GL_ONE
		rgbGen wave triangle -8 9 0.33 0.137
		tcMod scale 2 1
		tcMod scroll 0.002 -0.0025
	}
}

I’m always looking to improve on stuff so if you download it and improve it let me know…


(Fracman) #10

Looks nice!

Crazy idea: you could make a ROQ video (with sound!) of some lighting and use is as videomap !?