Shader problems. I need someone to look my scripting over.

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
Magnus
Posts: 529
Joined: Wed Feb 16, 2005 6:38 pm

Shader problems. I need someone to look my scripting over.

Post by Magnus »

Hello again.

I made a shader that uses two textures that are supposed to rotate around the center point of the brush.
Here is the first texture Image It is supposed to rotate counter clockwise at one revolution every two seconds.
Here is the second texture Image It is supposed to rotate clockwise at one revolution every second and overlay on top of the first texture.

Here is the problem.

It performs the proper actions and is the proper size, but it looks WAY overly bright and washed out.

See here is how it should look
Image

But this is how it looks ingame
Image

I have been through the q3map2 shader manual at
http://shaderlab.com/q3map2/shader_manual/index.html
and I am pretty sure I understand most of it fairly well by now.

That being said I can't see any parts of my script that would cause my shader to look like that ingame, but maybe one or some of you with way more experience will spot something I missed.

Anyway here is my shader script

textures/sfx/coreflame1
{
surfaceparm nonsolid
surfaceparm nomarks
sort additive

{

clampmap textures/sfx/coreflame1.tga
blendFunc add
//depthWrite
//tcMod stretch sin .9 0.1 0 .5
tcmod rotate -180
rgbGen identity
}
{
clampmap textures/sfx/coreflame2.tga
blendFunc add
//depthWrite
//tcMod stretch sin .9 0.1 0 .1
tcmod rotate 360
rgbGen identity
}
{
map $lightmap
rgbGen identity
blendFunc GL_DST_COLOR GL_ZERO
depthFunc equal
}
}

So anyone see anything wrong with my scripting that would cause the shader to look so washed out and bright?

Thanks.
Uh, well....good luck with that. :shrug:

[img]http://i57.photobucket.com/albums/g228/Magnus3204/forumheader.jpg[/img]
Shallow
Posts: 167
Joined: Wed Feb 09, 2005 1:58 pm

Post by Shallow »

Blendfunc add brightens whatever you draw on top of. Two additive stages on top of the white background (from the brushes behind) is pretty much guaranteed to blow out to white, unless the textures are really dark.

Lose the additive on the first stage, or use a much darker texture on the brushes behind this shader. (May not be what you are looking for - if the swirl is supposed to be a round shape you may also need to add an alpha channel to act as a circular mask)

For the second stage you should really make the texture the same size as the first. Add dead (black) space around the edges of your inner blob texture and airbrush it inwards onto the existing texture to avoid sharp edges. Black will leave the texture on the previous stage behind unchanged when it is added.

Also try commenting out the lightmap stage - it's usually unnecessary for a glowy effects shader.

Consider using a waveform for your rgbgen as well, it'll probably look more lively and interesting.
User avatar
Hipshot
Posts: 1547
Joined: Sun Jan 20, 2002 8:00 am

Post by Hipshot »

Strange, I have almost the same effect in my map, and used a vortex before... strange coincident...

Yea, skip the lightmap, not needed, and will probably only look wrong...
Q3Map2 2516 -> http://www.zfight.com/misc/files/q3/q3map_2.5.16_win32_x86.zip
Q3Map2 FS_20g -> http://www.zfight.com/misc/files/q3/q3map2_fs_20g.rar
GtkRadiant 140 -> http://www.zfight.com/misc/files/q3/GtkRadiantSetup-1.4.0-Q3RTCWET.exe
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Post by obsidian »

You should rename your textures/shader to something like textures/magnus_sfx/coreflame1 to prevent overwriting issues.

You don't need to specify sort additive, this is implied and generally not necessary.

depthWrite and depthFunc equal not necessary in any of your stages unless you are doing any kind of depth-testing... for example stuff like transparent grate shaders.

Instead of blendFunc add, try using blendFunc blend with an alpha-channel as well as some of the other explicit blendFuncs.
[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]
Magnus
Posts: 529
Joined: Wed Feb 16, 2005 6:38 pm

