Unbelievably dumb noobie question about TRANSLUCENT

Posted By: EvilSOB

Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 03:14

Cant believe Im posting this, but Im haveing a mental-blank day.

I have a model... closed single mesh, UV-skinned, single 24bit skin,
no shaders, and whatever material A7 auto-selected for a model.
The MDL7 files just have (embedded) texture enabled, no materials or effects in the file itself.
Entity is currently ent_create'd and is not running any actions.

When I load up the model without using TRANSLUCENT, it looks fine, excellent.
If I set on the TRANSLUCENT flag, is goes transparent. Cool.
If I crank alpha down to zero, it fades away. Also cool.
But when I crank alpha up to 100 or above, it gets solid ... almost ?!?

It looks like all the normals are flipped or something. It just looks inside-out.
Skin is definately 24-bit, NO alpha channel. And normals I assume are OK,
because model appears fine when there is TRANSLUCENT is off.
The warpage is also occuring while semi-transparent, but its hard to notice...

I KNOW Ive come across this before, and it isnt a model-issue Im certain.

What insanely stupid thing am I overlooking here?

Thanks guys...
Posted By: Saturnus

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 03:21

Probably this is what you're looking for:
Originally Posted By: Manual
A logical consequence of translucent or alpha channel transparent objects is that you can see other objects through them. This sounds trivial, but means that transparent or translucent entities must be rendered after all opaque entities (see rendering), and must not write into the 3D card's Z buffer. Thus their depth-sorting is not pixel-accurate, but only object-accurate. They won't hide other polygons or other parts of the same object. This can cause visible sorting errors on the screen when triangles of transparent models intersect or overlap. The errors are normally hardly noticeable, but sometimes very obvious - expecially when the alpha channel is almost opaque.

You can read the full explanation here:
http://www.conitec.net/beta/wed_entities.htm#transparency
Posted By: EvilSOB

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 04:18

Yes Saturnus, I believe so to.

Im looking for suggestions, workarounds etc.

I seem to remember there was a fairly simple 'fix' for it...
But that was two years ago....
Posted By: Superku

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 04:21

Taken from the wiki:

Code:
material mat_alphatest
{
  effect =
  "
    technique alpha_test
    {
      pass p0
      {
        zWriteEnable = true;
        alphaTestEnable = true;
        alphaBlendEnable = false;
      }
    }
  ";
}

action apply_alphatest_material
{
  my.material = mat_alphatest;
}



Convert it to lite-C, should help.
Posted By: EvilSOB

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 12:57

Hmmm.

Good looking answer, and I may use this one if it doesnt bog the system
down running on 40,000+ entities (within the camera fustrum) at once....


But I still feel there was some other way...
I think it was before I had commercial, so its unlikely it was shader-based...
Posted By: Superku

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 13:15

It's a FFP, you don't need shaders. There is no other way (?), that's how translucent entities behave. Just reset(my,TRANSLUCENT); when its alpha is 100.

Btw. you do not want to have 40,000+ Entities.
Posted By: Slin

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 13:53

Alpha testing doesn´t allow semi transparency, and that is what you want. Ao Superkus first post won´t help you. The only fix would be a model without faces on the backside facing the cam. Alternatively you could sort the faces, but that means quite a lot of work and is really slow with many polygons.

Superku,
While the code is no shader code, the graphics driver will make it a shader as otherwize modern hardware wouldn´t be able to draw it. As there is no fixed function pipeline anymore for a couple of years, only shaders laugh.
Posted By: Superku

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 14:20

Oh I did not know that, thanks.
Posted By: EvilSOB

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/19/10 16:02

Bugger, BUT...

While Superku's code wont work AS IS, is there any FF-pipe backface-culling possible?

Cause if I understand you rightly, because the graphic-driver is creating/compiling the shader,
doesnt that mean the FF-pipeline-like shader will run on lite-c free?
(avoiding shaders is pretty low-priority, but would be nice)

Cause if worst comes to worst, I can use the FFpipe backface-culling
on just one of my models, and the other (potentially) 40,000+ would survive
with the backface-ugliness left in cause it will all blur together...
(40k is an expected maximum, 10-15k is 'normal'...)


FYI: This is for a TOOL, not a game, so FPS isnt too critical...
So keeping above 15fps is probably acceptable...
Posted By: Nowherebrain

Re: Unbelievably dumb noobie question about TRANSLUCENT - 12/21/10 04:10

is there no way to do alpha blending and then alpha testing???...I'm no shader guru, but I think that would work.
© 2024 lite-C Forums