Jump to content

Transparency other than alpha test


DaveLee
 Share

Recommended Posts

I'm looking to create some softer decals, but the _alphatest shader seems to only read pixels as 100% opaque or 100% transparent. Ideally I would like to be able to paint gray areas in my alphas for softer edges. After digging through the shaders I haven't found anything that works. Does anyone else have an idea?

Link to comment
Share on other sites

  • 2 weeks later...

I knew there was a way to do an alpha blend, hah! That's exactly what I needed, thank you good sir. :)

 

decalworking.jpg

 

Could you paste your alpha blend .mat file, please?

Core i5-750 - GTX 460 1GB - 12GB DDR3 - Win 7 x64

Link to comment
Share on other sites

Sure thing:

 

texture0="abstract::whitebrickdecal01.dds"
texture1="abstract::oldpaintedbrick01_dot3.dds"
overlay=1
blend=alpha
shader="abstract::mesh_diffuse_bumpmap.vert","abstract::mesh_diffuse_bumpmap_specular.frag"
shadowshader="abstract::mesh_shadow.vert"

Link to comment
Share on other sites

Thanks. This is a lot better looking alpha for my purposes, but the problem now is that I can't seem to do two sided alpha for e.g. fence by cullface=0. Any workaround, or do I simply make two planes facing opposite sides?

 

Edit: played around with it and got it working for my scene.

Core i5-750 - GTX 460 1GB - 12GB DDR3 - Win 7 x64

Link to comment
Share on other sites

  • 2 weeks later...

you will always get strange results when using alpha blend, if not using in its own world, thats because of the deferred shading.

if your render in the normal world without skipping the invisible pixels the depth buffer will also be written at "invisible" pixels, so the whole plane gets rendered. when lighting the plane gets lightened even if its not visible there --> you see the plane again.

 

what i was thinkin about is: rendering all visible pixel (alpha=1) in the normal color buffer and rendering all pixels with alpha<1 in another color buffer at the same rendering call.

then compute the lighting for both buffers and blend the transparency buffer on the first color buffer.

i know thats pretty much like the transparency world, just that the shadows(exept the pixels with alpha<1) get drawn and that the collisions will also work as it's all in the same world

 

problems: 1 more computeLighting call

-when there is a object with alpha<1 behind an object with alpha<1 (but thats also in the transparency world)

-the shadows dont get calculated for pixels with alpha<1

 

€: sry.. forgot that i'd also need my own depth buffer then..

Link to comment
Share on other sites

  • 1 month later...

I have no problems with transparent, a bit bluish tinted, windows in my game. I just move all windows to the transparency (foreground) world, and windows show all shadows and lights behind them, and also cumulate (you can still see through multiple stacked windows and the color adds correctly too)! Cumulative transparency is no problem in deferred rendering engines, you just need to do it right.

 

In the mat file for windows I use blend=alpha, color=1,1,1,1, and the window texture has an alpha channel and is colored light blue. Framework must be used for rendering, because without it, you would have to rewrite it 1:1 with all the buffer and rendering logic, resulting in the same situation as using it.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

I have in the model's Lua script the LoadModel call which loads all transparent submodels to the main model. So it works transparently in Editor and in the game.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

I'm doing some models in 3dmax. Afghans rural buildings. Base texture is mud with some vertex painting for variation.

 

But I need some decals for stains and additional dirt on the walls too. They are simple planes which I detached from the model and they get exported with the building.

 

So no extra mesh just for decals. All in one building. It should look like the one Dave made on his screenshot.

 

At the moment I see the bricks at the spots where I have the white alpha but at the spots where the decal should be transparent its just black. :D

I used the same material file like Dave posted aboove. Alpha is located in diffusemap. Normalmap has specularity.

Pure3d Visualizations Germany - digital essences

AAA 3D Model Shop specialized on nature and environments

Link to comment
Share on other sites

There is a way to do this with lighting intact. The roads are one example. Will look at it when I get out of bed. i'm typing on my phone right now . actually i m just speaking into it

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Wow with just entering by voice? What phone do you use?

 

I found a solution with intesive searching the forums:

My material file is just:

 

 
texture0="abstract::mud_clean_rocks_dcl.dds"
texture1="abstract::mud_clean_rocks_dcl-norm.dds"
blend=alpha
depthmask=0
zsort=1
overlay=1

 

No shader stuff in it. I have no idea why it works but I have the look I'm looking for. So I don't care, hehe. ;)

 

So I have the building texture based on two textures which are vertex painted. Plus the decal with smooth mudwall to brick transition.

post-6-021042300 1279814021_thumb.jpg

Pure3d Visualizations Germany - digital essences

AAA 3D Model Shop specialized on nature and environments

Link to comment
Share on other sites

Sorry for the late reply! It looks like you figured it out.

 

Alpha blend behavior seemed to change for some reason in 3.32, but I'll have to try out your material code and see if that works. I had actually gone back to a straight alpha test until I had time to look at it.

Link to comment
Share on other sites

I think alpha test evaluates the alpha map pixel by pixel as either 100% transparent or 100% opaque, with no middle ground.

 

I can confirm that removing the shader information and using the material settings that Michael posted above produces the correct decal effect. Awesome! This issue had been bothering me for a while now.

 

post-652-045250700 1279990150_thumb.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...