Unity Community


View Poll Results: Will you be using this code in your project?

Voters
65. You may not vote on this poll
  • Yes

    56 86.15%
  • No

    9 13.85%
Page 1 of 3 123 LastLast
Results 1 to 20 of 49

  1. Location
    Indianapolis, Indiana
    Posts
    98

    Free RNM Shaders

    UPDATE:
    For anyone who is interested, feel free to check out my prior work with RNM in my SS Bump map article. There you get links to all the articles on RNM and SS Bump maps, tons of images breaking down how it works, and a video showing the tech running in a demo program I cooked up. Also, anyone wondering about the detail mapping technique used in my shaders can check out my article on Partial Derivative Normal maps. It may focus on an alternative encoding for normal maps, but it is also a pretty exhaustive article on detail mapping with tons of images.

    Background:

    Hello all! I've only recently joined the Unity community, but I want to start off with a big splash!

    I started using Unity 3D when my artist friend Xenius asked me to join his project as a shader programmer. Here, I was commissioned to write a series of custom shaders that employ Radiosity Normal Mapping (RNM) to handle scene lighting. Upon completing my task, I noticed the extreme lack of usable RNM shaders for Unity 3D, and decided to release our project's shaders for free.

    Comments:
    This package contains the shaders from our project, each supporting a variety of features beyond just RNMs. Among said features are cubemap specular, detail diffuse & normal maps, and alpha translucency & cutouts. The combinations are in the form of multiple shaders, rather than an ubershader.

    Please note, these shaders are completely free. I will at no point charge money for them, and simply ask to be credited appropriately. Since I am releasing them for free, I make no guarantees about their overall quality or efficiency. However, they have proven to be reasonably efficient thus far, and should be ready for production use with little to no modifications.

    Other than all that, if you use my shaders then I would like to hear about the project(s) in which you plan to use them. If you have any questions, please feel free to post here or PM me.

    Credits:
    xenius : Creating example art assets & documentation
    n00body: Implementing RNM shaders, and coding all their variants

    Screenshots:








    Files:
    Documentation
    Shaders
    Sampler Scene
    Web player for sample
    Maya 2009 project of sample scene (requires Turtle)
    Last edited by n00body; 12-22-2010 at 01:01 PM.
    [Hardware:] Windows 7, Nvidia Geforce GT 440, AMD Athlon II X4 620, 6GB RAM
    [Websites:] Development Blog | LinkedIn
    [Projects :] Alloy Physical Shader Framework | Free RNM Shaders


  2. Posts
    143

    The artist chimes in

    Hi all,
    If anyone has any questions about using these RNM Shaders in a scene, baking with turtle, workflow questions, or just general aesthetic inquiry about using RNMs feel free to post or PM me.
    -Xenius


  3. Location
    Zürich, Switzerland
    Posts
    26,572
    Very cool contribution

    While the project I'm currently part of will pretty surely not have use for something on this visual & demand level, I'm looking forward to see what others do with it.

  4. Code Maker

    Location
    Canberra
    Posts
    849
    Very cool! I was thinking about writing something like this a few months ago but when unity3 came out I found that deferred was better for the project I'm working on. I'm curious if the 2.0 ones run on iPhone and what kind of performance you are seeing.
    Have you tried the Strumpy Shader Editor?


  5. Location
    Zürich, Switzerland
    Posts
    26,572
    I doubt it would work on mobile, it uses too many texture maps for mobile due to which it would require 2+ passes (depending on the shader 2 or even 3 passes) which just isn't doable thanks to apples decision to push an underspeced gpu into 4th gen and ipad ... the 3gs potentially could afford it but doing something that runs there and not natively on the newer ones would be a suicide design plan

    Also I think there is some confusion that should cleared out, thought that already on your editor thread: OpenGL ES 2.0 is actually not SM2. Its something above it in the gpus that apple built into the current generation and DX10.1+ on any imagination tech gpu that was released after the SGX535 used by apple at the time (hard to give exact names as OpenGL ES is the streamlined optimized "super brother" of OpenGL and as such it has stuff cut. for example ES 2.0 means no FFP present at all so also none of the gl_xxx normally, unity covers this for you by feeding you with macros and perma filled registers as far as I can say)
    Last edited by Dreamora; 12-21-2010 at 08:22 PM.


  6. Location
    Indianapolis, Indiana
    Posts
    98
    @stramit:
    Funny thing is, my artist originally was using the deferred renderer so he could have up to 8 shadowed lights per scene to achieve his desired look. Naturally, this was horrible for performance, especially when most of the lights were static. So I was asked to implement RNMs so he could add far more lights, radiosity, etc and still be able to run on lower spec hardware. Now we are using the deferred renderer strictly for dynamic lights.

    Fun little side note, the bottom three shots have absolutely no dynamic lights in them. They are lit entirely by RNMs.

    @dreamora:
    Wow. I wasn't even aware of that limitation.

    Thanks for update.

    @both:
    Thus far, I haven't benchmarked the shaders, but will probably do so later in our project. Sadly, I don't have an iPhone on which to test, so I can't really comment on their performance. I will report my changes/findings here as time permits.
    [Hardware:] Windows 7, Nvidia Geforce GT 440, AMD Athlon II X4 620, 6GB RAM
    [Websites:] Development Blog | LinkedIn
    [Projects :] Alloy Physical Shader Framework | Free RNM Shaders


  7. Location
    Belarus
    Posts
    721
    What is RNM if you try to explain the feature for "dummies"?
    I feel sad, but I am not yet familiar with the technique. What it does? \ what are positive sides of using it? \ what are negative sides of using it?

    thanks,
    Slav


  8. Location
    32.71° N, 117.15° W
    Posts
    5,419
    Two questions:

    1. I'm not seeing the shader's effect on either of my machines (ATI x1600 on a Mac and GeForce GTS360M on a PC). What sort of graphics card do I need to see this?

    2. Any way to create RNM normal maps in Blender or other free / open source apps?


  9. Location
    Zürich, Switzerland
    Posts
    26,572
    Quote Originally Posted by n00body View Post
    @both:
    Thus far, I haven't benchmarked the shaders, but will probably do so later in our project. Sadly, I don't have an iPhone on which to test, so I can't really comment on their performance. I will report my changes/findings here as time permits.
    I can throw the test scene there, have iTouch 3GS, iTouch 4th gen and iPad to let it run through at native resolutions and gather you some iOS native profiler data.
    Will see if I potentially find the time today, have an important task to finish on my work before I can head to "private fun" though

    EDIT:
    Short feedback on running it at full resolution on itouch 4: it stutters serious in the sample scene already and thats lightweight.
    I've gpu avg times of up to 450ms depending on the angle

    In addition it uses to many varyings for the platform which disables fog and vertex color for example
    Last edited by Dreamora; 12-22-2010 at 05:11 AM.


  10. Location
    Indianapolis, Indiana
    Posts
    98
    @gnoblin:
    "Radiosity Normal Mapping" is less commonly, but more appropriately referred to as "Directional Lightmapping". Essentially, it is a form of lightmapping that allows you to store lighting information from three directions, then combine them using a standard normal map. This differs from traditional lightmaps which would have to be aware of surface normal maps when baking the lightmaps.

    Positives:

    • Can bake in tons of lights, and lighting effects (Soft Shadows, Translucent Shadows, Radiosity, Ambient Occlusion, etc) and have them apply to any surface normal map
    • Versus traditional lightmaps, they can have high-resolution surface details without having to increase the lightmap resolution
    • Responds to dynamically changing normal map (ex. water/lava flow, ripples in water, etc)
    • Supports detail normal mapping

    Negatives:

    • Three lightmaps per surface requires more storage space. As such, their resolution needs to be lowered, potentially sacrificing some quality. However, the nature of these maps makes it so that the surface's normal map will likely hide this drop in resolution. Also, it tends to be significantly less than traditional lightmaps that try to have normal map detail.
    • Longer bake times, since the baking app needs to cover three lightmaps versus one
    • More shader calculations, since it needs to sample the extra lightmaps, convert the normal map to the new basis, and then combine the contributions of the lightmaps. Standard lightmaps would just be a texture sample and a multiply.

    Does that explain it well enough?

    @bigkahuna:


    1. What do you mean by "not seeing the effect? Can you take a screenshot, and explain what you mean? If there is a problem, I definitely want to fix it.
    2. Last I'd checked, Blender doesn't support them. However, I haven't really been looking.


    @dreamora:
    That doesn't surprise me since this particular batch of shaders were customized to accommodate my artist's feature requests for the PC. During their development, detail maps added the most extra instructions, with cubemaps being a close second. These were further exacerbated by having lots of tweakable variables for all of them.

    Chances are good that I could trim down the most basic RNM shader to make it run efficiently. However, to have the best chance of making it run efficiently, I would have to take a look at UDKs approach to simplifying/compressing RNMs down to two maps as opposed to the current three maps. Sadly, that introduces another processing step to convert the output of a typical baking tool and converting it to the UDK-style RNMs.

    Thanks for testing it out, by the way. Your assistance is much appreciated.

    @all:
    Is there anyone here who would be interested in helping me build a simple UI/tool for converting these maps from their standard form to UDK's style? I can easily write the conversion code myself, but I don't have much experience making artist-friendly UIs.
    Last edited by n00body; 12-22-2010 at 09:06 AM.
    [Hardware:] Windows 7, Nvidia Geforce GT 440, AMD Athlon II X4 620, 6GB RAM
    [Websites:] Development Blog | LinkedIn
    [Projects :] Alloy Physical Shader Framework | Free RNM Shaders


  11. Location
    32.71° N, 117.15° W
    Posts
    5,419
    I'm not at my dev machine at the moment, but all that I'm seeing is a flat texture, no relief at all. I'll give it another try when I get back later.

    I did a search for tools that support RNM and apparently xNormal does, so I've downloaded the latest version of it (it's free).


  12. Posts
    96
    Quote Originally Posted by n00body View Post

    @dreamora:
    That doesn't surprise me since this particular batch of shaders were customized to accommodate my artist's feature requests for the PC. During their development, detail maps added the most extra instructions, with cubemaps being a close second. These were further exacerbated by having lots of tweakable variables for all of them.

    Chances are good that I could trim down the most basic RNM shader to make it run efficiently. However, to have the best chance of making it run efficiently, I would have to take a look at UDKs approach to simplifying/compressing RNMs down to two maps as opposed to the current three maps. Sadly, that introduces another processing step to convert the output of a typical baking tool and converting it to the UDK-style RNMs.
    I came up with my own CRNM technique that only stores directional intensity instead of color for this reason.


  13. Location
    Indianapolis, Indiana
    Posts
    98
    Cool cool. I take it yours are more optimized and would be better suited to iPhone games?
    [Hardware:] Windows 7, Nvidia Geforce GT 440, AMD Athlon II X4 620, 6GB RAM
    [Websites:] Development Blog | LinkedIn
    [Projects :] Alloy Physical Shader Framework | Free RNM Shaders


  14. Location
    32.71° N, 117.15° W
    Posts
    5,419
    @n00body - Ignore my earlier post. Everything seems to work fine, just typical "operator error". :P


  15. Posts
    143
    @dreamora: If you'd like, I can whip of a up a sample scene for you to test the basic RNM shader on the iphone. The sample scene probably chugged due to the cube-detail shader being used, which is crazy complex by comparison.

    If you downloaded the sample scene package, try changing all the currently applied shaders to RNM and RNM-cutout respectively. It should give you a more realistic representation of possibly performance.

    @gnoblin: Speaking as an artist using RNMs, i'd say one of the not-yet-mentioned benefits is being able to have the normal map and specular characteristics reeeeeally convey a material, instead of painted detail that fakes a lot of this in the diffuse channel. Look at Mirror's Edge as an example; the game is filled with tons of minimalist, largely flat-tone materials. Its the RNM, env map spec, and normal map that really make everything 'pop' hence why the technique is so useful.

    Example from Mirror's Edge:
    Name:  MirrorsEdge-2010-12-06-20-34-06-79.jpg
