Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: tvminimesh alpha fading  (Read 1424 times)
Gamecode
Customers
Community Member
*****
Posts: 467


WWW
« on: February 23, 2010, 05:02:35 PM »

i think, in tvminimesh setfade is "alpha" bug ?
if i set start fading,end fading (or distance?) minimeshes simply switch between 0 and 1 (show/not show) but no continualy fading from alpha 1 to 0

its bug ?
Logged

aiR Captains - RC aircraft project TV65
Brac
Customers
Community Member
*****
Posts: 367


« Reply #1 on: March 07, 2010, 11:46:24 AM »

make sure alphablending is enabled
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4944


WWW
« Reply #2 on: March 08, 2010, 02:59:32 PM »

Make sure the alphatest is not enabled.
Else it will by default skip pixels < 0.5 alpha.
It's not really compatible with fading !
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
Hypnotron
Customers
Community Member
*****
Posts: 1043


« Reply #3 on: March 08, 2010, 05:36:25 PM »

something for the wiki...
Logged
Gamecode
Customers
Community Member
*****
Posts: 467


WWW
« Reply #4 on: March 09, 2010, 11:49:46 AM »

i try,but
blending mode = alpha
alphatest = false

on minimeshes enable fading , set start distance, set end distance and ...

objects only show/hide , no continualy fading from alpha0 to1 Sad

must set something more?
Logged

aiR Captains - RC aircraft project TV65
SylvainTV
Administrator
Community Member
*****
Posts: 4944


WWW
« Reply #5 on: March 09, 2010, 04:09:53 PM »

Please show the code, there is maybe a small detail that we can't know.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
PrinceValiant
Community Member
*
Posts: 15


« Reply #6 on: March 09, 2010, 09:01:02 PM »

Hi all.

I tested minimeshes and get some strange results. (Or may be not so strange at all Tongue)

First. Fading needs 3 things: 1)Alphablending must set to ALPHA 2)Colormode must set to false 3) Alphatest must set to False.

If one of them fails you can't get minimeshes fading.

However, this means that we must use geometry based non transparent meshes. Hmm I'm confused now. Can we get colored minimeshes together with fading at least? Is it possible. (Sorry if I get off topic)

Thanx.
Logged
Aki
Customers
Community Member
*****
Posts: 82


« Reply #7 on: March 12, 2010, 12:07:11 AM »

Use shaders. You might even be able to modify the default minimesh shader, though colormode/alpha should be working. It's really a best practice to use shaders for all alpha-blended objects using pre-multiplied alpha instead of DX9's default blend math.
Logged

asia
Customers
Community Member
*****
Posts: 182


« Reply #8 on: March 12, 2010, 02:55:21 AM »

Aki, why do not you post and example of a minimesh shader to assign an Alpha value to a given minimesh? It would be useful...
Ciao
Fabio
PS
I know you can...
Logged

Fabio Musmeci
ENEA
CR Casaccia
Via Anguillarese 301
00060 Rome
Italy
musmeci@enea.it
+39 3333934898
Learning to live better on a smaller footprint..
nicolas
Community Member
*
Posts: 157


« Reply #9 on: March 12, 2010, 03:07:40 AM »

Hi all.

I tested minimeshes and get some strange results. (Or may be not so strange at all Tongue)

First. Fading needs 3 things: 1)Alphablending must set to ALPHA 2)Colormode must set to false 3) Alphatest must set to False.

If one of them fails you can't get minimeshes fading.

However, this means that we must use geometry based non transparent meshes. Hmm I'm confused now. Can we get colored minimeshes together with fading at least? Is it possible. (Sorry if I get off topic)

Thanx.
Not true.

I use grass and fern minimeshes which are heavily based on transparent parts in their textures, and they alpha fade just fine. This is on an old laptop with the lowest spec graphics processor imaginable.
Logged
Aki
Customers
Community Member
*****
Posts: 82


« Reply #10 on: March 12, 2010, 11:40:05 AM »

Aki, why do not you post and example of a minimesh shader to assign an Alpha value to a given minimesh? It would be useful...
Ciao
Fabio
PS
I know you can...


