Announcement

Collapse
No announcement yet.

Baking radiosity normal maps with vray (and is it possible to do with GLSL material)

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

  • Baking radiosity normal maps with vray (and is it possible to do with GLSL material)

    I want to bake some lighting for the effect described in this paper:

    http://www.valvesoftware.com/publica...e2_Shading.pdf


    The idea is to capture "directionality" in the light map, and it's achieved by sampling the light from three different normals:



    And then sample these three light maps weighting by how much the unpacked normal faces each one of these directions.


    I've tried rendering this the simple way - by creating a normal map with Vray Color to represent these directions:




    But there are some artifacts that i'm curious if could be with a vray glsl material.


    The halo around the light (black hole up on the top) and the edges of the boxes shouldn't be glowing because i should discard the samples if the come from underneath the surface.

    Any ideas on how this could be done? Is it enough to multiply the basis normal result with the ndotl from the regular normal?


    I'm also curious if this type of manipulation is even possible with the GLSL material. My understanding is that each sample going away from a point should be weighted by the dot with this normal basis, and the ndotl with the regular normal. It doesn't seem that i can do that directly though with the irradiance functions. I was thinking though if i could maybe use the reflection raytrace to shoot random hemisphere samples that would hit other points that just return regular irradiance.

    Any input on this would be appreciated.
    Last edited by pailhead; 04-04-2018, 12:38 PM.
    Dusan Bosnjak
    http://www.dusanbosnjak.com/

  • #2
    The way we did it for the VRayLightMeter object is to just render three times with three slightly different normals. Then V-Ray will automatically discard any light samples that are not relevant.

    Best regards,
    Vlado
    I only act like I know everything, Rogers.

    Comment


    • #3
      But with that i get the bleeding. I was able to get slightly better results with something like this:


      Code:
              vr_LightIterator light;
              for(int j = 0; j < vr_NumLights; ++j) {
                  vr_evalLight(j, vr_Position, normal, light);
      
                  float main_ndl = clamp(light.dot_nl, 0.0, 1.0);
      
                  vr_evalLight(j, vr_Position, bNormal, light);
      
                  float cos_nl = clamp(light.dot_nl, 0.0, 1.0);
      
                  if (cos_nl > 0.0) {
                      diffuse_contrib += vec4(cos_nl * main_ndl * light.contribution, 0.0);

      Although i wasn't able to fully test and compare yet. Not sure how incorrect it makes it, but it removed the artifact from direct lights at least (the halo around the black rectangle in the ceiling in the cornell box).
      Dusan Bosnjak
      http://www.dusanbosnjak.com/

      Comment


      • #4
        For some odd reason i can't get this to work with the second ve ctor, w hich in vray color turns out to (0.295, 0.146, 0.577), the other two work fine. I've made a test case where i've placed directional lights at these vectors. Click image for larger version

Name:	rad01.PNG
Views:	103
Size:	10.5 KB
ID:	990890


        Click image for larger version

Name:	rad02.PNG
Views:	118
Size:	39.9 KB
ID:	990891


        The red and the green channels work flawless. Directional light shining from those directions give the value 1, and it's uniform across the surface of the floor.

        Click image for larger version

Name:	rad03.jpg
Views:	115
Size:	77.9 KB
ID:	990892

        Green is the same, however, as soon as blue goes below a certain value in either red or green channels, it starts acting weird. I don't get 1 as the result, and on top of that the value is not uniform.

        Click image for larger version

Name:	rad04.jpg
Views:	109
Size:	63.3 KB
ID:	990893
        Dusan Bosnjak
        http://www.dusanbosnjak.com/

        Comment


        • #5
          I'm also under the impression that the light map is unpacked by only
          Code:
           normalMap.xy = normalMap.xy * 2. - 1.;
          the z component is not scaled?
          Dusan Bosnjak
          http://www.dusanbosnjak.com/

          Comment

          Working...
          X