Views: 6605
Size:  304.9 KB


  16. Posts
    96
    My shaders are optimized as best as they can be for use on just about anything. Mind you, that isn't to say all of my RNM shaders will run on on iOS. Though my CRNM + SSBump shaders should run quite well.
    Last edited by Geenz; 12-22-2010 at 11:29 AM.


  17. Location
    Indianapolis, Indiana
    Posts
    98
    @Geenz:
    Well yes, that is the ideal combination in terms of cutting down instructions. However, I feel like SS Bump maps would be bad for iPhone development since they don't compress well. So you are left with maps that need to be raw RGBA8, and will eat up memory in a hurry.

    I'm curious, have you found a solution to this problem?
    [Hardware:] Windows 7, Nvidia Geforce GT 440, AMD Athlon II X4 620, 6GB RAM
    [Websites:] Development Blog | LinkedIn
    [Projects :] Alloy Physical Shader Framework | Free RNM Shaders


  18. Posts
    96
    In terms of compression, you only really notice compression artifacts when the surface uses very low texture repeats and the surface is _right_ in front of the camera. There's no real way around it unless you use something like virtual texturing to stream full resolution uncompressed textures, and if you have the technology to use virtual texturing, then I'd question why you'd use RNMs :P
    Last edited by Geenz; 12-22-2010 at 12:00 PM.


  19. Location
    Indianapolis, Indiana
    Posts
    98
    @Geenz:
    Well yes, looking back at my own experiments with the tech, it looks passable if you use RGB565 as the format. Especially since the specular is likely to be subtle, so you will be less likely to see the banding. Also, since it is intended for a small screen, it really would be hard to see it except in contrived scenarios where you are looking straight at the wall.

    It looked bad for cases where I was using straight up environment map reflections with no diffuse. In that case, I should instead be using standard normal maps for the bumped reflection.

    @all:
    For anyone who is interested, feel free to check out my prior work with RNM in my SS Bump map article. There you get links to all the articles on RNM and SS Bump maps, tons of images breaking down how it works, and a video showing the tech running in a demo program I cooked up. Also, anyone wondering about the detail mapping technique used in my shaders can check out my article on Partial Derivative Normal maps. It may focus on an alternative encoding for normal maps, but it is also a pretty exhaustive article on detail mapping with tons of images.

    Cheers!
    [Hardware:] Windows 7, Nvidia Geforce GT 440, AMD Athlon II X4 620, 6GB RAM
    [Websites:] Development Blog | LinkedIn
    [Projects :] Alloy Physical Shader Framework | Free RNM Shaders


  20. Posts
    96
    Quote Originally Posted by n00body View Post
    @Geenz:
    Especially since the specular is likely to be subtle
    If you even intend to have "real" specular. On iOS, you pretty much have to fake specular if you want to use lightmaps with it.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •