3D tree (plant) working with `leaf cards´ but alpha against the sky does not.

Discussion in 'Track Modding' started by RafBR, Jan 21, 2012.

  1. RafBR

    RafBR Registered

    Joined:
    Jan 6, 2012
    Messages:
    155
    Likes Received:
    5
    This image shows what is happening in here, the alpha works well against other objects but not against the sky.
    I am wondering if the leafs can project alpha mapped shadows...of course yes but how?

    View attachment 779
    View attachment 780
     
  2. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    30
    Try setting Source/Destination Blending to Src Alpha/Inv Src Alpha and then check 'Sorted' (and you 'may' need to uncheck Chroma transparency in the gTex).

    As far as the shadows go: in the Instance rollout in the GMT Exporter plugin, select 'Texture' When you make your object a shadow caster. Of course, the problem you'll have is that the normals will be moving to face the 'camera' and the sun needs to be able to 'see' the face of the polygons in order to cast the shadows. So, when the camera is between the sun and the leaves, you will see shadows cast on the ground. But when the leaves are between the camera and the sun, I don't think it will cast shadows.
     
    1 person likes this.
  3. mianiak

    mianiak Registered

    Joined:
    Oct 5, 2010
    Messages:
    691
    Likes Received:
    46
    Use chroma.
     
  4. Alex Sawczuk

    Alex Sawczuk Administrator Staff Member

    Joined:
    Oct 4, 2010
    Messages:
    851
    Likes Received:
    971
    you want to use the non alpha test version of that shader and chroma transparency, i think.
     
  5. RafBR

    RafBR Registered

    Joined:
    Jan 6, 2012
    Messages:
    155
    Likes Received:
    5
    Done and works (I used the Src Alpha/Inv Src Alpha method) Thanks a lot!

    The shadow on the ground does not have the alpha working yet. I selected the "texture" in shadow caster (now I remember it is in the new `rF2_Track_Technology_v2` pdf) but nothing.
    View attachment 782

    I think I got your point and I agree ... If I could make another object for the leaves to cast shadows, that is invisible for the camera but facing the sun or static... Now I am lost...
     
  6. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    I haven't checked it yet, but as maniak and Alex pointed out - you will most likely need chroma instead of blending, for them to work correctly.
    The difference between alpha blending and alpha test (a.k.a. chroma) is that blending always draws full polygon, but blends it with background, while alpha test literally renders the given shape, by skipping pixels.
    Chroma transparency doesn't require sorting because it works perfectly well with Z buffer while blending doesn't.

    Billboards always rotate towards eye, and when rendering to shadowmap, the sun is the eye. So billboards used to cast shadows will be rotated towards sun and will cast shadows.

    Take a closer look at people standing near track in Monaco - no matter where are you looking from - they will always cast the same shadow, as if they were facing the sun.
    This produces a nasty self-shadow bug on people, because half of the billboard will always be in it's own shadow.


    This is only one of many issues I've found with billboards. Current ISI implementation suffers with both shadows and lighting.

    As soon as unlocked CoreShaders.mas is available, I'll fix those things :) If not, I'll send my feedback to ISI, so they can fix it themselves (although these problems with bllboards would take a lot of explaining but very little programming to fix, so I would prefer just to get my hands on shaders).
     
    Last edited by a moderator: Jan 22, 2012
  7. RafBR

    RafBR Registered

    Joined:
    Jan 6, 2012
    Messages:
    155
    Likes Received:
    5
    @K Szczech You are right, the shadows faces the sun :D and yes now I used what maniac and alex sugested (chroma) and worked fine too
    I only still have squares in the ground shadows...
    View attachment 796
     
  8. RafBR

    RafBR Registered

    Joined:
    Jan 6, 2012
    Messages:
    155
    Likes Received:
    5
    Ok, the texture shadows works now. My bad :eek:
    I am exporting the scn file to an exterior scn file for it not to mess with the original one, so I had forgotten to set the shadows to "textured" instead of "solid" in the scn
    Thanks to all of you!
     
  9. Michael Juliano

    Michael Juliano Track Team

    Joined:
    Oct 4, 2010
    Messages:
    371
    Likes Received:
    5
    Glad you got it working--thanks for helping him out, gents :)
     
  10. SmokinJo65

    SmokinJo65 Registered

    Joined:
    Jan 15, 2012
    Messages:
    87
    Likes Received:
    1
    View attachment 927

    Ok can someone answer my question please. I am fixing my trees as well and I might replace some but why do these trees look like ass only 100 yards away? I thought I had things check right in the export part. I am selecting multiple trees as well when exporting so I cannot mess with the LOD area. Or can I? If I have to export 150 instances for trees well that's plain dumb..
     
    Last edited by a moderator: Jan 29, 2012
  11. SmokinJo65

    SmokinJo65 Registered

    Joined:
    Jan 15, 2012
    Messages:
    87
    Likes Received:
    1
    Forget it, I figured it out...
     
  12. Jka

    Jka Member Staff Member

    Joined:
    Jan 31, 2011
    Messages:
    954
    Likes Received:
    213
    Just a wild guess, but have you created mipmaps for your textures? You can also play around with each (tree) material texture stage mipmap bias. Try some negative values up to -2.
     
  13. SmokinJo65

    SmokinJo65 Registered

    Joined:
    Jan 15, 2012
    Messages:
    87
    Likes Received:
    1
    This is a convert from RF1 so I believe they have mipmaps but I am not seeing anything when I open it in photoshop, doesn't give me an option to view mipmaps.

    If I uncheck chroma crap the trees are beutiful and full again but if I leave them at scn alpha/inv scn alpha I get some wierd clippings in the trees themselves and I think that was talked about above because of a bad shader for rf2 or something or shaders that needed to be fixed. As of now I think chroma looks like crap on trees because they seem so hardly even there (way to many pixals invisible).
     
  14. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    There are two ways to make objects transparent in games:
    - alpha blending
    - alpha test

    [​IMG]

    On the left you see alpha blending, on the right you see alpha test.

    Now the differences:

    Alpha Blending:
    - smoothly blends proportionally to alpha channel of texture
    - not z-buffer friendly (you need to enable sorting, or you may see further objects rendered on top of nearby objects)
    - not shdowmap friendly (it cannot cast proper shadows)
    - FSAA friendly
    - slightly worse performance (need to perform blending)
    - mipmap friendly

    Alpha Test:
    - either render pixels or not, providing sharply cut edges
    - z-buffer friendly - no problems at all, no sorting needed
    - shadowmap friendly - no problems at all
    - not FSAA friendly
    - slightly better performance (either drawing pixel or not - no blending performed)
    - not mimpap friendly (needs good mipmaps)

    To use blending, you just need to set Source and Dest Blend to something else than One / Zero. In most cases you will want Src Alpha / Inv Src Alpha.

    To use alpha test... well, that one is a bit weird actually :) I believe alpha test enables itself when you use chroma color on the primary texture (any texture?).


    You should always choose carefully. For glass it's obvious you need blending and not alpha test, but for vegetation and fences it may be much less troublesome to use alpha test instead.

    As for which one looks better on trees - personally, I haven't seen a single tree in my life that would have blurry leafs ;) On the other hand - as you move away, leafs and gaps all mix up due to limited screen resolution. In this case blending combined with mipmapping may work like antialiasing.
     
  15. RafBR

    RafBR Registered

    Joined:
    Jan 6, 2012
    Messages:
    155
    Likes Received:
    5
    Here when you say glass you mean grass, glass? Well I assume you mean it right and it is glass, so when doing 3d grass should we use alpha test, right? :D
     
  16. ethone

    ethone Registered

    Joined:
    Nov 30, 2011
    Messages:
    1,153
    Likes Received:
    37
    No, he meant glass alright. A material that is neither completely opaque nor completely transparent (even if just in certain places). You need blending to get that 50% transparency going.
     
  17. Luc Van Camp

    Luc Van Camp Track Team Staff Member

    Joined:
    Oct 4, 2010
    Messages:
    1,030
    Likes Received:
    15
    Indeed. With glass being semi-transparent there is no other option but to use alpha blending.

    EDIT: I'm slow :) ...
     
  18. RafBR

    RafBR Registered

    Joined:
    Jan 6, 2012
    Messages:
    155
    Likes Received:
    5

Share This Page