LDView POV-Ray rendering in 2020


POV-Ray rendering in 2020
#1
Information 
I've been exploring lego rendering using the LDraw system over the last few months, and it's been quite a journey. I've found several guides online from over the last ten years that have had various tips on how to get a good render using LDraw & POV-Ray. There was a lot of great info in them, but some of the advice was now out of date, and I had to spend a while comparing info between guides to get a good process.

So, now that I have a process that I'm pretty happy with, I thought I'd share it here for other's interest, and feedback is also welcome.

0. Install the LDraw AIOI package
Install whatever designers you like, and for rendering I am using LDView, the LDraw parts library, and Pov-Ray 3.7. (I am not using any of the POV-Ray alternatives such as Mega-Ray etc, as it seems POV-Ray 3.7 is newer / better than them.)

After installing that, I also install the latest version of LDView I can get, newer than what is in the LDraw AIOI at time of writing, which does change the .pov file exported, it seems to use new features of POV-Ray 3.7. I downloaded it from here: https://github.com/tcobbs/ldview/release...v4.4_Beta2

1. Generate the POV-Ray file in LDView
When LDView exports to a .pov file, it knows about high resolution part models designed for rendering, which results in a much better quality render. (It's doing this by using LGEO.xml to map to .inc part files, instead of using the standard / editor .dat part definition files). 

The process to generate the pov file is to open your model file (probably an .ldr file) in LDView, then choose file menu, export...

I don't edit any of the options here, just save the file

2. Set up POV-Ray to render larger resolutions
You'll probably want to render a larger file than what POV-Ray offers by default. For one thing, the Anti-Aliasing in POVRay is not great. So, render at 2x the dimensions you want, then resize down in a program that has bicubic (or other better) resize algorithm (eg. I use the free image editor, Paint.net). 

So, to do this, you need to make a one-time edit to a file that POV-Ray reads to get the render size options to offer. The file will be located at: C:\Users\[yourusername]\Documents\POV-Ray\v3.7\ini\quickres.ini

Making sure POV-Ray is closed at the time, open that file into a text editor.

If you wanted to render at 1920x1080 as you final resolution, you would want an option to render initially as 3840x2160, which you would add to the end of the file as:
[3840x2160, No AA]
Width=3840
Height=2160
Antialias=Off

Once you've added this once, save and close the file. Now this size will be available all the time in POV-Ray as a render option - which we'll get to in a minute.

3. Edit your .pov file in POV-Ray - change it to use Radiosity rendering
The default lighting provided in the .pov file from LDView has a standard 3-lights lighting setup, which casts some fairly strong shadows. I prefer to use an alternative lighting option called Radiosity rendering. To change to this I make two simple copy-paste changes at the top of .pov file, which I can do exactly the same on any file I want to render. They are:

Open the .pov file in POV-Ray first. Look at the top of the file, right below the comments, for these two lines:
Code:
#version 3.7;

#if (version >= 3.7) global_settings {assumed_gamma 1} #end

Replace them with (don't miss the scroll bar and extra lines here):
Code:
#version 3.7;

#include "rad_def.inc"

global_settings {
      max_trace_level 10
      radiosity {
              Rad_Settings(Radiosity_Final, on, off)
      }
      assumed_gamma 1
}

light_source { // X, Y, Z
      <-1000, -1500, -1000>
      color rgb 0.5
      area_light 200, 200, 10, 10
      jitter
}

#declare LDXSkipLight1 = 1;
#declare LDXSkipLight2 = 1;
#declare LDXSkipLight3 = 1;

Then scroll down just a bit to the // Camera settings section, and look for these 5 lines:
Code:
#ifndef (LDXFloorR) #declare LDXFloorR = 0.8; #end // Floor Red
#ifndef (LDXFloorG) #declare LDXFloorG = 0.8; #end // Floor Green
#ifndef (LDXFloorB) #declare LDXFloorB = 0.8; #end // Floor Blue
#ifndef (LDXFloorAmb) #declare LDXFloorAmb = 0.4; #end // Floor Ambient
#ifndef (LDXFloorDif) #declare LDXFloorDif = 0.4; #end // Floor Diffuse

Replace with:
Code:
#ifndef (LDXFloorR) #declare LDXFloorR = 1; #end // Floor Red
#ifndef (LDXFloorG) #declare LDXFloorG = 1; #end // Floor Green
#ifndef (LDXFloorB) #declare LDXFloorB = 1; #end // Floor Blue
#ifndef (LDXFloorAmb) #declare LDXFloorAmb = 0; #end // Floor Ambient
#ifndef (LDXFloorDif) #declare LDXFloorDif = 0.9; #end // Floor Diffuse

4. Do a test render
The final render can take a while, even on a multi-core i7 cpu, so you want to be sure you're happy. So do a small test render to make sure its looking right.

You do this by, in POV-Ray, in the dropdown list of resolutions in the top left corner choose a small size (eg 800x600) , then press the Run icon across the top toolbar.


5. Do the final render
Once a test render looks good, time to do the final render.

To do this, go back to that dropdown list of resolutions, and look for your large size you added earlier, and choose that. Then press Run again. For a fairly simple model, the render will probably take 15 mins to an hour, depending on your hardware.

6. Resize to your final size
Open your resulting .png file in your image editing program, and resize it down 50% to your final resolution, and save.


So that's my process, I think it produces pretty nice results, with a fairly simple workflow per image. I hope someone finds it helpful. And also would be interested to hear what anyone else is doing with POV-Ray now in 2020.
Reply
RE: POV-Ray rendering in 2020
#2
Fine job! Would it be possible to put it on the wiki along with some before/after pictures?

w.
LEGO ergo sum
Reply
RE: POV-Ray rendering in 2020
#3
To save you a few steps in your work flow do this:

Take all of your code and put it in a single text file using 'notepad' and name it, for example "Top inlcude.inc"
Code:
#include "rad_def.inc"

global_settings {
      max_trace_level 10
      radiosity {
              Rad_Settings(Radiosity_Final, on, off)
      }
      assumed_gamma 1
}

light_source { // X, Y, Z
      <-1000, -1500, -1000>
      color rgb 0.5
      area_light 200, 200, 10, 10
      jitter
}

#declare LDXSkipLight1 = 1;
#declare LDXSkipLight2 = 1;
#declare LDXSkipLight3 = 1;

#ifdef (LDXFloorR) #declare LDXFloorR = 1; #end // Floor Red
#ifdef (LDXFloorG) #declare LDXFloorG = 1; #end // Floor Green
#ifdef (LDXFloorB) #declare LDXFloorB = 1; #end // Floor Blue
#ifdef (LDXFloorAmb) #declare LDXFloorAmb = 0; #end // Floor Ambient
#ifdef (LDXFloorDif) #declare LDXFloorDif = 0.9; #end // Floor Diffuse

*Notice that I used "#ifdef" (if defined) instead of "ifndef" (if not defined) since the values will be declared before the file is included (you will see below). You could also use "#declare [variable] = [value];" and POV-Ray will re-declare (overwrite) the variable.



Next open the LDView with your model and choose export from the File menu:
   


Then open the options dialog:
   


An in the "Top include filename (empty for no top include):" add your full file address from where you saved your "Top inlcude.inc" file (remember you can name it "[whateveryouwant].inc") and then save your pov model file.

.png   include.png (Size: 16.81 KB / Downloads: 122)


This will make your changes automatically appear in every pov file you export with the LDView from that point forward and safe you the time of manually editing each file every time. Notice that a lot of variables are already declared above the file include. If you intend to change any of these variables you have to use "ifdef" or "declare" as stated above.
   


You can conviniently open your "Top inlcude.inc" file from within POV-Ray and make changes there, save the file (no need to close the tab) and run a render without having to open and close the file outside the program.
   

Hope that helps.


P.S.
Yes I have a Zeta Drive... No I don't have 26 drives, only 6.
Reply
RE: POV-Ray rendering in 2020
#4
(2020-10-22, 16:25)Leonardo Gonzalez Wrote: To save you a few steps in your work flow do this:
....

Oh thanks, this is super great!!

I just had a go setting it up as you described and it went perfectly. Will definitely help out with future renders. Copy-paste doesn't only take time, it also is chance for mistakes, so I'm glad to eliminate it.

I did read about these includes at some time, but for some reason didn't make the connection that it'd help with doing something like this.

Thanks again for taking the time to write this out Smile
Reply
RE: POV-Ray rendering in 2020
#5
(2020-10-21, 3:07)Ber Wrote: And also would be interested to hear what anyone else is doing with POV-Ray now in 2020.

I currently use Blender with ImportLdraw, but before I used POV-Ray. For the illumination I also skipped the three default lights and used different solutions:

- Uniform light: a white sphere surrounding the scene

Code:
sphere{LDXCenter, 10000
  texture{
    pigment{ color rgb<1,1,1>}
    finish{emission 1}
  }
  hollow no_image
}

- HDRI: from a realistic or virtual environment. Depending on the extension, POV-Ray expects HDR or EXR before the filename. The ANGLE variable rotates that environment.

Code:
sky_sphere{
  pigment{
    image_map{
      HDR 'file.hdr'
      gamma 1.5
      map_type 1 interpolate 2}
  }
  rotate 180*z
  rotate ANGLE*y
}
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 3 Guest(s)