Quake3World.com Forums
     Level Editing & Modeling
        broken glass shader [solved]


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: broken glass shader [solved]

Insane Quaker
Insane Quaker
Joined: 31 Mar 2009
Posts: 494
PostPosted: 04-19-2015 07:46 PM           Profile Send private message  E-mail  Edit post Reply with quote


hey guys,

shader noob question here. i've been trying to figure this out but i can't find a specific example of this having been done before (or maybe i'm just not thinking creatively enough).

i'm trying to make a broken glass shader. i'd like the glass to be translucent, as in blendfunc filter, with an env map, but i also want to have an alpha channel where the hole in the glass is.

could someone help me modify this shader to include an alpha channel?

Code:
textures/phdm5/glass_break1
{
        qer_editorimage textures/phdm5/glass_break1.tga
        qer_trans 0.9
        surfaceparm nolightmap
   surfaceparm nodlight
        surfaceparm trans
        {
                map textures/phdm5/glass_break1.tga
                blendfunc filter
        }
        {
                map textures/phdm5/glass_env.tga
                blendfunc add
                rgbGen identity
                tcGen environment
        }
}


as it stands, the alpha channel is not showing up in game. i tried blendfunc blend and that got the alpha channel working, but i also lost the translucency of the glass. i also tried just using grey in the alpha channel for the glass and black in the alpha channel for the hole with blendfunc blend, but then the texture appeared overly bright compared to blendfunc filter.

any help appreciated. thanks,
pat




Last edited by Pat Howard on 04-24-2015 05:43 PM, edited 1 time in total.

Top
                 

Commander
Commander
Joined: 10 Apr 2015
Posts: 137
PostPosted: 04-20-2015 03:36 AM           Profile Send private message  E-mail  Edit post Reply with quote


I was going to say, as long as the alpha channel has grey for the glass and black for the hole, it should work theoretically. If it's appearing too bright in game, then try adding "rgbGen lightingDiffuse" under blendfunc blend

and if its still too bright, try changing glass_env to "rgbGen lightingDiffuse" aswell




Top
                 

Insane Quaker
Insane Quaker
Joined: 15 Feb 2010
Posts: 298
PostPosted: 04-20-2015 02:08 PM           Profile Send private message  E-mail  Edit post Reply with quote


Code:
textures/phdm5/glass_break1
{
   qer_editorimage textures/phdm5/glass_break1.tga
   qer_trans 0.9
   surfaceparm nolightmap
   surfaceparm nodlight
   surfaceparm nomarks
   surfaceparm trans
   cull disable
   {
      map textures/phdm5/glass_break1.tga
      blendfunc filter
      rgbGen identity
      depthWrite
      alphaFunc GE128
   }
   {
      map textures/phdm5/glass_env.tga
      blendfunc add
      rgbGen identity
      tcGen environment
      depthFunc equal
   }
}


Or with a lightmap: (dark areas reflect more...)

Code:
textures/phdm5/glass_break1
{
   qer_editorimage textures/phdm5/glass_break1.tga
   qer_trans 0.9
   surfaceparm nodlight
   surfaceparm nomarks
   surfaceparm trans
   cull disable
   {
      map textures/phdm5/glass_break1.tga
      blendfunc filter
      rgbGen identity
      depthWrite
      alphaFunc GE128
   }
   {
      map $lightmap
      blendfunc filter
      rgbGen identity
      tcGen lightmap
      depthFunc equal
   }
   {
      map textures/phdm5/glass_env.tga
      blendfunc add
      rgbGen identity
      tcGen environment
      depthFunc equal
   }
}



_________________
Q3A Maps - by sst13
Quake Live Workshop


Top
                 

Insane Quaker
Insane Quaker
Joined: 31 Mar 2009
Posts: 494
PostPosted: 04-20-2015 04:13 PM           Profile Send private message  E-mail  Edit post Reply with quote


@sst13: thanks, but those shaders made the glass too dark.



i'd like to have an alpha on the broken glass but still have it look similar to the surrounding unbroken glass. maybe it's not possible without using a grey alpha? i could do it this way but it seems a bit like a hack and it would take a bit of fiddling to get it to look like a standard blendfunc filter.

here are the textures i am using:
glass_break1.tga
glass_env.jpg
glass.jpg




Top
                 

Old Skool'
Old Skool'
Joined: 02 May 2002
Posts: 5230
PostPosted: 04-20-2015 05:07 PM           Profile Send private message  E-mail  Edit post Reply with quote


Instead of faking it, why not simply break the glass instead? :)




Top
                 

Insane Quaker
Insane Quaker
Joined: 15 Feb 2010
Posts: 298
PostPosted: 04-20-2015 06:49 PM           Profile Send private message  E-mail  Edit post Reply with quote


Note: Both of my test shaders got the same name. You maybe used the lightmapped one accidentally...

