Tremulous Forum

Media => Mapping Center => Topic started by: Evoc on February 07, 2009, 07:49:33 pm

Title: Glass Shader Issues
Post by: Evoc on February 07, 2009, 07:49:33 pm
I have a shader file that describes the shader for two glass textures. One of them is red, the other blue.

The red glass shader works fine, as can be seen below (at the top):

(http://i41.tinypic.com/2poyvqv.jpg)

The blue glass shader, on the other hand, does not work at all, and instead, displays the notex texture:

(http://i41.tinypic.com/3503ype.jpg)

Wherever the red glass appears in the map, it is fine. Wherever the blue glass appears, all I get is the opaque, gray notex texture (it appears gray because the blue texture used in the shader is 1px by 1px, so the notex squares are really small):

The shader file is below:

Code: [Select]
textures/glass/redglass
{
qer_editorimage textures/stcs-glass/red.tga
qer_trans .4
surfaceparm nomarks
surfaceparm trans
{
map textures/stcs-glass/red.tga
blendfunc add
rgbGen const ( 0.1 0.1 0.1 )
}
{
map $lightmap
blendfunc gl_dst_color gl_src_alpha
rgbGen identity
tcGen lightmap
}
}
textures/glass/blueglass
{
qer_editorimage textures/stcs-glass/blue.tga
qer_trans .4
surfaceparm nomarks
surfaceparm trans
{
map textures/stcs-glass/blue.tga
blendfunc add
rgbGen const ( 0.1 0.1 0.1 )
}
{
map $lightmap
blendfunc gl_dst_color gl_src_alpha
rgbGen identity
tcGen lightmap
}
}

BUT, whatever lighting is on the other side of the glass is coming through, so the problem seems to lie in the shader's texture as the rest of the shader works fine.

Also, the red .tga is a 32-bit TGA saved from Photoshop and is 1px by 1px. The blue .tga is the exact same (except it's blue :P).

The paths are all correct, and this is shown by the fact that the shaders both show up in-Radiant like they're supposed to (the texture are there, and they are transparent due to qer_trans).

The shader is listed correctly in the shaderlist.txt file (the file is stcs-glass.shader). Also, the shaderlist.txt file is completely "normal" (once, I added a shader name to it by mistake that didn't exist, and it screwed up everything in-game).

Also, I tried using a completely different glass shader (the Karith plainglass2 one) with the red and blue .tga files, and I tried "cutting back" the glass shader I am using now to the "bare minimum," but the same thing still happened in-game (the red was fine, the blue was notex).

With all of that being said, I could someone provide me with a reason why this is happening and a way to fix it?

Thanks for any and all help!
Title: Re: Glass Shader Issues
Post by: CATAHA on February 07, 2009, 10:30:58 pm
Check console - why shader missing. Or try other image for shader. Just make jpg or something.
Title: Re: Glass Shader Issues
Post by: Archangel on February 08, 2009, 07:41:41 pm
why 1x1px .. D:
Title: Re: Glass Shader Issues
Post by: Evoc on February 08, 2009, 07:58:34 pm
It's just a solid color with nothing else, so why use anything greater than 1px?
Title: Re: Glass Shader Issues
Post by: CATAHA on February 09, 2009, 07:16:23 am
Why you not using .avi or .BMP extension then? Bcaus they not work =]
I think using 1x1 px images in Radiant/Trem can cause errors. But its just my opinion. =D
Try it. It it wont help we will think about other solutions.
Title: Re: Glass Shader Issues
Post by: epsy on February 10, 2009, 06:24:19 am
Perhaps see if it is not outside pure using sv_pure 0
Title: Re: Glass Shader Issues
Post by: Thorn on February 10, 2009, 02:18:25 pm
It'll be converted to 2x2 by the engine anyway, won't it?

Try something more sane such as 32x32, it's not like you're going to lose any space.
Title: Re: Glass Shader Issues
Post by: Archangel on February 10, 2009, 06:05:03 pm
very technically 1x1 would work, i suppose. but I dunno about all of the engine limitations.
Title: Re: Glass Shader Issues
Post by: Odin on February 10, 2009, 07:24:49 pm
You don't need that.
You can use this:
Code: [Select]
textures/glass/redglass
{
qer_editorimage textures/stcs-glass/red.tga
qer_trans .4
surfaceparm nomarks
surfaceparm trans
{
map $whiteimage
blendfunc add
rgbGen const ( 0.1 0 0 )
}
{
map $lightmap
blendfunc gl_dst_color gl_src_alpha
rgbGen identity
tcGen lightmap
}
}
textures/glass/blueglass
{
qer_editorimage textures/stcs-glass/blue.tga
qer_trans .4
surfaceparm nomarks
surfaceparm trans
{
map $whiteimage
blendfunc add
rgbGen const ( 0 0 0.1 )
}
{
map $lightmap
blendfunc gl_dst_color gl_src_alpha
rgbGen identity
tcGen lightmap
}
}
Title: Re: Glass Shader Issues
Post by: Evoc on February 10, 2009, 09:54:49 pm
I will try that in a second and post my results.

What makes the shader different than the one I posted? I do notice that the rgbGen const is different. If you could explain this, it would be great!
Title: Re: Glass Shader Issues
Post by: gimhael on February 10, 2009, 10:00:25 pm
It uses the built-in all-white texture $whiteimage and applies a red resp. blue color to it, so you don't have to pack a separate red and blue texture into your map at all.
Title: Re: Glass Shader Issues
Post by: Evoc on February 10, 2009, 10:15:29 pm
Ah, now I get it. And the .tga's, I'm assuming, are only used for visual references purposes in-Radiant.

Ok, well, I did this, and while both the red and blue displayed, they were completely opaque in color.

(http://i40.tinypic.com/rkst4m.jpg)

(http://i41.tinypic.com/2i7ntkw.jpg)

How would I go about fixing this, and why is it happening?
Title: Re: Glass Shader Issues
Post by: Zero Ame on February 13, 2009, 04:09:36 pm
if your gonna use .TGA files you could just save yourself a lot of time and not use a shader at all, all you need is an alpha layer on the .TGA's thats 50% grey and they will be transperent.
Title: Re: Glass Shader Issues
Post by: gimhael on February 13, 2009, 05:03:41 pm
The alpha channel of the texture isn't used anyway because you use blendfunc gl_add in the first stage.

In the second stage of the shader you multiply the background with the alpha channel of the lightmap. I have no idea what q3map puts in the alpha channel of the lightmaps, but I guess it is 1 for all pixels.

Usually you should only multiply the lightmap to the background, try the blendfunc gl_dst_color gl_zero.
Title: Re: Glass Shader Issues
Post by: Evoc on February 13, 2009, 09:35:23 pm
if your gonna use .TGA files you could just save yourself a lot of time and not use a shader at all, all you need is an alpha layer on the .TGA's thats 50% grey and they will be transperent.

Really? I'll try this and post up the results.

EDIT: Nope, did not work. I made it fifty percent opacity in Photoshop and it just appeared lighter-than-normal in game, but still OPAQUE...

EDIT II: I'll try what gimhael said later.
Title: Re: Glass Shader Issues
Post by: Archangel on February 14, 2009, 12:19:14 am
you didn't follow his directions.  alpha layer 50% grey, not 50% opacity.
Title: Re: Glass Shader Issues
Post by: Evoc on February 14, 2009, 01:25:38 am
How would I go about changing that in Photoshop? :O

EDIT: I changed it, and neither Gimhael's new blendfunc nor Archangel's alpha layer instructions work.
Title: Re: Glass Shader Issues
Post by: Zero Ame on February 14, 2009, 02:49:14 am
look at this evoc
http://www.robinwood.com/Catalog/Technical/SL-Tuts/SLPages/WhiteHalo1.html
Title: Re: Glass Shader Issues
Post by: Evoc on March 13, 2009, 01:25:50 am
It's been almost a month, so I feel as if this is an appropriate bump. Can someone please help me? Nothing in this thread has worked so far...
Title: Re: Glass Shader Issues
Post by: CATAHA on March 13, 2009, 02:43:54 am
May be something with ur trem/compiler/videodrivers then? Some methods posted here rly MUST work.

PS Have no time today, but if u're still have no solution till mondey i'll post you image files and shaders. Dont see any problem with it. =]
Title: Re: Glass Shader Issues
Post by: Ingar on March 13, 2009, 06:50:07 pm
The shader Odin pasted works fine.

I did the following:

1) I created ~/.tremuous/base/scripts/glasstest.shader
I pasted Odin's shaders in there, but I changed the names
to make sure I was using this particular shader:

Code: [Select]
textures/glasstest/redglass
{
        qer_editorimage textures/glasstest/red.tga
        qer_trans .4
        surfaceparm nomarks
        surfaceparm trans
        {
                map $whiteimage
                blendfunc add
                rgbGen const ( 0.1 0 0 )
        }
        {
                map $lightmap
                blendfunc gl_dst_color gl_src_alpha
                rgbGen identity
                tcGen lightmap
        }
}

(the same for the blue glassshader)

Note that I do not have textures/glasstest/red.tga. The qer_editorimage parameter
tells what texture this shader will have in radiant. It has nothing to do with how it
will look in your compiled map.

In my case, it shows up as image not found because I was too lazy to find a red and a blue image.
It doesn't matter because this shader does not use any textures.

(2) I added glasstest to shaderlist.txt

(3) I made a boxmap with a node and an egg

(4) I added two large brushes in the middle. I made them nodraw and then covered
one face of the first brush with glasstest/redglass and one face of the second brush
with glasstest/blueglass.

(5) compiled it

(6) tremulous +set sv_pure 0 +devmap glasstest

(7) screenshot and profit

Notes:

Make sure you do not have a pk3 that contains a shader with the same name. It can produce weird results.
(that's why you want to give your shaders names like yourmap/yourshadername)
Title: Re: Glass Shader Issues
Post by: gimhael on March 13, 2009, 07:35:54 pm
I still think that blendfunc add is not right for a glass effect. Note that it makes the area seen through the "glass" brighter, normally it should be darker, so I think alpha blending or blendfunc filter would fit better.
Title: Re: Glass Shader Issues
Post by: Evoc on March 13, 2009, 09:38:25 pm
We can talk aesthetics later. For now, I'll try what Ingar said.

EDIT: OMG INGAR IS GOD +KARMA +KARMA +KARMA BTW BLENDFUNC FILTER IS TOO DARK FOR THIS MAP'S ATMOSPHERE

LOL INGAR OMG THANKS