Author Topic: Glass Shader Issues  (Read 9005 times)

Evoc

  • Posts: 127
  • Turrets: +13/-12
Glass Shader Issues
« 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):



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



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!
Quote from: ...lying to people about being banned...
Evoc: I JUST GOT BANNED FROM THE FORUMS
Amanieu: lolwut
Thorn: nice
your_face: rofl
Thorn: the less places you can say anything the better

CATAHA

  • Posts: 539
  • Turrets: +8/-18
    • Tremulous Lair
Re: Glass Shader Issues
« Reply #1 on: February 07, 2009, 10:30:58 pm »
Check console - why shader missing. Or try other image for shader. Just make jpg or something.
Russian q3/trem mapping site: http://tremlair.krond.ru/
=[ Boxmaps suck if they have no concept ]=

Ice Trap (InstaGib)

Other maps: A.T.D*S Remake

Archangel

  • Guest
Re: Glass Shader Issues
« Reply #2 on: February 08, 2009, 07:41:41 pm »
why 1x1px .. D:

Evoc

  • Posts: 127
  • Turrets: +13/-12
Re: Glass Shader Issues
« Reply #3 on: February 08, 2009, 07:58:34 pm »
It's just a solid color with nothing else, so why use anything greater than 1px?
Quote from: ...lying to people about being banned...
Evoc: I JUST GOT BANNED FROM THE FORUMS
Amanieu: lolwut
Thorn: nice
your_face: rofl
Thorn: the less places you can say anything the better

CATAHA

  • Posts: 539
  • Turrets: +8/-18
    • Tremulous Lair
Re: Glass Shader Issues
« Reply #4 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.
Russian q3/trem mapping site: http://tremlair.krond.ru/
=[ Boxmaps suck if they have no concept ]=

Ice Trap (InstaGib)

Other maps: A.T.D*S Remake

epsy

  • Posts: 205
  • Turrets: +8/-25
    • Armagetron Advanced!
Re: Glass Shader Issues
« Reply #5 on: February 10, 2009, 06:24:19 am »
Perhaps see if it is not outside pure using sv_pure 0
Warning: All opinions expressed in my posts are mine and mine alone. Any connection to any group I am affiliated with - be it the ArmagetronAd Developers or any other group, is purely coincidental unless otherwise expressly stated. Don't be a dolt when you read my posts, as they *may* require some brainpower and thinking (also purely coincidental). Any opinion in my posts not expressed by me are purely figments of your imagination and will be dealt with accordingly.
SigTemplate by Khasla.

Thorn

  • Guest
Re: Glass Shader Issues
« Reply #6 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.

Archangel

  • Guest
Re: Glass Shader Issues
« Reply #7 on: February 10, 2009, 06:05:03 pm »
very technically 1x1 would work, i suppose. but I dunno about all of the engine limitations.

Odin

  • Spam Killer
  • *
  • Posts: 1767
  • Turrets: +113/-204
    • My Website
Re: Glass Shader Issues
« Reply #8 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
}
}

Evoc

  • Posts: 127
  • Turrets: +13/-12
Re: Glass Shader Issues
« Reply #9 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!
Quote from: ...lying to people about being banned...
Evoc: I JUST GOT BANNED FROM THE FORUMS
Amanieu: lolwut
Thorn: nice
your_face: rofl
Thorn: the less places you can say anything the better

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: Glass Shader Issues
« Reply #10 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.

Evoc

  • Posts: 127
  • Turrets: +13/-12
Re: Glass Shader Issues
« Reply #11 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.





How would I go about fixing this, and why is it happening?
Quote from: ...lying to people about being banned...
Evoc: I JUST GOT BANNED FROM THE FORUMS
Amanieu: lolwut
Thorn: nice
your_face: rofl
Thorn: the less places you can say anything the better

Zero Ame

  • Posts: 329
  • Turrets: +33/-15
    • NOS
Re: Glass Shader Issues
« Reply #12 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.

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: Glass Shader Issues
« Reply #13 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.

Evoc

  • Posts: 127
  • Turrets: +13/-12
Re: Glass Shader Issues
« Reply #14 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.
« Last Edit: February 13, 2009, 11:47:01 pm by Evoc »
Quote from: ...lying to people about being banned...
Evoc: I JUST GOT BANNED FROM THE FORUMS
Amanieu: lolwut
Thorn: nice
your_face: rofl
Thorn: the less places you can say anything the better

Archangel

  • Guest
Re: Glass Shader Issues
« Reply #15 on: February 14, 2009, 12:19:14 am »
you didn't follow his directions.  alpha layer 50% grey, not 50% opacity.

Evoc

  • Posts: 127
  • Turrets: +13/-12
Re: Glass Shader Issues
« Reply #16 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.
« Last Edit: February 14, 2009, 01:53:11 am by Evoc »
Quote from: ...lying to people about being banned...
Evoc: I JUST GOT BANNED FROM THE FORUMS
Amanieu: lolwut
Thorn: nice
your_face: rofl
Thorn: the less places you can say anything the better

Zero Ame

  • Posts: 329
  • Turrets: +33/-15
    • NOS
Re: Glass Shader Issues
« Reply #17 on: February 14, 2009, 02:49:14 am »

Evoc

  • Posts: 127
  • Turrets: +13/-12
Re: Glass Shader Issues
« Reply #18 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...
Quote from: ...lying to people about being banned...
Evoc: I JUST GOT BANNED FROM THE FORUMS
Amanieu: lolwut
Thorn: nice
your_face: rofl
Thorn: the less places you can say anything the better

CATAHA

  • Posts: 539
  • Turrets: +8/-18
    • Tremulous Lair
Re: Glass Shader Issues
« Reply #19 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. =]
Russian q3/trem mapping site: http://tremlair.krond.ru/
=[ Boxmaps suck if they have no concept ]=

Ice Trap (InstaGib)

Other maps: A.T.D*S Remake

Ingar

  • Tremulous Developers
  • *
  • Posts: 554
  • Turrets: +302/-7
    • Ingar's projects on the Web
Re: Glass Shader Issues
« Reply #20 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)

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: Glass Shader Issues
« Reply #21 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.

Evoc

  • Posts: 127
  • Turrets: +13/-12
Re: Glass Shader Issues
« Reply #22 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
« Last Edit: March 13, 2009, 09:58:44 pm by Evoc »
Quote from: ...lying to people about being banned...
Evoc: I JUST GOT BANNED FROM THE FORUMS
Amanieu: lolwut
Thorn: nice
your_face: rofl
Thorn: the less places you can say anything the better