Quake3World.com https://www.quake3world.com/forum/ |
|
Glass shader to tone down the skybox light? https://www.quake3world.com/forum/viewtopic.php?f=10&t=42188 |
Page 1 of 1 |
Author: | AEon [ 12-07-2009 04:41 AM ] |
Post subject: | Glass shader to tone down the skybox light? |
Alas, I just cannot figure "shader logic", on how to make a glass shader that will do the following:
Present - not working shader: Code: textures/aedm7/glass { qer_editorimage textures/aedm7/dsiglass.tga qer_trans 0.7 // Was 0.5, 0.7 is darker, less transparent. surfaceparm alphashadow // Testing ceiling glass, change skylight on floor?! surfaceparm nolightmap //surfaceparm nonsolid // Glass is solid?! surfaceparm trans // cull disable // Turn on culling for 2-sided glass! { map textures/aedm7/dsitinfx_alpha.tga blendfunc blend //rgbGen identity // tcGen environment alphagen const 0.5 // .25 Defines window transparency was .4 (.35 = more transparent) } }
Can it be that you can cast shadows via 100% transparent areas in a texture (tga), and that the shadows are either "on" or "off"? All light compiles would completely block lighting of the glass once I use surfaceparm alphashadow. (Will try using a completely different shader POM vines where alphashadows at least work). |
Author: | $NulL [ 12-07-2009 05:21 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
The texture with the alpha channel will need to be the texture referenced in qer_editorimage not the 'map' texture. You might be right about alphashadow being a binary on/off. (Its been a while since I experimented with it.) But you can definatly replace alphashadow with lightfilter on a black/white image to get the desired result. Light filter multiples the brightness of the light passing through the surface with the colour value of the texture at the point it passes through. So if light tries to pass through a black pixel the light will be stopped; but light will not be affected by a pure white pixel. All values in between give appropriate effects, you can even use colour to emulate light coming through a stain glass window. |
Author: | AEon [ 12-07-2009 05:57 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
$NulL, ... /me weeps quietly... this is the first time I have been made aware that qer_editorimage is actually used for anything other but in-editor preview. Explains why I was changing things but nothing was happening. Info that really should be mentioned in the shader manual: alphashadow, IMO. Will try your light filter idea. Update: Sorry $NulL but manipulating the qer_editorimage image instead does not not anything for me. As I had expected it would not, why should it, concerning lighting. I created a checked tga 24bit texture: black, white, gray, and black 50% transparent, and put it in this shader: Code: textures/aedm7/glass { qer_editorimage textures/aedm7/dsiglass_checker.tga qer_trans 0.7 // Was 0.5, 0.7 is darker, less transparent. surfaceparm lightfilter // Use texture's RGB and alpha channels to generate colored alpha shadows in the lightmap. surfaceparm alphashadow // Testing ceiling glass, change skylight on floor?! surfaceparm nolightmap surfaceparm trans { map textures/aedm7/dsiglass_checker.tga blendfunc blend //rgbGen identity } } And is just does not "shine" through or filter the light at all. Obviously I don't get the fundamentals of the lighting shader code required, and I don't seem to be able to find a shader that uses surfaceparm lightfilter. Trial and error is a waste of my time... giving up. It was a nice idea. |
Author: | Quack [ 12-07-2009 09:08 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
I'm not sure if there is a better (optimized) way to do this, but this code seems to work. Three stages: 1) Env map for shiny effect 2) Glass texture with alpha channel 3) depthFunc for transparency For lighting, I recommend relying on your skybox light (both skyLight & sunExt) in combination with the window's shader emitted surfacelight, similar to the one below. You can use the backSplash & lightmapFilterRadius to create a soft ambient light above the glass that will filter light through, and illuminate the area around the window. Still doing some testing, but it looks like skybox & shader surfacelight provide good results. Code: textures/name/glassStain
{ qer_editorimage textures/name/glassStain.tga surfaceparm alphashadow surfaceparm lightfilter q3map_lightmapFilterRadius 0 32 q3map_backSplash .5 -16 q3map_surfacelight 150 { map textures/effects/envmapligh.tga tcGen environment tcmod scale 2 2 rgbGen identity blendFunc GL_DST_COLOR GL_ONE } { map textures/name/glassStain.tga blendFunc GL_DST_COLOR GL_ZERO rgbGen identity } { map $lightmap rgbGen identity blendFunc GL_DST_COLOR GL_ZERO depthFunc equal } } |
Author: | obsidian [ 12-07-2009 09:25 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
It's already pretty clear in the manual that qer_ directives are editor only: Quote: Editor Specific Shader Keywords These instructions only affect the texture when it is seen in the Radiant editor. They should be grouped with the surface parameters but ahead of them in sequence. alphashadow is indeed binary, it takes the alpha channel of the texture and uses it as a mask for casting shadows. Examples are like shadows cast by tattered banners, plant leaves, window frames (but not the glass). It doesn't sound like this is what you want. It doesn't work well with fine-lined details since the lightmap resolution is usually much lower than texture resolution. lightfilter takes the colour and alpha information of the texture to produce coloured "shadows". So if you have stained glass, it will take those colours and project them as coloured shadows. Try just this: Code: textures/aedm7/glass
{ qer_editorimage textures/aedm7/dsiglass_checker.tga qer_trans 0.7 // Was 0.5, 0.7 is darker, less transparent. surfaceparm lightfilter // Use texture's RGB and alpha channels to generate colored alpha shadows in the lightmap. //COMMENTED OUT - surfaceparm alphashadow // Testing ceiling glass, change skylight on floor?! surfaceparm nolightmap surfaceparm trans { map textures/aedm7/dsiglass_checker.tga blendfunc blend //rgbGen identity } } |
Author: | rgoer [ 12-07-2009 09:52 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
lightfilter is definitely what you want |
Author: | Hipshot [ 12-07-2009 10:12 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
obsidian wrote: It's already pretty clear in the manual that qer_ directives are editor only: I've said it before, qer_editorimage, effects the bounce light. Maybe I'm doing something wrong, but I'm 100% it does. That's why if I have a editor image that looks totally different from the real texture, I always specify a lightimage. |
Author: | $NulL [ 12-07-2009 10:34 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
I could have sworn that in the absence of q3map_lightimage, q3map2 will look at the qer_editorimage. It worked correctly with this shader: Code: textures/null_urt1/glass_clear
{ qer_editorimage textures/null_urt1/glass_shadow.tga surfaceparm nolightmap surfaceparm trans surfaceparm lightfilter cull disable qer_trans 0.5 { map textures/null_urt1/chrome.tga blendfunc add tcGen environment rgbgen const ( 1 0 0 ) } } |
Author: | obsidian [ 12-07-2009 11:43 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
Hipshot wrote: obsidian wrote: It's already pretty clear in the manual that qer_ directives are editor only: I've said it before, qer_editorimage, effects the bounce light. Maybe I'm doing something wrong, but I'm 100% it does. That's why if I have a editor image that looks totally different from the real texture, I always specify a lightimage. Err... yes, except for that. It uses that as a fallback feature for radiosity if lightRGB and lightImage are absent. But as far as what it actually does and what AEon thought, qer_ directives don't actually affect the appearance of the shader itself. |
Author: | jal_ [ 12-07-2009 12:04 PM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
Another thing the qer_editorimage is used for is at exporting ASE models. It writes the qer_editorimage instead of the shader. It makes no sense to me that it does, but it does. In netradiant's q3map2 you can add -shaderasbitmap so it writes the shader names instead. |
Author: | AEon [ 12-07-2009 01:21 PM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
obsidian wrote: lightfilter takes the colour and alpha information of the texture to produce coloured "shadows". So if you have stained glass, it will take those colours and project them as coloured shadows. I don't know why I kept reading to use alphashadow and lightfilter in the same shader, but removing the former *finally* shows some results on the lightmapped floor (lightmapscale 0.125)... thanks. As was mentioned the "black" part blocks all light, but interestingly so does the black texture that was using 50% opacity (set in PS)... "white" lets all light pass and the grey looks really nice, taking off that "edge" of the very brilliant skylight. The latter is pretty much what I was looking for, though I might use the use the dsifx or the dsiglass texture to actually give the floor a slight irregularity, plus toning down the light intensity. After finalizing the glass, I'll give the decals (i.e. those Tabun created another try)... would be nifty if the color actually lit the floor. I just need to color-invert them... hopefully. Quack, will test your shader... and see if I can get the windows set up the way I want them. Though I started "miss-using" windows as a light source, in this case I'd prefer not to (maybe later, your idea of the greenish tint). Thanks everyone for not giving up on me. If I get this to work it should really look cool. Especially the contrast between toned-down glass, and broken out pieces of glass (full intensity) should really look nice. Hmm... "godrays" for the broken out areas might be nifty. Update: $NulL was right... qer_editorimage does actually define the lightfilter image - here the checked pattern - whereas the dsitinfx.tga is only seen in-game as environment mapping. Code: textures/aedm7/glass { qer_editorimage textures/aedm7/dsiglass_checker.tga qer_trans 0.7 surfaceparm lightfilter // Use texture's RGB and alpha channels to generate colored alpha shadows in the lightmap. surfaceparm nolightmap surfaceparm trans { map textures/aedm7/dsitinfx.tga blendfunc blend tcGen environment alphagen const 0.5 // .25 Defines window transparency was .4 (.35 = more transparent) } } Nice... |
Author: | rgoer [ 12-07-2009 03:55 PM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
if you set dsitinfx as your lightimage then you should be able to use dsiglass_checker as your editorimage without issue? or maybe I'm misunderstanding, it's literally been 5+ years since I wrote a Q3 shader |
Author: | AEon [ 12-08-2009 03:15 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
rgoer wrote: if you set dsitinfx as your lightimage then you should be able to use dsiglass_checker as your editorimage without issue? Don't fully understand your comment, I actually did that and it works. The present shader uses:
The problem I still see is that the glass does not actually *have* a real surface i.e. dsiglass.tga, onto which the effect dsitinfx.tga is then mapped. Presently I am changing the transparency of the glass manipulating dsitinfx.tga (via alphagen const 0.5) that tones down the effect, almost removing a glass surface. Anyway, will test Quack's shader next... |
Author: | obsidian [ 12-08-2009 09:25 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
Instead of changing the vertex alpha (alphaGen) try playing around with the texture's levels in Photoshop. You may be able to get a little more contrast between lighter and darker areas. Also, most glass shaders use an additive blend. Try experimenting with that, it may look better. |
Author: | Quack [ 12-08-2009 09:46 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
If you use lightfilter without using alphashadow, would black pixels cast shadows in the same way that alphashadow would? If the beam is a shade of light grey, it would filter that color instead of casting solid shadows like alphashadow. In the comments above I see that lightfilter uses texture's RGB and alpha channel. Would there ever be a need to use alphashadow in combination with lightfilter? I'm thinking about metal support for a window, a simple rectangle with a steel frame & square cross in the middle. Instead of making the window frame in-game with brushes, you could use an alpha channel with alphashadow, and make the metal support any color so that it would appear to be grey & shiny, but it would effectively block light out creating solid shadows on surfaces. |
Author: | AEon [ 12-09-2009 05:58 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
Taking this one step at a time. First off define how the lightfilter texture defined by qer_editorimage should look to give of some light dampening, to contrast enough compared to a broken out piece of glass:
b) dsiglass texture overlayed by a 50% opacity white layer. Too bright, does not contrast enough with the direct sunlight. c) Original dsiglass texture with +50 Contrast. Over all (even looking at the shots in 1680x) the pattern of the glass is simply to "fuzzy" to actually show significant structure on the floor. But that is OK, IMO, because I primarily want to see a darkening, for a "structure" a colored decal will be used (next set of tests). Again bit too dark like a). d) Upped the Brightness +20on c). Probably the best level of shading, though making a) a tad brighter would have done just as well, the since additional contrast does not show. e) This is how the glass on the ceiling presently looks (blend add not used yet). f) This is how the floor looks without any glass in the ceiling... as brightness comparison. The floor brushes us _lightmapscale 0.125, and even with that any detail in this type of lightfilter texture, will not really show. But as mentioned a decal will be used for details. My guess is that that (texture fit) glass texture on the ceiling is simply too far away from the floor to make it possible to project a sharper shadow? Next I'll simply use an inverted colored decal by Tabun as lightfilter "glass"... just to test how well that works. Might be funny to color the gray dsiglass, just to see how that goes. Update II: Little fun test with colored light:
b) Update: Using one of Tabun's colored decals as "glass" here. Colored shadow on the floor looks quite nice, and gives the floor an interesting structure. Strange that the _lightmapscale 0.125 cannot be improved on. I tried _lightmapscale 0.05, and the result was exactly the same. Was 0.125 the lowest possible value q3map2 works with? For completeness, the present shader version (nothing much changed so far): Code: textures/aedm7/glass
{ // Contrast +50, Brightness +20 (yellow, red, blue, green) qer_editorimage textures/aedm7/dsiglass_rygb30.tga qer_trans 0.7 surfaceparm lightfilter // Colored alpha shadows in lightmap. surfaceparm nolightmap surfaceparm trans { map textures/aedm7/dsitinfx.tga blendfunc blend tcGen environment alphagen const 0.7 } } |
Author: | obsidian [ 12-09-2009 08:27 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
No, _lightmapscale is not limited by the scale, but by other things, like the physical size of lightmap pages being stretched over large surfaces and other things. There are a few tricks involved, I'm trying to find the thread about it... Edit: Aha! viewtopic.php?t=39964 and http://sgq3-mapping.blogspot.com/2009/0 ... htmap.html |
Author: | AEon [ 12-14-2009 06:20 PM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
Posting your final shader along with the textures and map file could probably interest quite a few folks out there. Looks great... though for me this is too much... I'll be using a simple glass shaders that basically absorbs some light, plus a "godray" or beam for the places were the glass is broken... I my experiment with decals filtering light later though. |
Author: | rgoer [ 12-14-2009 06:48 PM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
does alphaGen lightingSpecular work in vq3? I thought that was something added later, like in the elite force version or something |
Author: | ^misantropia^ [ 12-15-2009 01:43 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
rgoer wrote: does alphaGen lightingSpecular work in vq3? I thought that was something added later, like in the elite force version or something It's there. Might be that it was added in a point-release but it's there now. |
Author: | obsidian [ 12-15-2009 08:11 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
alphaGen lightingSpecular is used on dynamic player and weapon models. I don't think anywhere else. |
Author: | Plan B [ 12-15-2009 08:14 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
Very interesting thread. I like how this 10 year old tech keeps getting reinvented |
Author: | Quack [ 12-15-2009 09:34 AM ] |
Post subject: | Re: Glass shader to tone down the skybox light |
Here is the glass texture used in the example posted above. I found that using tcGen environment with tcmod scale 4 4 created a really nice glossy effect. It also distorts what you are viewing through the glass. Code: textures/jungle/glassStain { qer_editorimage textures/jungle/glassStainGreen.tga surfaceparm lightfilter surfaceparm trans surfaceparm nolightmap cull disable q3map_lightmapFilterRadius 0 16 q3map_surfacelight 70 { map textures/effects/envmapligh.tga tcGen environment tcmod scale 4 4 rgbGen identity blendFunc GL_DST_COLOR GL_ONE } { map textures/jungle/glassStainGreen.tga blendFunc GL_DST_COLOR GL_ZERO rgbGen identity } } For the metalish floors/walls, I'm using a texture from q3 with custom shader. The texture contains an alpha channel which is used with the lightingSpecular. Added tcGen environment for greenish hue, this time tcmod scale .1 .1 because it should be a subtle shiny effect. I don't know a lot about alphaGen lightingSpecular and how to really control the reflections. The stock q3 shaders do use lightingSpecular, and I think it is used in a few maps also. Maybe q3dm12? Code: textures/jungle/metal { qer_editorimage textures/base_wall/train1.tga { map textures/effects/envmaprail.tga tcGen environment tcmod scale .1 .1 rgbGen identity } { map textures/base_wall/train1.tga blendFunc GL_ONE_MINUS_SRC_ALPHA GL_SRC_ALPHA alphaGen lightingSpecular rgbGen identity } { map $lightmap rgbgen identity blendFunc GL_DST_COLOR GL_ZERO } } |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |