Announcement

Collapse
No announcement yet.

Rectangle/disc light preview texmap

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

  • Rectangle/disc light preview texmap

    In the "Vraylight-Rectangle/Disc light" rollout there is a little checkbox called:
    Preview texmap

    it is greyed out and cannot be turned off or on except with the light selected and the following maxscript command:

    $.preview_texmap = false
    $.preview_texmap = true

    so what does it do?

    no reference in the docs, though there is a picture of the rollout here:
    https://docs.chaosgroup.com/display/...+%7C+VRayLight
    and in the disc light docs....

    I think I've asked this before: is there a way of working out (mathematically) how the light intensity is affected by the "directional" value of the light... Preferably independently of the light distribution area (radius or 1/2length 1/2 height).
    IE New intensity = OldIntensity x 2^(directional)/2
    or something?

  • #2
    Originally posted by rajdarge View Post
    In the "Vraylight-Rectangle/Disc light" rollout there is a little checkbox called:
    Preview texmap

    it is greyed out and cannot be turned off or on except with the light selected and the following maxscript command:

    $.preview_texmap = false
    $.preview_texmap = true

    so what does it do?

    no reference in the docs, though there is a picture of the rollout here:
    https://docs.chaosgroup.com/display/...+%7C+VRayLight
    and in the disc light docs....

    I think I've asked this before: is there a way of working out (mathematically) how the light intensity is affected by the "directional" value of the light... Preferably independently of the light distribution area (radius or 1/2length 1/2 height).
    IE New intensity = OldIntensity x 2^(directional)/2
    or something?
    I made some measurements once, didn't really find anything useful though and the devs don't seem to know either

    http://forums.chaosgroup.com/showthr...directionality
    A.

    ---------------------
    www.digitaltwins.be

    Comment


    • #3
      I don't know why this option - Preview texmap, is not listed in the V-Ray light documentation, but we will try to correct this asap.
      However, this option is grayed out if your 3DS Max viewport is configured to use Nitrous driver. I think this is a limitation.
      Tashko Zashev | chaos.com
      Chaos Support Representative | contact us

      Comment


      • #4
        Actually I haven't changed my display driver from the default setup. Does that mean that when I use the openGL or Direct3d driver that I can see the applied texmap on the light?
        that would be seriously wicked thing, and would happily go from nitrous to direct3d...

        @Vizioen: nice analysis of the light pattern.

        I will give your files a go and see if I can make any contributions.
        Don't hold your breath though


        Raj

        Comment


        • #5
          The Direct3D driver does indeed display the texMap if you set up one. Seriously useful. Shame the nitrous driver cannot do the same....
          also I have been working on the lightmeter testsetup and I thought a scripted response would be better
          Code:
          Currfile = getsourcefilename()
          CurDir = getFilenamePath (Currfile)
          animate off
          LtTesttarg = targetobject pos:[0,0,0] name:"TestLight.target"
          LtTest = vraylight pos:[0,0,100] targeted:true name:"TestLight"  width:5 height:5 normalizecolor:3 multiplier:1.0 preview_distribution:1 lightDistribution:0.0
          LtTest.target = LtTesttarg
          ltMeter = VRayLightMeter active:true width:10 length:10 orient:true colors:true text:true max:100000.0 min:0.0 pos:[0,0,0]
          
          with animate on 
          (
          	at time 0 ltTest.lightDistribution = 0.0
          	at time 90 ltTest.lightDistribution = 1.0
          )
          
          for i = 0 to 90 do 
          (
          	slidertime = i
          	ltMeter.calculate()
          	NewName = CurDir + "LightReads" + (i as string) + ".csv"
          	ltMeter.saveCSV NewName
          	print newName
          )
          the little script above generates a tests scene with the vraylightmeter being used to measure the light output.
          it generates 91 files that contain the CSV data. In reality I am only interested in the readings from the centre or 4 (zero indexed) in this case.
          and only the direct light.
          the values do jump around a bit, and the xyz positions do change as well. Not really sure why that is. Extracting the single useful value and graphing it is the next step.
          but I may have to jump to c++ as doing it in max script is unfamiliar territory.
          Raj

          Comment


          • #6
            So I looked at that script a little and found some major flaws.
            I will add to the other thread though this time.

            Comment


            • #7
              Originally posted by rajdarge View Post
              Actually I haven't changed my display driver from the default setup. Does that mean that when I use the openGL or Direct3d driver that I can see the applied texmap on the light?
              that would be seriously wicked thing, and would happily go from nitrous to direct3d...

              @Vizioen: nice analysis of the light pattern.

              I will give your files a go and see if I can make any contributions.
              Don't hold your breath though


              Raj
              Just did a test with Max 2016 Legacy Direct3d viewport driver to confirm.
              Click image for larger version

