Sign in to follow this  
HoMa

How to export light.dat from MLCad to LDView to POV

Recommended Posts

I am currently working myself through this great tutorial using MLcad 3.4, LDView 4.1 and POV-Ray for Windows 3.7:

[Guide] Rendering LDraw models using POV-Ray http://www.eurobrick...showtopic=65876

Now I want to gain more control of the the lights, so I've added a light.dat in the source .ldr file in MLCad. In LDView this light.dat is shown and I can switch it on and off and I can play around with "replace main lights".

When it comes to the POW export I do not see any difference in the .pov file which is created. It always has the three default lights and I wonder where the only one light.dat is which I have inserted in MLCad.

This is the //Lights section in my .pov file:

// Lights
#ifndef (LDXSkipLight1)
light_source { // Latitude,Longitude: 45,0,LDXRadius*2
<0*LDXRadius,-1.414214*LDXRadius,-1.414214*LDXRadius> + LDXCenter
color rgb <1,1,1>
}
#end
#ifndef (LDXSkipLight2)
light_source { // Latitude,Longitude: 30,120,LDXRadius*2
<1.5*LDXRadius,-1*LDXRadius,0.866026*LDXRadius> + LDXCenter
color rgb <1,1,1>
}
#end
#ifndef (LDXSkipLight3)
light_source { // Latitude,Longitude: 60,-120,LDXRadius*2
<-0.866025*LDXRadius,-1.732051*LDXRadius,0.5*LDXRadius> + LDXCenter
color rgb <1,1,1>
}
#end

Is there any option in the export settings for the pov export of LDView to overwrite the default lights and just use the light.dat from the source .ldr?

Anyone any ideas?

Thanks in advance,

HoMa

Share this post


Link to post
Share on other sites

Hello HoMa,

until now I was not aware at all that it is possible to add povray light sources directly in MLcad.

So I made a quick test setup and now I can confirm your problem: There is no additional light in the render which is based on light.dat.

However, but there is something. Please have a deeper look to your pov-file!

(1) To localise the light.dat source in your render, respectively to make it visible, please try to set ldxqual to 0 => #declare LDXQual = 0;

You will find the relevant code most probably right at the beginning of your pov-file. As a result you should see a cube in your render which represents the light source.

(2) Most probably your Pov-File contains several expressions like “LDX_light_dot_dat”. This is the converted code based on Light.dat.

See for example (or similar):

object {

LDX_light_dot_dat

LDXSeamMatrix(8, 8, 8, 0, 0, 0)

matrix <1,0,0,0,1,0,0,0,1,-11,-41,0>

#if (version >= 3.1) material #else texture #end { LDXColor15 }

}

Unfortunately I do not understand the intention of all the related code, respectively how the relevant code is able to generate light. In other words: This code does not work the way it should work.

If anybody should have a deeper insight in this problem, please let us know!

(3) If you wish to have a light source exactly at your light.dat position, you can use the position data from the object definition (see above): The position data of the light.dat light source is represented by the matrix term => matrix <1,0,0,0,1,0,0,0,1,-11,-41,0>

So please add the following term (with correct position matrix) to your pov-file:

object { light_source { <0,0,0> color rgb <1,1,1> } matrix <1,0,0,0,1,0,0,0,1,-11,-41,0> }

And remove all other preset light sources.

I am sure, in the first moment all the above is absolutely confusing. Furthermore I wonder if you wish to invest such an effort just to have “control” over your light sources in povray. Why don’t you just add some self defined light sources in povray? Adding light sources directly in povray gives you full control!

Please let me know if you require any further support.

kind regards

papacharly

Share this post


Link to post
Share on other sites

Hi papacharly,

