Page 1 of 2
Need a correct window shader for custom texture
Posted: Sat Apr 30, 2005 7:01 am
by diego
I've seen some other posts on windows, but I didn't see anything regarding this particular shader issue.
I made a custom window texture and tried a couple of window frame shaders from Mohaa to make it work. The env map is working fine on the glass. And the window frame is opaque. But I have a lot of shades of gray in the Alpha channel on the glass that are not showing up. Instead it looks as if my Alpha was only black and white.
The image on the left is what I get with the Alpha channel on the right:
http://webpages.charter.net/dt3d/screen ... indows.jpg
Here are 2 almost identical shaders that I tried but neither uses the alpha channel correctly:
Code: Select all
textures/Praetoria/windows/window_transparent_01
{
qer_editorimage textures/Praetoria/windows/window_transparent_01.tga
qer_keyword praetoria
qer_keyword window
qer_keyword glass
qer_trans .4
surfaceparm glass
{
map textures/Praetoria/env/env_bright.tga
tcgen environment
alphagen const .2
blendFunc blend
}
{
map textures/Praetoria/windows/window_transparent_01.tga
depthWrite
alphaFunc GE128
nextbundle
map $lightmap
}
}
textures/Praetoria/windows/window_transparent_01
{
surfaceparm glass
qer_keyword broken
qer_keyword window
qer_keyword glass
// cull none
qer_editorimage textures/Praetoria/windows/window_transparent_01.tga
{
map textures/Praetoria/env/env_bright.tga
tcgen environment
alphagen const .2
blendFunc blend
}
{
map textures/Praetoria/windows/window_transparent_01.tga
// blendFunc blend
depthWrite
alphaFunc GE128
nextbundle
map $lightmap
}
}
Posted: Sat Apr 30, 2005 7:20 am
by jv_map
Get that alphaFunc GE128 outta there
And use blendfunc blend on the window stage.
Posted: Sat Apr 30, 2005 7:27 am
by diego
LOL
It just occured to me to check the scripting forums. Silly me. I'm now using Tom's blue glass shader from his door2 tutorial. It works fine. A bit opaque, I'll tweak it a bit.
Posted: Sat Apr 30, 2005 9:30 am
by diego
Hmm, i have another problem with this window.
The window brush is textured on all sides with nodraw except for the front face. The transparency is working. But if I move into a position where I can see 1 window through another window, the window in the back draws on top of the window in the front. Also, the glass surface parameter does not work.
If I put the window texture on both sides of the brush, the glass surface parameter works, and the draw order seems correct between 2 windows. But I can see both sides of one window at the same time -- ie, the texture is drawn twice.
Posted: Sat Apr 30, 2005 12:18 pm
by jv_map
Hmmm maybe get rid of the 'cull none'

Posted: Sat Apr 30, 2005 8:49 pm
by diego
Dropped the Cull none. The window has nodraw on all surfaces except the outside surface. The inside doesn't draw at all. Surface parameter doesn't work. And the rear windows draw on top black.
http://webpages.charter.net/dt3d/screen ... ndows2.jpg
Here's the shader. I'm not very knowlegable about shaders. I've mostly gotten by with cut-and-paste shaders based on tuts and and stock stuff.
Code: Select all
textures/Praetoria/windows/window_transparent_01
{
qer_editorimage textures/Praetoria/windows/window_transparent_01.tga
qer_keyword window
qer_keyword glass
qer_trans .45
surfaceparm glass
// cull none
{
map textures/Praetoria/env/env_bright.tga
tcgen environment
alphagen const .4
blendFunc blend
}
{
map textures/Praetoria/windows/window_transparent_01.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
}
{
map $lightmap
rgbGen Identity
blendFunc GL_DST_COLOR GL_ZERO
}
}
cull
Posted: Sun May 01, 2005 3:54 am
by tltrude
If you remove "cull none" it defaults to "cull front". At least that is what the shader bible says. Every surface has two sides and if the front is culled, the back surface of the face is all you see. That is why most textures look reversed when you apply them (no cull none in the shader).
The normal windows in the game all have the same problem as your screenshot. I can't remember what fixes it, but you can check my test pointer map for a new window shader that seems to work.
Click on my sig logo to find it.

