LightBlow Shader (100 posts)

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    Hi guys!

    The Lightblow shader is an improved Lighting shader for JME.

    Features:
    1 Improved lighting calculations.
    2 Improved reflection calculations.
    3 Reflection map implementation with normal map alpha.
    4 Improved Minnaert calculations.
    5 Hemispherical lighting.
    6 Image Based Lighting with Albedo.
    7 Emissive map implementation with diffuse alpha.
    8 normalization of normals by default.
    9 Specular map implementation with normal map alpha.
    10 Specular intensity implementation.
    11 Switching -x/-y/-z normals for different normal maps. (3dmax, blender, xnormal have different approaches).
    12 Specular Color now works with specular maps
    13 Glowblow fragment shader is added with m_GlowIntensity? uniform. It’s possible to change glow intensity for objects. Please, use DiffuseMap? as GlowMap? instead of new additional Glow rgb texture.
    14 Lightmaps are added.

    Shader Repository:

    http://code.google.com/p/jme-glsl-shaders/



    Unlimited Free Image and File Hosting at MediaFire

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    Ok, I did patches here:

    http://code.google.com/p/jmonkeyengine/issues/detail?id=310&colspec=ID%20Type%20Status%20Component%20Priority%20Product%20Milestone%20Owner%20Summary

    http://code.google.com/p/jmonkeyengine/issues/detail?id=311&colspec=ID%20Type%20Status%20Component%20Priority%20Product%20Milestone%20Owner%20Summary

    http://code.google.com/p/jmonkeyengine/issues/detail?id=312&colspec=ID%20Type%20Status%20Component%20Priority%20Product%20Milestone%20Owner%20Summary

    Thanks to Erlend_sh for his article about javadoc patches: http://jmonkeyengine.org/2011/01/22/submit-javadoc-patches-with-the-online-code-editor/

    I hope my patches will be approved.

  • Profile picture of Momoko_Fan Momoko_Fan366p said 1 year, 1 month ago:

    I can see why in some cases this patch would be useful. Specifically, many objects in the scene might not even use specularity so this could save a few cycles on old GPUs. However doing it this way means you have much more shader switches which are considered expansive.

    @mifth, are you experiencing performance issues, which motivated you to make this change?
    About the SpecIntensity parameter, remember you can always scale up the Specular color to achieve the same effect

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    1) if you have a scene with 2 millions of polygons it will save you fps indeed. Especially, if you have other gpu effects (hdr, bloom, motion blur, blur etc.). The less shader calculation the better scene performance. I’m talking about complex scenes.
    Specular calculations are more complex even than reflection calculations. So i think if you don’t need specular, so it would be better to switch it off.

    2) About Spec SpecIntensity – if you assign a gray specular map you cannot make it more or less intensive (for instance twice or 3 times) with Specular color. SpecIntensity will be more usable as i suppose. It works like in blender, or 3d max or like in unity. I think this is a very important parameter and it presents in every pro shader.

    This picture shows on a mesh without maps the SpecIntensity power. You can easily multiply specular twice or devide on a half:
    http://img849.imageshack.us/i/speec.png/[/URL]

    Uploaded with ImageShack.us

  • Profile picture of Empire Phoenix Empire Phoenix156p said 1 year, 1 month ago:

    Shader switches are only expensive on old GPU‘s actually, all current gpus are able to to use them correctly. (The old do every branch and use ony the one wanted behaviour is kinda dead by now)

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    you mean if i don’t want to count specularity, so i should write another shader?

    Do you mean that new GPU do not understand such things?:
    #if defined(SPECULAR_LIGHTING) && !defined(VERTEX_LIGHTING)



    #endif

    well, i’m confused.

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    I can make a stress test: a scene with specular and a scene without specular.
    Nvidia gts 250.

  • Profile picture of Empire Phoenix Empire Phoenix156p said 1 year, 1 month ago:

    Old cpus in fact did not understood it, only newer (will a few years by now) gcs are able to perform branching in the program logic. ( the older ones just did everything procedually from top to bottom and then used only the wanted result.)

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    Ok, what will you suggest for lighting material improvements? My improvements are useful or useless?

    Atleast SpecularIntensity will be useful.

  • Profile picture of Empire Phoenix Empire Phoenix156p said 1 year, 1 month ago:

    Well, I think that one large material is probably simpler to use than dozens of small simple ones. So I think it might be usefull. A stress test for this would be kinda interesting however to see if the assumptions made here are correct.

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    Thanks man a lot!!! I’ll make a stress test when i’ll be at home.

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    Hi!

    Ok, my stress test! Shaders with Specular map, normal map, diffuse map.

    1)
    I did a stress test with 2 millions of triangles.
    Lighting shader: 86 fps.
    My improved shader with specular: 86 fps (The same result as Lighting but specular map increased 3 times (SpecIntensity = 3.0)).
    My improved shader without specular: 92 fps.

    So my shader wins 6 fps with 2 million of polygons scene.

    2)
    I did a stress test with 1 million of triangles.
    Lighting shader: 160 fps.
    My improved shader with specular: 160 fps (The same result as Lighting but specular map increased 3 times (SpecIntensity = 3.0)).
    My improved shader without specular: 177 fps.

    So my shader wins 17 fps with 1 million of polygons scene.

    3)

    I did a stress test with 250 thousand of triangles.
    Lighting shader: 516 fps.
    My improved shader with specular: 516 fps (The same result as Lighting but specular map increased 3 times (SpecIntensity = 3.0)).
    My improved shader without specular: 581 fps.

    So my shader wins 65 fps with 250 thousand of polygons scene.

    So you decide would you like to commit my shader improvements or no. :)

    Sceenshots of 2 million of triangles scene:
    Lighting shader with Shininess = 2.0:

    Uploaded with ImageShack.us

    My improved shader with SPECULAR_LIGHTING and SpecIntensity=3.0, Snyniness=2.0:

    Uploaded with ImageShack.us

    My improved shader without specular:

    Uploaded with ImageShack.us

  • Profile picture of Empire Phoenix Empire Phoenix156p said 1 year, 1 month ago:

    Well I think it seems quite usefull, but I’m not the one making such decisions ^^

    about same in speed but with additional functionalities or a bit faster seems not bad for me at least.

  • Profile picture of InShadow InShadow15p said 1 year, 1 month ago:

    Looks awesome! :)

  • Profile picture of mifth mifth132p said 1 year, 1 month ago:

    Thanks @EmpirePhoenix and @InShadow!
    One remark to the shader: if you want to switch reflection on, so you will need to switch SPECULAR_LIGHTING on.

    I hope the core devs will accept my changes.