thank you for looking into my "problem". So far I was able to follow you:

  • light.dat is now visible in the rendered scene using #declare LDXQual = 0;
  • object { LDX_light_dot_dat ... is identified in the pov file.

If I just use

object { light_source {  <0,0,0>  color rgb <1,1,1>  } matrix <1,0,0,0,1,0,0,0,1,-11,-41,0> }

and delet all other lights, I just get black boxes and no light at all. It seems to be that the lights should be declared as light_source only, without object { light_source }.

Adding the matrix information to one of the three default lights which were set by the LDView-2-POV export doesn't make a difference:

// Lights
#ifndef (LDXSkipLight1)
light_source {    // Latitude,Longitude: 45,0,LDXRadius*2
   <0*LDXRadius,-1.414214*LDXRadius,-1.414214*LDXRadius> + LDXCenter
   color rgb <1,1,1>
   matrix <1,0,0,0,1,0,0,0,1,0,12,-90>   
   }
#end

I think I do not understand the position definition <0*LDXRadius,-1.414214*LDXRadius,-1.414214*LDXRadius> + LDXCenter in the light_source. LDXRadius and LDXCenter are variables which are defined at the top of the pov file. But I have no idea what these four values are:

  1. 0*LDXRadius
  2. -1.414214*LDXRadius
  3. -1.414214*LDXRadius
  4. LDXCenter

Anyway, thanks for your help so far and great to see your renderings at your http://www.flickr.com/photos/107790234@N02/ gallery!

Kind regards,

HoMa

Share this post


Link to post
Share on other sites

Hello HoMa,

please reset LDXQual to the old value! Otherwise the light source may be encapsulated by a non-transparent box. So no light will get out of this box.

Yes, the standard way of defining light sources is just using the term “lightsource”. If you use “object” as a container for a light source, you can easily transform the position of the light source by using a matrix. To keep it simple, my idea was to directly use the data given in your pov-file. Most probably this was not one of my best ideas. So please forget this possibility.

One more try to get ahead (and to keep it simple too):

If you wish to position light sources directly in pov-ray you can use for example

light_source { <x,y,z> color rgb <1,1,1> }. Which is a white spotlight at position <x,y,z>.

For more information about light sources please have a look to http://www.f-lohmuel...t/camlit_d1.htm

I usually delete all these predefined light sources and add my own light sources. To be able to position light sources or any other objects accurately in a povray render I usually add a coordinate system:

// x-axis (red)

cylinder { <0, 0.0, 0.0>, <1000.0, 0.0, 0.0>, 20 pigment{ color rgb<1,0,0>}}

// y-axis (green) NEGATIVE

cylinder { <0, 0.0, 0.0>, <0.0, -1000.0, 0.0>, 20 pigment{ color rgb<0,1,0>}}

// z-axis (blue)

cylinder { <0, 0.0, 0.0>, <0, 0.0, 1000.0>, 20 pigment{ color rgb<0,0,1>}}

This way it is easier to understand where objects are, where objects have to be placed or in which direction objects have to be moved. Please note: The y-axis in povray is inverted. So “up” means negative y-values.

And glad you like my renders! Thanks. And looking forward to your renders!

regards

papacharly

Share this post


Link to post
Share on other sites

Hi papacharly,

thanks again for your useful tips! Now I can use the light.dat and it's modifications to the object { lightsource ... Basically this is, what I wanted!

The coordinate system is really helpful, I felt a bit lost in pov-space and did not now where "zero" is, which makes it hard to estimate which numbers needs to be changed.

I also found out, that just using the 3 default lights plus an 4th extra light at the camera location is a great help also. But it is good to know, how to use the light.dat set in MLCad later in the rendering process. This might be handy for lights in headlights etc. (like you've done it in your submarine underwater scene.

Also, thanks for the link to the pov tutorial. This is written in a language I really understand because it gives examples from the real world, e.g. describing a light source like the sun or a local lamp.

Kind regads,

Holger

Share this post


Link to post
Share on other sites
// Lights
#ifndef (LDXSkipLight1)
light_source { // Latitude,Longitude: 45,0,LDXRadius*2
<0*LDXRadius,-1.414214*LDXRadius,-1.414214*LDXRadius> + LDXCenter
color rgb <1,1,1>
matrix <1,0,0,0,1,0,0,0,1,0,12,-90>
}
#end

I think I do not understand the position definition <0*LDXRadius,-1.414214*LDXRadius,-1.414214*LDXRadius> + LDXCenter in the light_source. LDXRadius and LDXCenter are variables which are defined at the top of the pov file. But I have no idea what these four values are:

  1. 0*LDXRadius
  2. -1.414214*LDXRadius
  3. -1.414214*LDXRadius
  4. LDXCenter

I can explain that bit. Let's start with the variables that LDView puts in the pov file.

LDXCenter is the middle of your model; < (Xmax + Xmin)/2, (Ymax + Ymin)/2, (Zmax + Zmin)/2 >.

LDXRadius. Looking at the values in my model I'm guessing it's the radius of the smallest sphere you could draw around the entire model.

So how are these variables used to position a light?

light_source { // Latitude,Longitude: 45,0,LDXRadius*2
<0*LDXRadius,-1.414214*LDXRadius,-1.414214*LDXRadius> + LDXCenter

The comment explains what's happening in the next line; it's defining a light source at latitude 45, longitude 0, and distance 2xLDXRadius from LDXCenter.

Latitude is how high above the horizon you are, longitude is how far from North you are, with North in PovRay apparently defined as the negative z-axis.

Light source starts with a position for the light. <0*LDXRadius,-1.414214*LDXRadius,-1.414214*LDXRadius> + LDXCenter is simply a location in x, y z with:

x = 0 * 2 * LDXRadius

y = -0.707107 * 2 * LDXRadius

z = -0.707107 * 2 * LDXRadius.

You may remember your Sin and Cos from trigonometry? At 45 degrees both Sin and Cos are sqrt(2)/2 or 0.707107.

So this light source sits above the z-axis (x=0), at a 45 degree angle from the middle of the model, and twice as far from the middle as the furthest point of the model.

Does that make sense?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.