Transparent texture?

Discuss the creation of various model formats for Quake engines, and related matters to modeling.
Post Reply
Karall
Posts: 128
Joined: Thu Jul 15, 2010 5:23 pm

Transparent texture?

Post by Karall »

Alright, so I want to make a plant right?
Pretty simple, just make two square planes in a cross and apply a texture. Altho for it not to look weird, were theres nothing on the texture I want it to be transparent. So for example i have some leaves on a white background. How would i make that white transparent? I use Darkplaces.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Post by ceriux »

check out external tga support and how to use alpha channels
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

In unmodified Quake/GlQuake engines, there's no support to transparent colors in .mdl. Besides the usual Darkplaces/FTE indications, the RMQ engine (developed and maintained by mh) does support transparency to .bsp models (not sure about .mdl though, better to ask mh directly), and I remember the Kurok engine having this exactly to implement vegetation (a simple engine change was required and there's a thread where mh showed how to do that - use the forum search if you want to get your hands dirty in engine coding :) ).

If you're not targeting a modified engine, it's possible to emulate what you want with 2 entities and 2 sprites (sprites do support color index 255 as transparency). Basically, spawn both entities in the same coordinates but having a 90 degrees offset in the .angles_y and here is your plant/bush.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

There hasn't been a requirement for having this on MDLs in RMQ yet so it doesn't support it. I'd personally run with the two sprites idea if only for one drawback - sprites are always drawn fullbright.

I guess you could hack it with MDLs by setting the entity alpha to something like 0.999 and using a TGA with an alpha channel as the skin. This may even work with the native 8-bit texture; Nehahra does this for fences/grills/grates on brush models and it works - kinda - fine. I haven't personally tested this for MDLs though so I don't know how robust it would be, and I wouldn't encourage hacks of this nature (they normally either come back to bite you or conflict with something else).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

hexen2 has a few extra mdl flags that enable different transparency modes. A regular Quake engine doesn't support it though. With FTE or DP you can write some q3-style shaders to do it.

getting a brush model thin enough to make a good tree may be problematic, and can't easily be animated.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Post by leileilol »

Since you use Darkplaces just use scripts/plants.shader with like um

Code: Select all

progs/plants_0
{
cull disable
       {
          map progs/plants_0
          alphaFunc GE128
          rgbGen lightDiffuse
       }
}
progs/plants_0 leading to a .tga, or .png of course (or even a jpg with a _alpha.jpg pair)
i should not be here
Madfox
Posts: 106
Joined: Sat Jan 15, 2005 3:13 pm
Location: Holland
Contact:

Post by Madfox »

I used the transparant effect by transporting the model to a sprite.
There's a good sprite-editor from FricaC that can obtain the effect by using one of Quake's colours as alpha chanel,while importing small bmp.
It's a bit in the way like the grenade explosion, which also makes use of the transparant effect.

Quake uses the Pal Colour:255 R:159 G:091 B:083 for transparant.
So when you use this as your surrounding colour it will be transparant. Don't forget to use 2bit black/white shaders for alfa.

Bad point is the plant will always turn like in doom, but when you make it round enough, like a palmtree it won't be that disturbing.

fimg_v can be found at the Quakaddicted site/tools
http://www.quaddicted.com/tools/

Here's an example of the voreball as sprite, the red surrounding won't appear in Quake.
Image
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Actually when I suggested to use sprites I was thinking about oriented sprites (the kind that doesn't always face you). :) It's just a flag you set when creating sprites with ADQuedit, I think it's possible to do the same with Fimg.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Post by leileilol »

but sprites aren't lit! :(

Well, if you're using darkplaces, stick a ! beginning in the filename then it'll be lit

Personally I don't like using oriented sprites for objects because you'd require more entities to simulate more volume, AND the sprites do not have visible backfaces

also, glquake (and everything after) broke its sprite rendering for the various different modes. mh needs to like write a tut to fix the exotic sprite modes in GL or something. VP Parallel Oriented is very cute to make sprite effects with (rotating smoke anybody?)
i should not be here
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

leileilol wrote:but sprites aren't lit! :(

Well, if you're using darkplaces, stick a ! beginning in the filename then it'll be lit
Also, if the objective is to put a few arbusts in a garden lit by the sun light this won't be an issue at all. :)

EDIT:
leileilol wrote:Personally I don't like using oriented sprites for objects because you'd require more entities to simulate more volume, AND the sprites do not have visible backfaces
makestatic() is your friend!
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
goldenboy
Posts: 924
Joined: Fri Sep 05, 2008 11:04 pm
Location: Kiel
Contact:

Post by goldenboy »

You're giving me ideas.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

makestatic is fine up to a point. Most engines still have a hard limit on the number of static entities they can have; any quick examination of the code will reveal that this limit is actually completely unnecessary. Each static entity needs one or more efrags to link it into the BSP tree, so even if you remove the limit on static entities you still need to remove the limit on efrags. Static entities live on the client only, they won't show up in clipping hulls (even if static bmodel entities) so you still need to sprinkle clip brushes around the place.

Regarding sprites, they're a solution with drawbacks. Biggest drawback is that lighting on them - even if you do enable the trick with a ! in the name - is gouraud-shaded, meaning that you don't get proper shadows that would otherwise be generated from light.exe.

For any given solution, if you find yourself having to accumulate more and more hacks, complexity and bugfixes in order to get it working, it's a pretty good sign that it might not be the correct solution, and maybe you need to backtrack and rethink your approach.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

@mh: bushes made up of sprites are hacks with several problems and limitations, no doubt about this. But, as I said, they get the job done in a easy way without wasting time and effort. Later, if the result is not good enough and there's enough motivation, other solutions like custom .mdl/.md3 props can be provided. ;)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Post Reply