Arius has a nice one (with specular highlights too!) here.
Logged

PrinceValiant
Community Member
*
Posts: 15


« Reply #11 on: March 12, 2010, 06:19:38 PM »

Quote
I use grass and fern minimeshes which are heavily based on transparent parts in their textures, and they alpha fade just fine. This is on an old laptop with the lowest spec graphics processor imaginable.

Hi Nicolas

It's very good indeed. Do you use shaders or you obtained this result just with built in SetFading function? Can you please share with us your code which works?

By the Way this is my code part which creates Minimeshes.
Thanx
Code:
Public Sub CreateFoliage()
        mObjGrass = Scene.CreateMeshBuilder("mini_" + MyBase.Name)
        mObjGrass.LoadTVM(MyBase.Model)
        mObjGrass.SetScale(MyBase.Scale.X, MyBase.Scale.Y, MyBase.Scale.Z)
        'Force BlendMode as special Case otherwise fading not can done
        If _IsFading Then
            mObjGrass.SetAlphaTest(False)
            mObjGrass.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA)
        Else
            mObjGrass.SetBlendingMode(MyBase.BlendMode)
            mObjGrass.SetAlphaTest(MyBase.AlphaTest, MyBase.AlphaReference, True)
        End If


        mObjGrass.SetLightingMode(MyBase.LightMode)

        'Use the grass mesh to create a minimesh system.
        mObjGMini = Scene.CreateMiniMesh(10000, "Minnie")
        mObjGMini.CreateFromMesh(mObjGrass, True)
        'mObjGMini.SetBlendingMode(MyBase.BlendMode)
        mObjGMini.SetCullMode(MyBase.CullMode)
        mObjGMini.SetClamping(_IsClamping)
        mObjGMini.EnableFrustumCulling(False, False, True)

        'This is For disabling 000 object - which used as base - placing
        mObjGrass.Enable(False)

       
        'We must analyze this later
        If _IsFading Then
            MsgBox("FADING disables Alphatest/AlphaSort/ColorMode and forces blending mode into Alpha" + vbCrLf + "Thus you must use basic non transparent textured geometry if u want both good looking and fading meshs.", MsgBoxStyle.Critical)
            'In case of Fading we must not use alphatesting i.e:
            'we must use physical strong geometrized models instead of basic 2 cross with alphaing
            mObjGMini.SetAlphaTest(False)
            mObjGMini.SetAlphaSort(False)
            mObjGMini.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA) 'Just for sureness
            mObjGMini.SetFadeOptions(True, _FarDistance, _StartDistance, _MaxAlphaFade)
            mObjGMini.SetColorMode(False)
        Else
            mObjGMini.SetAlphaTest(MyBase.AlphaTest, MyBase.AlphaReference, True)
            mObjGMini.SetAlphaSort(True)
            mObjGMini.SetColorMode(_IsColorModeActive)
            mObjGMini.SetColor(MyBase.ObjectColor.ToArgb)
        End If



    End Sub
Logged
PrinceValiant
Community Member
*
Posts: 15


« Reply #12 on: March 12, 2010, 06:58:56 PM »

Hi Again.

After Nicolas' mention I digged up some old code and found that he was right. My old Code also fade with transparent minimesh object.

Here it is.
Code:
        'Use the grass mesh to create a minimesh system.
        miMesh = mObjScene.CreateMiniMesh(mCount, "yuhMini" & mCount)
        miMesh.CreateFromMesh(moMesh, True)
        miMesh.SetAlphaSort(False)
        miMesh.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA)
        'Nice Farcry Effect
        miMesh.SetFadeOptions(True, 500, 150, 1)
        miMesh.SetAlphaTest(True, 128, True)

        miMesh.SetMaterial(mObjGlobals.GetMat("Flake"))

        'miMesh.SetClamping(True)
        If blnIsColorModeActive Then miMesh.SetColorMode(True)


I realized that there is Hierarchy here. IF SetFading comes before SetAlphaTest everything is okay but vice versa it fails...(Not tested because no need for now.) Maybe this is what Sylvain mentioned.  Cheesy Thanks again...
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks