Skip to content

Commit

Permalink
Add parameter for width
Browse files Browse the repository at this point in the history
  • Loading branch information
regulus79 committed Feb 3, 2024
1 parent eed6a1e commit 0ff1999
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Convert HDRI images into six-image skyboxes, using the python cv2 library

`python convert.py path/to/hdri path/to/output [--brightness-scale=1]`

Example: `python convert.py images/hochsal_field_1k.hdr ~/.minetest/mods/hdriskybox/textures/test`
Example: `python convert.py images/hochsal_field_1k.hdr ~/.minetest/mods/hdriskybox/textures/test [--width=256]`

Note: make sure that the output path is not a full image path. Leave it at something like `textures/skybox`, and the program will save the images to `textures/skybox_top.png`, `textures/skybox_front.png`, and so on.

The optional parameter scales the brightness of the output images. By default, the brightness of the output images are scaled so that 255 is the average brightness of the original HDRI. This is done since many HDRI's are quite dim in most places. Ideally, this would be corrected by using a tonemap or something, but I do not currently have the time or expertise to implement that.
The optional parameter "--brightness-scale" scales the brightness of the output images. By default, the brightness of the output images are scaled so that 255 is the average brightness of the original HDRI. This is done since many HDRI's are quite dim in most places. Ideally, this would be corrected by using a tonemap or something, but I do not currently have the time or expertise to implement that.

The parameter "--width" is the width of the output skybox images. I would not recommend going above 512 or so, since the code's complexity is quadratic, and it will take a very long time to generate.
5 changes: 3 additions & 2 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
parser.add_argument("input_path",type=str,help="Path to the input 360 image")
parser.add_argument("output_path",type=str,help="Path to where the script should save the skybox. NOTE: the program will automatically add '_top.png' and such to the end of the path, so it is best to give a path like 'images/my_skybox', so that it will save the 6 images to 'images/my_skybox_toppng' and so on.")
parser.add_argument("--brightness-scale",type=float,help="The multiplier for the brightness of the HDRI. By default, the output skybox is scaled so that the average brigthness of the HDRI is 255 in the output, since many HDRI's get very bright. Default: 1",nargs="?",default=1)
parser.add_argument("--width",type=int,help="The width of the output skybox images. Default: 256",nargs="?",default=256)
args=parser.parse_args()

input_path=args.input_path
Expand All @@ -26,8 +27,8 @@
# Save the average brightness for later when the final images are scaled.
average_value=np.average(img)

# Width of the output skybox images
width=256
# Width of the output skybox images, default 256
width=args.width

# The direction parameter is a number from 0 to 6, in order of: x+, x-, y+, y-, z+, z-
def generate_tile(direction,width):
Expand Down

0 comments on commit 0ff1999

Please sign in to comment.