Announcement

Collapse
No announcement yet.

Speckles in Bakes ("Render to Texture")

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Speckles in Bakes ("Render to Texture")

    Hi,

    yesterday I ran into the issue that Render to Texture bakes an sRGB curve into normal map bakes (high-to-low poly baking):

    http://forums.chaosgroup.com/showthread.php?89164-Why-does-Vray-bake-normal-map-in-sRGB


    Now I ran into yet another issue with the baking engine: I get serious speckling in my bakes. You can see it in some places in the normal map I linked above as well as in the baked diffuse map here:

    Click image for larger version

Name:	Baking_Speckles.jpg
Views:	1
Size:	270.4 KB
ID:	885029

    This happens no matter how high I set the samples in the Image Sampler. I'm working with 3ds Max 2016 and V-Ray 3.40.01.
    Note that I didn't bake the diffuse map from a high poly object. I just baked a "Diffuse Filter" element from a simple box that uses a purely diffuse material.

    Doesn't look right to me! Is this a bug?

  • #2
    Raising the Min samples from 1 to at least 10 got rid of the speckles at least for the diffuse texture above (Noise threshold 0,005). Values below 10 still showed some speckling. Why is raising the Min samples so high necessary for such a simple texture? I thought raising the Min Samples was only necessary in very few cases at all.

    Does the baking engine sample differently than in a normal rendering (except for the fact that the baker doesn't render a view)?

    Comment


    • #3
      If you want to get the maps plugged in your material use this Workaround:
      http://forums.chaosgroup.com/showthr...render+texture
      So, build a new material, put your map into the selfillum slot apply it to your object, disable exposure, disable GI, disable color mapping(in render dialog or render to texture element) and finally add a SelfillumElement.
      Than rise the min samples to 2 and render. It'll be very quick.

      The Problem with using those elements directly is:
      They are just like the elements in the render dialoge.
      That means they are parts of the beuty, so they'll only get as much samples as needed for the beuty to be clean. Which is way less than they would need to be clean on ther own.

      Beware of this one too :
      http://forums.chaosgroup.com/showthr...der-to-texture
      Last edited by Ihno; 27-07-2016, 06:44 AM.
      German guy, sorry for my English.

      Comment


      • #4
        Use the VrayMultiSubTex for baking more than one map to one texture.
        For instance, put the diffuse of all materials in a MultiSubObject Mtl into the corresponding input's of the VrayMultiSubTex and use it as selfillum tex.
        German guy, sorry for my English.

        Comment


        • #5
          Originally posted by Ihno View Post
          If you want to get the maps plugged in your material use this Workaround:
          http://forums.chaosgroup.com/showthr...render+texture
          So, build a new material, put your map into the selfillum slot apply it to your object, disable exposure, disable GI, disable color mapping(in render dialog or render to texture element) and finally add a SelfillumElement.
          Than rise the min samples to 2 and render. It'll be very quick.

          The Problem with using those elements directly is:
          They are just like the elements in the render dialoge.
          That means they are parts of the beauty, so they'll only get as much samples as needed for the beuty to be clean. Which is way less than they would need to be clean on ther own.

          Beware of this one too :
          http://forums.chaosgroup.com/showthr...der-to-texture
          Originally posted by Ihno View Post
          Use the VrayMultiSubTex for baking more than one map to one texture.
          For instance, put the diffuse of all materials in a MultiSubObject Mtl into the corresponding input's of the VrayMultiSubTex and use it as selfillum tex.
          I've been using that LightMtl workaround for things like AO, too. I don't think it suits my current situation very well as I am baking materials which have maps in multiple channels. Dragging these maps one by one into a LightMtl is rather cumbersome. Or did I misunderstand you?
          In principle the workflow with choosing the various filter elements in the Render To Texture dialog works as expected if it wasn't for that gamma and sampling issue. Both can be worked around for the time being though without too much hassle. Nevertheless it's annoying.

          That VrayMultiSubTex trick sounds cool. Haven't really thought about that texture too much!
          However, I thought that this texture was best suited for situations where the same material needs to be used with different textures on scene objects. In my case all my materials are very unique. No too many common denominators. Or maybe I just haven't understood your technique as applied to baking?

          Comment


          • #6
            Originally posted by JulianT_CD View Post
            I've been using that LightMtl workaround for things like AO, too. I don't think it suits my current situation very well as I am baking materials which have maps in multiple channels. Dragging these maps one by one into a LightMtl is rather cumbersome. Or did I misunderstand you?
            In principle the workflow with choosing the various filter elements in the Render To Texture dialog works as expected if it wasn't for that gamma and sampling issue. Both can be worked around for the time being though without too much hassle. Nevertheless it's annoying.
            Well it takes ages to always render GI, reflections and stuff while you only need the diffuse map... Are you talking about map channels or UV channels? Multiple UV channels are no problem. They'll all get baked down to whichever uv channel you select in the render to texture dialoge. Just use the last map node befor the VrayMtl. as SelfillumTex.
            If you mean multiple map channels use my VrayMultiSubTex trick.

            Originally posted by JulianT_CD View Post
            That VrayMultiSubTex trick sounds cool. Haven't really thought about that texture too much!
            However, I thought that this texture was best suited for situations where the same material needs to be used with different textures on scene objects. In my case all my materials are very unique. No too many common denominators. Or maybe I just haven't understood your technique as applied to baking?
            For instance, you have an house with a MultiSubObject material applied.
            It has 20 different materials on and you want to bake them all down to one map atlas for each map input of your VrayMtl's. One for diffuse, one for reflect and so on.
            You'd probably have an UV map channel 1 where the objects or parts of the house all have an individual mapping and they are overlapping each other.
            First attach them all to one or just a few object's. Add a Unwarp UVW modifier and add a new map channel. Let's say its channel 3.
            Than pack your uv's to get rid of the overlapping.
            Afterwards just follow my instructions from the previous post.
            You'll end up with something like this:
            Click image for larger version

Name:	SubObjectBake.jpg
Views:	1
Size:	511.8 KB
ID:	862827
            Than apply the self illuminating Material to the objects you want to bake and bake once for each VrayMultiSubTex. Use the settings I previously discriped for the selfillum workaround.

            If you want to export to unity, you'd have to copy the UV channel 3 to uv channel 1.
            Dont expect the unity standart shader to look like your materials in vray, out of the box.
            You'll run in a back and forth between unity and photoshop to get it right. I'll try to find a way to convert vray maps to unity pbs maps, in max as soon as I have time for that.

            Edit: You should probably create another VrayMultiSubTex with different colores for use as mask in the Photoshop part of the work.

            Edit2: If you use Triplanar mapping instead of unwarp objects individually, you'd have to Use flatten UVs before packing.

            Using Render to Texture feels like working in a minefield, bugs and things to take care of everywhere. Seems like both, ChaosGroup and AD havent really worked on it since ages.
            Last edited by Ihno; 27-07-2016, 10:52 PM.
            German guy, sorry for my English.

            Comment


            • #7
              Inho, thanks a lot for your detailed explanation! I think I now understand your workflow.

              Btw, I was talking about map channels, not UV channels.

              I think you misunderstood which kind of maps I am baking with Render to Texture. I am not baking any illumination maps (GI, reflections, shadows etc.). All I'm doing is baking the Filter Maps (DiffuseFilterMap, ReflectFilterMap etc). These bake very fast since no lighting calculations are involved! With these I can approximate the V-Ray materials in Unity although for some maps it requires, as you already said, some conversion with Photoshop to get maps out of it that make sense for Unity's PBR shader. However, that is not a big deal.

              So again, I am NOT doing any light baking in 3ds Max, primarily because I haven't found a shader in Unity that allows me to input these lightmaps the way I need it. Piping them into Emission is not an option, because that doesn't allow the shader to react to dynamic lights anymore and IIRC any reflections I put on top (reflection probes) won't be visible. Putting it into Albedo is an equally bad idea, because the diffuse part of the material obviously needs illumination to makes the light maps visible. That can only be achieved by setting the global ambient light to a flat white color which looks horrible on dynamic, non-baked objects.

              I haven't looked into shader programming yet inside of Unity, so I can't make my own custom solution. But in case you have an idea for getting light maps baked with V-Ray inside 3ds Max elegantly into Unity I am all ears

              Thanks again for all your helpful tips!

              Comment


              • #8
                Originally posted by JulianT_CD View Post
                Raising the Min samples from 1 to at least 10 got rid of the speckles at least for the diffuse texture above (Noise threshold 0,005). Values below 10 still showed some speckling. Why is raising the Min samples so high necessary for such a simple texture? I thought raising the Min Samples was only necessary in very few cases at all.

                Does the baking engine sample differently than in a normal rendering (except for the fact that the baker doesn't render a view)?
                That might be a bug, any change to send the scene for investigation?
                Svetlozar Draganov | Senior Manager 3D Support | contact us
                Chaos & Enscape & Cylindo are now one!

                Comment


                • #9
                  Originally posted by svetlozar.draganov View Post
                  That might be a bug, any change to send the scene for investigation?
                  Yes, a stripped down version. Where should I send it?

                  Comment


                  • #10
                    Originally posted by JulianT_CD View Post
                    I think you misunderstood which kind of maps I am baking with Render to Texture. I am not baking any illumination maps (GI, reflections, shadows etc.). All I'm doing is baking the Filter Maps (DiffuseFilterMap, ReflectFilterMap etc). These bake very fast since no lighting calculations are involved!
                    I think I actually didn't tryed to render the filter maps yet. But you can't get any possible map without wiring it to the diffuse slot. Or I'm getting this wrong? I see no GlossinessFilter map for example.

                    Originally posted by JulianT_CD View Post
                    With these I can approximate the V-Ray materials in Unity although for some maps it requires, as you already said, some conversion with Photoshop to get maps out of it that make sense for Unity's PBR shader. However, that is not a big deal.
                    Haha, do this for a city scene with 100+ assets. All Mtl. ID's whildly spreaten over the atlas maps and say that again


                    Originally posted by JulianT_CD View Post
                    So again, I am NOT doing any light baking in 3ds Max
                    The workflow I discribed isn't capable to bake light. Its just a way to get exactly the maps you plug in the VRay Mtl.

                    Originally posted by JulianT_CD View Post
                    But in case you have an idea for getting light maps baked with V-Ray inside 3ds Max elegantly into Unity I am all ears
                    Yes, if your target is PC and/or PC/VR I'd highly recommend to use the Valve Lab Renderer which can be found in the Asset Store for free.
                    It has a Lightmap override in it's standart material. And the performance, aa and direct shadow quality is way better compared to the the unity standart renderer.
                    But you can't use any post effects than.

                    If your target is mobile or weaker Pc and no vr. You should use the standart renderer.
                    We have a script here witch overrides the lightmap array with custom lightmaps. It also can change the lightmap ID of the objects. I found it somewhere in the unity forums and a programmer here did some changes to it. I'll post it here later, can't get my hands on it right now.
                    At the moment I'm not really shure which element to bake for lightmapping and how to edit it in PS to get a nearly identical result in Unity. I'm still testing. Its a bit tricky since unity hasn't any exposure and I'm not quite shure if I should render GI or raw GI in case of using direct light inside of Unty. And raw lighting or total lighting when I want to use just Vray Lighting for Static Scenes.
                    Also I'm not shure if I should turn the exposure on or off. I think it will depent on which renderer you use and which the target device is.
                    Last edited by Ihno; 28-07-2016, 09:25 AM.
                    German guy, sorry for my English.

                    Comment


                    • #11
                      Originally posted by Ihno View Post
                      I think I actually didn't tryed to render the filter maps jet. But you can't get any possible map without wiring it to the diffuse slot. Or I'm getting this wrong? I see no GlossinessFilter map for example.
                      There is the VRayMTLReflectGlossinessBake element which bakes the Glossiness map.

                      Haha, do this for a city scene with 100+ assets. All Mtl. ID's whildly spreaten over the atlas maps and say that again
                      I hope I'll never have to do that But so far, even with scenes with 20-30 materials, it's a rather fast workflow. Not ideal, but manageable.

                      The workflow I discribed isn't capable to bake light. Its just a way to get exactly the maps you plug in the VRay Mtl.
                      I know. I just mentioned that I wasn't baking light, because you said using elements in "render To Texture" to bake Glossiness, Diffuse etc would require long lighting calculations. So I said that this wasn't needed in my case


                      Yes, if your target is PC and/or PC/VR I'd highly recommend to use the Valve Lab Renderer which can be found in the Asset Store for free.
                      It has a Lightmap override in it's standart material and the performance, aa and direct shadow quality is way better according to the the unity standart renderer.
                      But you can't use any post effects than.
                      We are doing VR mostly. I've already asked our developer to look into the Lab Renderer, but so far he hasn't found the time to do that yet. Now, after your post, I will push him a little! Good advise! I didn't know it had that lightmap override!

                      If your target is mobile or weaker Pc and no vr. You should use the standart renderer.
                      We have a script here witch overrides the lightmap array with costum lightmaps. It also can change the lightmap ID of the objects. I found it somewhere in the unity forums and a programmer here did som changes to it. I'll post it here later, can't get my hands on it right now.
                      That would be really cool! Mobile platforms and lower end PCs will surely be targets sometime in the near future. We are still in the early stages of setting up our interactive 3D department.

                      At the moment I'm not really shure which element to bake for lightmapping and how to edit it in PS to get a nearly identical result in Unity. I'm still testing.
                      Maybe a RawTotalLighting map...? That should contain the total diffuse (direct + indirect) Lighting which hasn't been multiplied by the diffuse surface color of the materials yet. That's what lightmaps should contain, right? . Not sure if the RawTotalLighting element contains shadows, though, but I think we could bake another element that contains the direct shadows (RawShadowMap?) and multiply these on top?
                      Last edited by JulianT_CD; 28-07-2016, 05:05 AM.

                      Comment


                      • #12
                        Originally posted by svetlozar.draganov View Post
                        That might be a bug, any change to send the scene for investigation?
                        I found what caused the speckles! It turned out, that the procedural "Tiles" texture that I used in the diffuse and bump slot showed these speckles, because I set the "Blur" value in the Bitmap node to the minimum of 0,01. Setting it to 1,0 got rid of the speckles. Is this a bug or do I generally have to have some blur in 3ds Max's procedural textures?

                        The speckles in the normal map might be the result of ray hit misses. The Max Scanline Renderer also had some of the speckling. XNormal baked it without any artifacts.

                        Do you still need the file for investigation?

                        Comment


                        • #13
                          Originally posted by JulianT_CD View Post
                          There is the VRayMTLReflectGlossinessBake element which bakes the Glossiness map.
                          Dosn't seem to work here:
                          Click image for larger version

Name:	RefGlossBake.jpg
Views:	1
Size:	365.9 KB
ID:	862850

                          Originally posted by JulianT_CD View Post
                          That would be really cool! Mobile platforms and lower end PCs will surely be targets sometime in the near future. We are still in the early stages of setting up our interactive 3D department.
                          Here we go:SetLightmapsManually.zip
                          Create a empty game object throw the script on it.
                          Change the array size to the count of your lightmaps and put them in. Push the "Set Lightmap Array" button and type true in the "Trigger Set Lightmap Array On Start" field.
                          Than put the script on every model in your scene and set the lightmap index to the corresponding number of the map in the previously set Array. Also type true in the "Trigger Set Lightmap Values On Start" and push the "Set Lightmap Values" button.

                          Originally posted by JulianT_CD View Post
                          Maybe a RawTotalLighting map...? That should contain the total diffuse (direct + indirect) Lighting which hasn't been multiplied by the diffuse surface color of the materials yet. That's what lightmaps should contain, right? . Not sure if the RawTotalLighting element contains shadows, though, but I think we could bake another element that contains the direct shadows (RawShadowMap?) and multiply these on top?
                          Well, it depents on what you want to do. If you want unity to manage the direct light you'll need the raw GI maps. Its hard to get those elements clean. It renders for ages since you can't turn off anything in the global swiches rollout.
                          I tested the GI (not raw) already and it dosn't work quite well. I think you are right, will test raw elements next. I think threy're even harder to get clean in time.. If you find a proper setup for this before I do, tell me!
                          German guy, sorry for my English.

                          Comment


                          • #14
                            We really hijacked that thread
                            Sorry mods!

                            Originally posted by Ihno View Post
                            Dosn't seem to work here:
                            [ATTACH=CONFIG]31669[/ATTACH]
                            Hard to tell based on the screenshot. What's on the left side of the screenshot? The node that's cropped.
                            If you like you can upload a stripped down version here and I will take a look at it. It should work.
                            Have you maybe dialed down the multiplier value next to the map slot of the material's "Maps" rollout? The one that goes from 0-100. A very low value would make this particular map bake very bright.

                            Here we go:[ATTACH]31670[/ATTACH]
                            Create a empty game object throw the script on it.
                            Change the array size to the count of your lightmaps and put them in. Push the "Set Lightmap Array" button and type true in the "Trigger Set Lightmap Array On Start" field.
                            Than put the script on every model in your scene and set the lightmap index to the corresponding number of the map in the previously set Array. Also type true in the "Trigger Set Lightmap Values On Start" and push the "Set Lightmap Values" button.
                            Awesome, thanks a lot! Will check it out with my next lightmapping efforts!

                            Well, it depents on what you want to do. If you want unity to manage the direct light you'll need the raw GI maps. Its hard to get those elements clean. It renders for ages since you can't turn off anything in the global swiches rollout.
                            I tested the GI (not raw) already and it dosn't work quite well. I think you are right, will test raw elements next. I think threy're even harder to get clean in time.. If you find a proper setup for this before I do, tell me!
                            Sure, if you want the direct lighting to only come from dynamic Unity lights, then all you should need is the RawGI. But if you want to bake any direct lights into your lightmap, then we need a render element that includes direct shadows. Maybe the RawTotalLighting element does include them, I'm not sure from the top of my head.
                            Unfortunately, since the very first version of Unity 5 there is a bug which still doesn't allow dynamic Unity directional lights (set to "Mixed" mode) throw shadows from non-static objects onto lightmapped surfaces. Eventually this will likely be fixed with Unity 5.4. Maybe the Lab Renderer can handle that situation.

                            You're right in that raw elements are harder to sample clean. But with distributed rendering and some potent machines, it should be doable. You also don't have to render them super clean as they will eventually be multiplied by the surfaces' diffuse color which will make any remaining noise much less visible.

                            Comment


                            • #15
                              Originally posted by JulianT_CD View Post
                              Hard to tell based on the screenshot. What's on the left side of the screenshot? The node that's cropped.
                              If you like you can upload a stripped down version here and I will take a look at it. It should work.
                              Have you maybe dialed down the multiplier value next to the map slot of the material's "Maps" rollout? The one that goes from 0-100. A very low value would make this particular map bake very bright.
                              I turned off glossy effects in the global swiches rollout. Turned it back on and now it works.


                              Originally posted by JulianT_CD View Post
                              Unfortunately, since the very first version of Unity 5 there is a bug which still doesn't allow dynamic Unity directional lights (set to "Mixed" mode) throw shadows from non-static objects onto lightmapped surfaces. Eventually this will likely be fixed with Unity 5.4. Maybe the Lab Renderer can handle that situation.
                              The lighting in the lab renderer works differently. You can even have lightmaps on dynamic objects if you use the override. And yes non static objects throw shadows on static objects. But I didn't tryed realtime GI yet. It may not work with override Lightmaps...

                              Originally posted by JulianT_CD View Post
                              You're right in that raw elements are harder to sample clean. But with distributed rendering and some potent machines, it should be doable.
                              This brings my city back to my head It takes 2 days on 4 machines to bake the 55 GI elements and still it is noisy. But you are right, the noise is less visible in most cases. You can also use this workaround http://forums.chaosgroup.com/showthr...baked-textures to get them cleaner. It, of course will eat some details but also that isn't really visible if you have a crisp albedo and normal maps.
                              Last edited by Ihno; 28-07-2016, 02:48 PM.
                              German guy, sorry for my English.

                              Comment

                              Working...
                              X