Page 1 of 1

Transparent texture?

Posted: Sat Apr 02, 2011 2:06 pm
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.

Posted: Sat Apr 02, 2011 4:43 pm
by ceriux
check out external tga support and how to use alpha channels

Posted: Sun Apr 03, 2011 2:14 pm
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.

Posted: Sun Apr 03, 2011 4:18 pm
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).

Posted: Mon Apr 04, 2011 1:23 am
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.

Posted: Mon Apr 04, 2011 1:34 am
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)

Posted: Tue Apr 12, 2011 9:00 pm
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

Posted: Wed Apr 13, 2011 12:20 am
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.

Posted: Wed Apr 13, 2011 12:23 am
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?)

Posted: Wed Apr 13, 2011 12:47 am
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!

Posted: Wed Apr 13, 2011 8:24 am
by goldenboy
You're giving me ideas.

Posted: Wed Apr 13, 2011 12:42 pm
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.

Posted: Thu Apr 14, 2011 12:52 am
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. ;)