Posted: Sun May 01, 2005 5:05 am
by diego
One difference I can see is those windows are perfectly clear. It also looks like you are using 2 images with different alpha channels.
What is the .FCM file in your pk3 that is associated with those windows? That's the second time I've seen that for glass, but I can't open that file.
Posted: Sun May 01, 2005 5:50 am
by jv_map
Adding a depthWrite in the 2nd stage should fix it... but you may get transparency problems... (maybe use alphafunc again).
Posted: Sun May 01, 2005 9:41 am
by diego
I can't get any of these shaders to work correctly. I've been going thru the shader manual all day and experimenting with different settings in addition to trying shaders from your tutorials.
The closest I got had all the reflective and transparency effects working, but window frames for windows behind the one I was looking through would draw on top of the reflective glass layer.
Typically, If I use a "blendFunc blend" on the second stage, 1 of 2 things will happen:
The second layer of windows will not draw at all
or the second layer will flicker off and on depending on the camera orientation.
I noticed that even if I disable the 2nd stage completely, and just render the reflective env layer in the first stage, you can see the windows in back pop on and off -- the alpha constant setting has to be pretty opaque to notice it.
I'm more than willing to give up the soft blending for the window frame as long as I can keep the reflective layer drawing in the correct order. Here is my current shader:
Code: Select all
textures/Praetoria/windows/window_transparent_01
{
qer_editorimage textures/Praetoria/windows/window_transparent_01.tga
qer_keyword glass
qer_keyword window
surfaceparm glass
{
map textures/Praetoria/env/env_bright.tga
tcGen environment
alphagen const .5
blendFunc blend
}
{
map textures/Praetoria/windows/window_transparent_01.tga
depthWrite
alphaFunc GE128
// blendFunc blend
nextbundle
map $lightmap
}
}
Here is an image showing with the 2 most successful variations:
http://webpages.charter.net/dt3d/screen ... ndows3.jpg
compile
Posted: Sun May 01, 2005 11:19 pm
by tltrude
Maybe it is the lightmap. Have you tried doing a -final light compile?
Posted: Mon May 02, 2005 3:57 am
by diego
No, I'll give that a shot tonight. It shouldn't take long. I'm only working on 1 building at a time.
---------
Just finished. No difference. So, what are all those .FCM files for?
Posted: Mon May 02, 2005 6:56 am
by jv_map
.fcm I think is a fence mask... presumably helps the game in determining which portions of the windows are solid / wood and which are non-solid / glass.
Posted: Mon May 02, 2005 7:13 am
by Rookie One.pl
Really? Haven't ever noticed a difference in shooting a wooden part of a window, it all sounded glass...
From what I can see the depth test for the windows is enabled only kind of partially. Try adding a depthFunc lequal to the first stage. Just mess with depthFunc and depthWrite, add them in random combinations in random places.

Posted: Mon May 02, 2005 9:29 pm
by diego
Well, that's what I have been doing. I've gone through two versions of the shader manual trying to find a combination of settings that works.
If I keep the GE128 on the 2nd stage, the window frame at least draws in the correct order and the 2nd layer of window frames doesn't pop on and off. But the window frames always draws on top of the first stage of reflection. If I turn down the alpha const on the reflection texture, this is not as noticable, but it's still wrong.
One thing I noticed in Tom's broken window shader, he is actually using 2 textures to make that work. One texture has the broken glass in it and he is blending it with the reflection map. The second texture used in the second stage has just the frame in the alpha channel and that has the GE128 blending.
I didn't want to make a 3rd texture but I'll give it a shot.
Regardign FCM files. I saw something online about it being a "Forward Compression Map". But that might not necessarily be the correct filetype for q3 games. I downloaded a tool that is supposed to compress and uncompress FCM files, but I couldn't get it to work.