Home Technical Talk

CGFX alpha masked LitSphere shader

polycounter lvl 10
Offline / Send Message
choco polycounter lvl 10
Hey there,
I'm currently looking into using litsphere shading as a method for texturing.
The goal here is to use "decals" which has a normal map applied to it with an opacity mask.
Using lit spheres would allow me to reproject the normal map and create unique textures by putting together a bunch of decals in maya.
The output texture would be then extracted through a hardware render from an orthographic camera.

The hardware 2.0 engine in maya allows me to also extra an ambient occlusion map (SSAO technique) in realtime and also transparency with multi-sampling.

I'm currently looking into modifying the shader to add support for alpha based transparency stored either in the color texture or in the normal map (alpha channel).
I would greatly appreciate any pointers regarding the direction I should be taking.

As of now, I'm no tech artist but I'm looking it learning how to author my own cgfx/hlsl shaders which I would gladly share with the community.

The shader I'm currently using is made by Leonardo Covarrubias (blog.leocov.com)

Links to download the shader :
Icreproject (advanced litsphere/reprojection shader) : https://dl.dropbox.com/u/53969153/litsphere/lcReproject.zip

Simple litsphere shader : https://dl.dropbox.com/u/53969153/litsphere/lcLitSphere_1.1.cgfx

Here is an example of usage with a normal map litsphere :

Litsphere used : swizzle +X, +Y, +Z
normal_map_litsphere.png



A few test with some low poly brick stones which has a normal map baked into it :

maya_object_litsphere_nrm.jpg


Shade map (SSAO + simple litsphere) :

maya_object_litsphere_AO.jpg


Failed attempt to use with objects which has transparency (decals method) : AO was turned on to see two planes.

maya_decal_litsphere.jpg

Replies

  • Drew++
    Options
    Offline / Send Message
    Drew++ polycounter lvl 14
    I would test out a shader I just re-wrote, but I don't have Maya... but it needs just an alpha map(mask) somewhere, then you set the alpha in your main pixel shader function to use that map. Then in the shader 'pass' you would enable alpha test or alpha blend. I'll message you and maybe we could get this working :P
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Hey Choco

    I just changed
    float  Oi = 1;
    

    to
    float  Oi = ungamma22(tex2D(litSphereMapSampler, UV).a);
    

    Basically stripping and using the alpha of the color texture (since this is a lit sphere, maybe using the alpha of the normal might be better and more convenient (?)) and changed the technique to alpha test.

    Here's the modified shader. Its pretty simple and basically what Drew mentioned. If you want to learn more about shaders, HLSL, CGFX etc check out Ben Clowards DVD's on CGAcademy. They're written with HLSL and if you want CGFX check out Luiz's DVDs on Eat3d. Let me know if you wanted more info etc. Also definitely a useful thing to do!
  • Drew++
    Options
    Offline / Send Message
    Drew++ polycounter lvl 14
    Yeah, I went ahead and re-wrote the shader, we're working on adding some cool stuff now on Skype ^_^
  • choco
    Options
    Offline / Send Message
    choco polycounter lvl 10
    Thanks for the help guys, drew got it working like a charm, he rewrote the whole shader.
    Only thing left is to get alphablend technique to work with the hardware engine of maya.
    Currently it only works with the default rendering engine which doesn't render in software mode.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Yeah thats gonna be hard as to my knowledge the hardware renderer isn't exposed to the cgfx shader/plugin (Other materials have a Hardware Texturing where you can change to combined to see the whole thing, alpha and all that jazz)
  • choco
    Options
    Offline / Send Message
    choco polycounter lvl 10
    Maybe using a secondary pass to render transparency could be the solution, I'm not sure tho.
  • CheeseOnToast
    Options
    Offline / Send Message
    CheeseOnToast greentooth
    Hey guys, I'm looking for the updated shader that Drew made. Basically, I'm looking for an easy way to create foliage planes using alpha-mapped leaves as my highpoly source for normals and transparency. Litspheres are great for rendering to a plane, but I can't get the alpha working.

    Any help would be appreciated.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Hey Cheese

    Are you just using the hardware render like Choco for the alpha? AFAIK Drew and Choco made this shader One option you can do is using Maya API to render the scene.
  • CheeseOnToast
    Options
    Offline / Send Message
    CheeseOnToast greentooth
    Thanks man, but AFAIK that shader doesn't support litspheres. I'd like to be able to apply a normal map litsphere like the one choco posted above and also an opacity map. I could then render my highpoly branch + leaves from an orthographic camera to get a really quick and easy normal map out.
Sign In or Register to comment.