Searching for the opposite of "blendfunc add" ?


(thore) #1

Hi there!

Anyone played HL2? Remember those tunnel exits that showed up in bright white?

“blendfunc add” works just fine for the brightening things up when looking towards the
cave exit from the inside… now I’m looking for the opposite blendfunc that will darken
the inside of the cave while standing outside. None of the GL_ combinations I tried so
far really worked the way I want them to… some actually set the black texture back
to 100% alpha while it’s supposed to have only 3%…

shader:


textures/box_darkbright/bright
{
	qer_editorimage textures/box_darkbright/bright.tga
	qer_trans 0.3
	cull front
	nocompress
	surfaceparm nomarks
	surfaceparm nonsolid
	surfaceparm pointlight
	surfaceparm trans
	{
		map textures/box_darkbright/alpha03.tga
		blendFunc add
	}
}

The dark texture’s shader looks exactly the same and only has “bright.tga” substituted
with “dark.tga” Both are fully opaque using “alpha03.tga” as an external alpha channel
(since I didn’t manage to save my tga with alpha channel yet.)

Here’s what the inside looks like:
(darker part of the sky is the original brightness, lower left pic shows (opaque :angry: ) view from outside)

Hints appreciated.

~Greetings


(Twisted0n3) #2

Blendfunc add can only ever brighten something. You probably want to use blendfunc filter.


(EB) #3

http://www.bpeers.com/software/q3ase/


(thore) #4

q3ase might allow click-configuring your shader rather than writing it yourself… but it doesn’t really solve the problem :wink:

thanks anyways.

I tried the dark (read black) texture with included alphachannel and “blendfunc blend” now and got it working… but
my attempt to let the bright (white) texture have an tga-internal alpha channel too failed. Well… the tga file was
successfully saved with its alpha channel… but the tex appeared ingame… guess what: fully opaque.

So for now the black tex got its alpha channel and the white tex still uses the external alpha03.tga. Kind of dirty but
it works…


(compiled bsp -meta)

The downside is a major drop of fps since there are quite a lot shaders piled up to allow for a smooth transition and
minimize the visibility of “edges” where the shaders hit the walls. We’ll see whether or not this little experiment will
ever make it into a real map :>

~Greetings


(carnage) #5

Anyone played HL2? Remember those tunnel exits that showed up in bright white?

i was told that hl2 used an engine feature to do this, also was told that the enigne has been improved a great deal in this way and steam are releasing some hl2 maps using the new features

its posible that q3 could do this if something was writen into the q3map2 compiler or something similar but ude have to ask someone who know more about that kinda stuff


(Twisted0n3) #6

It would have to be a lightmap hack of some kind.

Alpha channels are not used unless the blendfunc is “blend” or something involving GL_SRC_ALPHA, generally speaking.

If I wanted to do what you’re doing, I’d have a white.tga and a black.tga with 50% alpha channels or some such, and shaders for these with blendfunc blend and alphagen vertex, then use alphamod volume brushes to control vertex alphas, producing successively stronger blends. In fact, with that, you could accomplish the above effects with fewer overlapping fills (upshot: better FPS) and no visible edges – there’d be maybe half as many “curtains” across the passage, but each would have an outer square border and an inner center. I’d use five nodraw brushes for each, four around the outside mitred and one square one inside; the inward-facing sides would then get the white shader and the outward facing sides the black shader, and alpha volume brushes. Then I’d run eight alpha volume brushes horizontally through lined-up vertices – four on the outside at 0%, and four for the vertices of the center squares. Those would be subdivided, one brush per vertex, with the white-side brushes increasing from say 10 to 100% toward the cave entrance, and the black-side brushes decreasing from 100 to 10%, in steps of 10 – or maybe steps of 20 instead. (The pattern would be 10%, 100%, 20%, 90% etc. in the former case, so the black side furthest from the entrance is darkest and the white side furthest from the entrance is also darkest by being least whitening…the first of them half embedded in the first nodraw brush group, and half further in the cave; the next half embedded in the same brush group and half further out of the cave; and so forth.)


(thore) #7

The problem with 90107030505030701090 would be the hard cut from 90% to zero when
leaving / entering the alpha curtains. In fact I use a quite similar structure that instead
provides a smooth transition at each end of the “curtain hallway”.
That is simply a nodraw brush with a white textured face pointing towards the inner cave
and a black textured face pointing towards the cave exit. This brush with its two faces is
than stacked up 10 or 15 times to allow for the desired density of the effect since the
faces only have 3% alpha. When standing inside the cave the black faces are culled - and
the white faces are culled when standing at the cave entrance looking into the darrrrrrrk :slight_smile:

With this setup you cant really look through the whole “curtain hallway” standing at either
end of it, but you will never run against an 90% alpha wall since the 3% alpha values just
add up over distance. It feels like the “real” fog but with the benefit to enable that fog only
for a certain point ov view (while a common fog shader would be visible from inside the cave
as well as outside).


(Twisted0n3) #8

Hrm – in that case, maybe you’d just want to use eight alpha brushes, four outer ones at 0 and four inner ones at 10…


(thore) #9

That is, if I get you right, an attempt to get rid of those edges where curtains and wall meet?
If so I’d rather prefer modifying the .tga alpha channel to fade towards image borders. Less
brushwork to deal with…


(Twisted0n3) #10

Hrm, that would work I suppose, given that all these are a fixed size and shape.