So if this is your glass shader:
Code:
textures/phdm5/glass
{
   qer_editorimage textures/phdm5/glass.tga
   qer_trans 0.9
   surfaceparm nolightmap
   surfaceparm nodlight
   surfaceparm trans
   {
      map textures/phdm5/glass.tga
      blendfunc filter
      rgbGen identity
   }
   {
      map textures/phdm5/glass_env.tga
      blendfunc add
      rgbGen identity
      tcGen environment
   }
}


This should be the matching "broken" one:
Code:
textures/phdm5/glass_break1
{
   qer_editorimage textures/phdm5/glass_break1.tga
   qer_trans 0.9
   surfaceparm nolightmap
   surfaceparm nodlight
   surfaceparm trans
   {
      map textures/phdm5/glass_break1.tga
      blendfunc filter
      rgbGen identity
      depthWrite
      alphaFunc GE128
   }
   {
      map textures/phdm5/glass_env.tga
      blendfunc add
      rgbGen identity
      tcGen environment
      depthFunc equal
   }
}



_________________
Q3A Maps - by sst13
Quake Live Workshop


Top
                 

Insane Quaker
Insane Quaker
Joined: 31 Mar 2009
Posts: 494
PostPosted: 04-20-2015 09:01 PM           Profile Send private message  E-mail  Edit post Reply with quote


@sst13: thanks for your help again. both shaders appear darker like that. do you have a different result on your end?

@fjoggs: i could, but i thought the shapes would be more interesting and realistic this way.




Top
                 

surfaceparm nomarks
surfaceparm nomarks
Joined: 10 Aug 2009
Posts: 1018
PostPosted: 04-21-2015 01:08 PM           Profile Send private message  E-mail  Edit post Reply with quote


Pat Howard wrote:
@fjoggs: i could, but i thought the shapes would be more interesting and realistic this way.


It's also good from a tris count point of view. Though I don't know how much alpha channel shaders hit - in terms of performance, compared to say 100 more polygons.



_________________
Portfolio
Twitter


Top
                 

Insane Quaker
Insane Quaker
Joined: 15 Feb 2010
Posts: 298
PostPosted: 04-21-2015 02:05 PM           Profile Send private message  E-mail  Edit post Reply with quote


Pat Howard wrote:
@sst13: thanks for your help again. both shaders appear darker like that. do you have a different result on your end?.

Looks pretty much ok on my end:
Image

Pat, can you post your (unbroken) glass shader?


cityy wrote:
Though I don't know how much alpha channel shaders hit - in terms of performance, compared to say 100 more polygons.

It depends on how much you can see through the alpha tested texture. In this case (only the skybox) it wouldn't eat up much performance.
A bad idea would be to view bigger parts of the map through such a shader. (using this PC) :owned:



_________________
Q3A Maps - by sst13
Quake Live Workshop


Top
                 

Insane Quaker
Insane Quaker
Joined: 31 Mar 2009
Posts: 494
PostPosted: 04-21-2015 08:23 PM           Profile Send private message  E-mail  Edit post Reply with quote


sst13 wrote:
Looks pretty much ok on my end


yeah, that is exactly what i'm after.

i'm using the both the shaders you posted, the unbroken and the matching broken one. :confused:




Top
                 

The Afflicted
The Afflicted
Joined: 11 Mar 2015
Posts: 848
PostPosted: 04-22-2015 12:27 AM           Profile Send private message  E-mail  Edit post Reply with quote


Intresting Post!
Seems the Crack in Pats "Glass" goes up to the right - and in ssts "glass" it moves up to the left.
Maybe it make a difference which side oft the brush you put the texture on? In the 2 shots they display different/ mirrored.
Was just an idea :)



_________________
Die Vitamine sind in der Dose gefangen!!!


Top
                 

Old Skool'
Old Skool'
Joined: 02 May 2002
Posts: 5230
PostPosted: 04-22-2015 01:16 PM           Profile Send private message  E-mail  Edit post Reply with quote


cityy wrote:
Pat Howard wrote:
@fjoggs: i could, but i thought the shapes would be more interesting and realistic this way.


It's also good from a tris count point of view. Though I don't know how much alpha channel shaders hit - in terms of performance, compared to say 100 more polygons.


Yeah those 100 extra tris sure add up huh? :p




Top
                 

The Afflicted
The Afflicted
Joined: 11 Mar 2015
Posts: 848
PostPosted: 04-22-2015 04:37 PM           Profile Send private message  E-mail  Edit post Reply with quote


