Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Inner polygons, and shaders using an alpha map.

Author
Message
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Jun 2010 20:41 Edited at: 23rd Jun 2010 20:42
I have an interesting scenario that I don't know if it's going to work or not.

My artist is using Lightwave, and has created a space station segment that has an outer tube structure, and then a sort of triangle structure inside the tube. He has texture mapped it so the outer tube areas where there is supposed to be glass will be transparent (using an alpha map) to reveal the images on the surfaces inside.

My standard shader knowledge doesn't seem to be working for this, so I thought I would pose the question, is this possible with DBPro and Shaders? Would I need to separate the two structures to make it work?

Here is a screenshot. The green circle shows where there are windwos that should be transparent.



KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Jun 2010 21:23
I think I understand what's going on. I've been using the alpha map to get transparency of other textures to reveal a base texture, but in this case I'm trying to get total transparency of the object in those areas.

I'm actually not quite sure how to do that. Any suggestions?

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Jun 2010 21:32
Make sure the two parts are different limbs, and then it will work

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Jun 2010 21:56
I went into Milkshape and removed the inner polys to see if I could separate the 2 objects and go from there, but now it's not showing any textures. Must have wiped out the UV mappings or something. (I'm a programmer, not a modeler..)

I'll ask him to do it in 2 separate objects, then I can manipulate it easier.

Should I have to use SET OBJECT TRANSPARENCY and SET ALPHA MAPPING ON for this to work, or should the shader be able to make the appropriate areas completely transparent?

Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 23rd Jun 2010 22:13
I had a similar problem, imagine a wall (essentially a box) and a window in the wall i wanted to see trough. The window is only in the texture (no CSG cutout in the wall), UV mapped so it is positioned on the same coordinates on each side (a square with 100% alpha).
What happens is that the window will not be transparent as the light gets blocked by the opposite face wall when looking trough it.

I found a way past it though, AlphaFunc & AlphaRef fixes the transparency both ways.

Hope it helps with your model.

(Code only the shader lightning pass):


Regards
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Jun 2010 23:12 Edited at: 23rd Jun 2010 23:42
I've tried a few variations, but that didn't seem to work.

[edit]

Is there a good shader command reference somewhere? Google doesn't seem to be pointing me to anything decent.

Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 24th Jun 2010 00:07 Edited at: 24th Jun 2010 00:17
Try change the AlphaRef to different values. Also Cullmode may have to be None, depends on polygon normal facing on the inner "Triangle".

Edit: Also the PS functions Out.rgba methods can be off, looking at that picture it looks like the alpha is not taken in to account at all as it reflects that much light?
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 24th Jun 2010 00:28
What the shader does for the ships in the game is blends the alpha map with a solid color texture. (that's the user's custom color) Then it applies the diffuse, specular and emissive textures over that so scratches, color blending, and specular are still shown.

Since that picture I've colored all those textures black in that area, but it's still not showing fully transparent. It's just black now, as one might expect.

Here's the shader, if that sheds any light on the subject. (pun intended..)



Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jun 2010 01:13 Edited at: 24th Jun 2010 01:18
There really shouldn't be a problem with this if you followed Diggsey's advice so there must be a problem in the code somewhere. I won't have time to look at this in detail till tomorrow evening but in the meantime my guess is the shader is wrong. I think it needs to implement alpha blending somehow in the technique section. Here's a simple example from a completely different shader:



You won't want exactly that code but something like that will probably be needed.

Edit I should add that you'll need different SRC and DEST blend modes and a different BLENDOP - but some form of alpha blending is needed, especially if you want partial transparency in places.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Jun 2010 01:51
Texture the windows with a transparent texture, like a png or a dds.

My signature is NOT a moderator plaything! Stop changing it!
Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 24th Jun 2010 01:57 Edited at: 24th Jun 2010 02:06
Plugged your shader slightly modified in on a plain box textured with a caravan texture from my game that uses the method i described.



The red circles is a targetmarker texture i used as the zero stage (your player colour) to have something that was transparent.

The "window" is the rectangle up left (and some leftover alpha space in the texture).

I had to modify the shader to only use the diffuse Alpha at the end of the PS_L1 though, and CullMode=None.




Regards
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 24th Jun 2010 22:44
@Mobiius, that's basically what I'm doing, then feeding all of it into the shader to get all the right effects. It just doesn't want to go fully transparent in the areas where the alpha mask is telling it to.

@All, after playing with some of the commands that GG and Duke E provided, I've been able to get some transparency. It's not what I expected, but it's progress. It seems to be using the colors from the diffuse. The brighter the color, the less transparent it is everywhere on the model. It seems to be ignoring the alpha mask texture.

I'm having the artist break up the inner and outer pieces into 2 separate objects to make this a little easier.

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 25th Jun 2010 19:07 Edited at: 25th Jun 2010 19:23
Ok, I have the 2 pieces of the station segment now.

I've been messing around with the suggested shader commands for a few hours now and I either get no transparency, or the transparency is based on the colors in the diffuse texture, and not the alpha map.

[edit]
Kept playing with things and figured it out.

I had this from Duke E's suggested changes.


Which I changed to this.


That, in combination with this in the technique section


Gave me the final result I was looking for.


Thanks for the help everyone.

Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 26th Jun 2010 03:00
I suspect you may have to add alpha for your other texture stages, depends on your "detail" maps

However you "code snippeted" the same codes for My and Your changes, i brace for an edit, *ducks* =)

Regards
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 26th Jun 2010 03:11



They're different.

Rawwrr. Sig Fail.
Newcastle is awesome
Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 26th Jun 2010 03:52
Doh, sorry. i see now, thanks Mad NightMare.

I am obviously unfit to post here at the moment in my sleep depraved state

Regards
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 27th Jun 2010 05:06


Then type.

Login to post a reply

Server time is: 2026-07-25 08:13:34
Your offset time is: 2026-07-25 08:13:34