Post by Magnus »

Blendfunc add brightens whatever you draw on top of. Two additive stages on top of the white background (from the brushes behind) is pretty much guaranteed to blow out to white
I see. So my script would be fine if it were in like a spacemap with a black sky.
if the swirl is supposed to be a round shape you may also need to add an alpha channel to act as a circular mask
Add dead (black) space around the edges of your inner blob texture and airbrush it inwards onto the existing texture to avoid sharp edges
Tried both of those.

With the alpha chanel instead of the alpha areas looking transparent they look white and with the dead black areas they still look dead black ingame.
I figure it must be my scripting.
This behaivior is something I am sill trying to learn about.
Strange, I have almost the same effect in my map, and used a vortex before... strange coincident...
As most folks can see what I did was took the "fireswirl" texture from the default Q3A textures/sfx/fireswirl and removed the small swirl in the middle and then smudged the outer ring into the center in a spiral to create coreflame1
Then I took the small swirl from the middle and smudged it out in a spiral to the edges of the image to create coreflame2
You should rename your textures/shader to something like textures/magnus_sfx/coreflame1 to prevent overwriting issues.
Never thought about that. That would truly suck. I'll go change that now. Thanks.
depthWrite and depthFunc equal not necessary in any of your stages unless you are doing any kind of depth-testing... for example stuff like transparent grate shaders.
So that is part of why it looked so washed out and bright. With me scripting it that way and it being against a bright fog background made it take on the brightness of everything around it as well.

Well I ended up writing a seperate script for coreflame1 and coreflame2 and the created a large 256x256x1 unit 16 sided brush for the coreflame1 and a medium 64x64x1 unit 16 sided brush for coreflame2.
Then I just placed the coreflame2 brush centered on top of and below the coreflame1 brush.
It seems to look and work great ingame.

Here is the final result.

The outer metal ring with the spikes on bottom and lamps on top rotates around the whole thing as well.

From below:

Image

And from above:

Image

As you can see the fog kind of makes it look hazed out, but it is fog after all.


Well thanks to you all for the help. I'll keep going over the q3map2 shader manuel untill this stuff becomes second nature.
Uh, well....good luck with that. :shrug:

[img]http://i57.photobucket.com/albums/g228/Magnus3204/forumheader.jpg[/img]
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Post by obsidian »

You have 3 preset blendFuncs that are commonly used, add, filter and blend. There are other explicit blendFuncs, but those 3 are the most commonly used.

blendFunc add is commonly used for "glowing" effects like fire or energy effects. Problem is, if you are overlaying multiple additive stages together, the total result of the end pixels will ultimately result in pure white.

blendFunc filter is subtractive. It is generally used to darken a texture (like lightmaps for example - used to create shadows which darken the base texture).

blendFunc blend is used when you have alphachannels in the texture, where you need to make specific parts of the texture transparent, and other parts opaque.
[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]
Magnus
Posts: 529
Joined: Wed Feb 16, 2005 6:38 pm

Post by Magnus »

Thanks obsidian.

I was just going back over chapter 6 with Stage Specific Shader Keywords.

I am starting to see where I went wrong in my first script.

See I wanted it to glow a bit so at first I put a colored light in the middle of it, but when I compiled it it gave me a warning.
I looked it up and found that it was besause I placed the light in solid.
That was when I wrote my script the way I did, but I didn't know at the time that it would double up on the brightness especially with the fog being light emiting on it's own.
So now what I have done is created a light about 256 units under the teleporter with a radius equal to the fire part of the teleporter and placed a target_position 1 unit under it and colored the light and then connected the light to the target_position so it is a colored spotlight. Then I done the same thing above the teleporter.
It looks great!

Thank for all the help on this one.
Uh, well....good luck with that. :shrug:

[img]http://i57.photobucket.com/albums/g228/Magnus3204/forumheader.jpg[/img]
Post Reply