I also think its better to get the Shader to work well, brushing out broken glass is soo Q2-style :(



_________________
Die Vitamine sind in der Dose gefangen!!!


Top
                 

surfaceparm nomarks
surfaceparm nomarks
Joined: 10 Aug 2009
Posts: 1018
PostPosted: 04-23-2015 09:44 AM           Profile Send private message  E-mail  Edit post Reply with quote


Fjoggs wrote:
Yeah those 100 extra tris sure add up huh? :p


Well, yea, in this particular case it is not very relevant but I think it's a good thing to be aware of the effect your decisions have on the polycount every time you make one. It's something I like to ignore a lot.



_________________
Portfolio
Twitter


Top
                 

Old Skool'
Old Skool'
Joined: 02 May 2002
Posts: 5230
PostPosted: 04-23-2015 01:17 PM           Profile Send private message  E-mail  Edit post Reply with quote


Shaders affect performance as well. The triscount from a broken glass like that would be as negligible on performance as the shader would be.




Top
                 

Insane Quaker
Insane Quaker
Joined: 31 Mar 2009
Posts: 494
PostPosted: 04-23-2015 08:28 PM           Profile Send private message  E-mail  Edit post Reply with quote


@sst13: okay, i just realized what the problem is. it's actually the skybox behind the glass that is causing my problem!



the broken glass shader only appears darker when viewing the skybox through it. the skybox is not visible at all and it also creates a very weird HOM effect that you can't quite see from the picture.

here is my sky shader, copied from the shader manual:
Code:
textures/kara/hip_miramar
{
   skyparms env/hip_miramar/miramar - -   
      q3map_sunExt 1 1 .93 450 323 70.5 3 32
   q3map_lightmapFilterRadius 0 8
   q3map_skyLight 125 6
   surfaceparm sky
   surfaceparm noimpact
   surfaceparm nolightmap
   surfaceparm nodlight
   nopicmip
   nomipmaps
   qer_editorimage env/hip_miramar/miramar_ft.tga   
}

anyone know what causes this?




Top
                 

The hell good boy
The hell good boy
Joined: 22 Jun 2011
Posts: 1922
PostPosted: 04-24-2015 06:40 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Detail the brush with glass shader? You said it's causing little HOM effect - blocking vis - repair with detail brush... I'm not sure if Radiant support also making brush nonsolid, which might make brush detail and compiler should not generate collision polygons for it... This could also help. If you use caulk for invisible faces, don't, use nodraw instead...

Also nopicmip and nomipmaps should not be in one shader... And I never seen sky shader with these options...



_________________
[ Websites | Facebook | Twitter | YouTube | Instagram ]
When you feel the worst, turn to the sun and all the shadows will fall behind you.” - John Lennon


Top
                 

Insane Quaker
Insane Quaker
Joined: 31 Mar 2009
Posts: 494
PostPosted: 04-24-2015 09:53 AM           Profile Send private message  E-mail  Edit post Reply with quote


@czghost: i appreciate your desire to help on the forum, but none of the stuff you just said is true. it's no good to have that kind of false information floating around here. in the future, could you do me a favor and please only comment on technical topics when you have a strong knowledge of the subject?

@sst13: would you mind just trying the shader in front of a skybox? i'm getting this problem with any kind of skybox shader i try, but not with stock q3 skies.




Top
                 

The Afflicted
The Afflicted
Joined: 11 Mar 2015
Posts: 848
PostPosted: 04-24-2015 11:18 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hmm.. Hard Words! So i wont post any Ideas too cause im a Noob... :(
I hope you will figure it out!



_________________
Die Vitamine sind in der Dose gefangen!!!


Top
                 

Insane Quaker
Insane Quaker
Joined: 15 Feb 2010
Posts: 298
PostPosted: 04-24-2015 02:34 PM           Profile Send private message  E-mail  Edit post Reply with quote


Adding a higher sort value solves the problem with the skybox:
Code:
textures/phdm5/glass_break1
{
   qer_editorimage textures/phdm5/glass_break1.tga
   qer_trans 0.9
   surfaceparm nolightmap
   surfaceparm nodlight
   surfaceparm trans
   sort additivie
   {
      map textures/phdm5/glass_break1.tga
      blendfunc filter
      rgbGen identity
      depthWrite
      alphaFunc GE128
   }
   {
      map textures/phdm5/glass_env.tga
      blendfunc add
      rgbGen identity
      tcGen environment
      depthFunc equal
   }
}


The sort value must be 7 or more to work well with a skybox.
For viewing health bubbles or torch fire through the broken glass shader at least 9 (additive).

PS: Add "r_clear 1" to your config. This helps a lot spotting this kind of errors including missing/untextured faces...



_________________
Q3A Maps - by sst13
Quake Live Workshop


Top
                 

Insane Quaker
Insane Quaker
Joined: 31 Mar 2009
Posts: 494
PostPosted: 04-24-2015 05:43 PM           Profile Send private message  E-mail  Edit post Reply with quote


@sst13: it works! thanks so much.

@andyw/czghost: no harshness intended, sorry if i was too blunt. guessing i'm feeling better now that i've got this bug out of my map :)




Top
                 
Quake3World.com | Forum Index | Level Editing & Modeling


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.