Name:	2016-08-26 16_07_22}.png
Views:	1
Size:	88.9 KB
ID:	863266
              Tashko Zashev | chaos.com
              Chaos Support Representative | contact us

              Comment


              • #8
                Yeah did that too with the legacy driver, It looks impressive, but there is one bug: the black areas should be transparent as they emit no light.
                raj

                Comment


                • #9
                  Is it too hard (or plain impossible ATM) to have textured lights in viewport for Nitrous? That's something I wish for quite a while. Although it should be trivial to make a script that creates a non-renderable plane to preview textured light sources.

                  -Eugenio

                  EDIT: Made a quick simple script and it seems to be working pretty fine. Copy and paste the code to the listener and run it. You can also drag and drop into a menu to create a button. Hope it helps.

                  NOTES:
                  -Works on selection or all lights if nothing is selected.
                  -Running multiple times doesn't duplicate plane objects.
                  -Only textured plane lights are considered.
                  -A light green wire color is used when the texture is on, and orange when it's off.
                  -Plane objects are named with lightname + "_LightTex" suffix for easy filtering.
                  -Plane materials are named as "LightTex_" + lightname" prefix as it groups their materials better.
                  -Plane object has negative scale to match light texture orientation.

                  Code:
                  (    objs = if selection.count == 0 then lights else selection as array
                      
                      name = "LightTex"
                      
                      for l in objs where isKindof l VrayLight and l.type == 0 and l.texmap != undefined do
                      (
                          planeName = (l.name + "_" + name)
                          
                          if isValidNode (p=(getNodeByName planeName)) do delete p
                          
                          mat = standardMaterial name:(name + "_" + l.name) diffuseMap:l.texmap selfIllumAmount:100 showInViewport:true
                          
                          plane    \
                          width:(l.size0*2)    \
                          length:(l.size1*2) \
                          lengthsegs:2 \
                          widthsegs:2 \
                          wireColor:(if l.texmap_on then color 180 255 50 else color 230 120 0) \
                          parent:l \
                          name:planeName \
                          transform:(scaleMatrix [-1,1,1] * l.transform) \
                          renderable:false \
                          isFrozen:true \
                          showFrozenInGray:false \
                          material:mat
                      )
                  )
                  Last edited by Midiaeffects; 26-08-2016, 09:05 PM.

                  Comment


                  • #10
                    I have a similar script, you should apply the material to the opacity map, and freeze the plane once parented, and wire the dimensions of the plane to the half width and height, at least that's what I did
                    Last edited by rajdarge; 26-08-2016, 10:15 PM.

                    Comment


                    • #11
                      Indeed! Thanks for pointing that out. I just don't see much of a need to freeze the plane after parent though. I mean, it's just a preview dummy anyway.

                      -Eugenio

                      Comment


                      • #12
                        it gets annoying when you are working with the light in the scene as you keep selecting the plane and not the light

                        Comment


                        • #13
                          Ohhhh, but it does that . I thought you mean freeze transform, as I've used negative scaling.

                          This little update applies texture to opacity too and instance plane and light sizes:
                          Code:
                          (    objs = if selection.count == 0 then lights else selection as array
                              
                              name = "LightTex"
                              
                              for l in objs where isKindof l VrayLight and l.type == 0 and l.texmap != undefined do
                              (
                                  planeName = (l.name + "_" + name)
                                  
                                  if isValidNode (p=(getNodeByName planeName)) do delete p
                                  
                                  mat = standardMaterial name:(name + "_" + l.name) diffuseMap:l.texmap opacityMap:l.texmap selfIllumAmount:100 showInViewport:true
                                  
                                  p = plane    \
                                  lengthsegs:2 \
                                  widthsegs:2 \
                                  wireColor:(if l.texmap_on then color 180 255 50 else color 230 120 0) \
                                  parent:l \
                                  name:planeName \
                                  transform:(scaleMatrix [-2,2,2] * l.transform) \
                                  renderable:false \
                                  isFrozen:true \
                                  showFrozenInGray:false \
                                  material:mat
                                  
                                  p.width.controller = l.size0.controller = Bezier_Float()
                                  p.length.controller = l.size1.controller = Bezier_Float()
                              )
                          )
                          -Eugenio

                          Comment


                          • #14
                            I didn't see the "isfrozen:true" in the previous script on my phone. Its a bit hard to read at time.
                            Clever using the scale matrix like that, I couldn't understand why you were using it before when you could have just copied the transform across.
                            I used wire parameters to link the height and width, but it was prone to crashing if something went wrong, this approach is simpler. I suppose its safer to delete the object rather than update the texture map if it gets changed, though something keeps nagging that it should update.
                            also light.type ==4 is valid for a texture map. Linking the controllers and changing the "radius" gives some strange results
                            I haven't found a way of wrapping a mirrored ball HDR on to a sphere yet to simulate a dome light. Though panotools library looks interesting in converting to an equirectangular map and applying it to a sphere. Trying to align a HDR is a PITA using activeshade mode.
                            Last edited by rajdarge; 27-08-2016, 08:12 AM.

                            Comment


                            • #15
                              its been 5 years since I've programmed any maxscript, or really used 3dsMax in any serious way - busy doing other stuff
                              However Back in the dim dark past I learned these 2 things that I thought were truisms:
                              1. Negative Scaled objects are BAD, evil and the mark of the devil. At least according to bobo. I still cannot understand why you would choose to do this to an object. Once it is negative scaled, I can see no way of fixing in. In fact I left the 3ds max world with the distinct impression that applying any global scale to an object is a disaster waiting to happen. Maybe this has been fixed in the last 5 years, along with the mirror tool. I don't know. Correct me if I am wrong. I've barely touched it, just kept up my subscription.
                              2. The script Controller is slow, the expression controller is fast.
                              SO with these thoughts in mind, I changed the above script to take into account the above notions. For 18 months of those last 5 years I taught myself C++ and OOP and in that process I learned (the hard way as I try to pick up the pieces of my 5 year old code to work out WTF I was thinking) that clarity in coding is more important than typing. There was a term that was commonly used for code that was too compact, so to avoid that inference my code is a little kludgier. I'm trying to keep in mind that is not a compiled language so the are other determinants of speed etc that are not apparent in compiled code.
                              so here 'tis:
                              Code:
                               
                              (    objs = if selection.count == 0 then lights else selection as array
                                  
                                  name = "LightTex"
                                  
                                  for l in objs where isKindof l VrayLight and (l.type == 0 or l.type == 4) and l.texmap != undefined do
                                  (
                                      
                              		planeName = (l.name + "_" + name)
                                      
                                      if isValidNode (p=(getNodeByName planeName)) do delete p
                                      
                                      mat = standardMaterial name:(name + "_" + l.name) diffuseMap:l.texmap \
                              		opacityMap:l.texmap selfIllumAmount:100 showInViewport:true         
                                      p = plane  lengthsegs:2 widthsegs:2 wireColor:(if l.texmap_on then color 180 255 50 else color 230 120 0) \
                                      parent:l name:planeName \
                              		transform:l.transform \ -- take out the negative scaling. 
                              		renderable:false isFrozen:true showFrozenInGray:false \
                                      material:mat
                              		l.size0.controller = Bezier_Float() -- must have a controller to use in the expression
                                      l.size1.controller = Bezier_Float()
                              		floatExpC_1 = Float_Expression name:"p_width" -- create an expression float controller
                              		floatExpC_2 = Float_Expression name:"p_height" 
                              		p.width.controller = floatExpC_1
                              		p.length.controller = floatExpC_2
                              		floatExpC_1.AddScalarTarget  "W" l.size0.controller
                              		floatExpC_1.SetExpression  "W*2.0" -- muliply by 2 
                              		if (l.type == 0) then floatExpC_2.AddScalarTarget  "L" l.size1.controller
                              		else floatExpC_2.AddScalarTarget  "L" l.size0.controller
                              		floatExpC_2.SetExpression  "L*2.0"
                                  )
                              )
                              I could refine it further to get the naming scheme better as clearly a disc has a radius, but I left it
                              also is there a max primitive that is a disc? You can use a circle line and then apply a UVW map modifier I suppose. Is that a good idea?

                              Comment

                              Working...
                              X