Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Calinou committed Oct 6, 2022
0 parents commit cd87faa
Show file tree
Hide file tree
Showing 24 changed files with 428 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.godot/
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright © 2022 Hugo Locurcio and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Godot 3D LUT example

This project includes code for generating 3D look-up-tables for color correction.
Example output files are included in the `generated/` folder.

If you are copying neutral LUTs for use in your projects, make sure to also
copy the associated `.import` file to get the import type to be set up
correctly immediately. This allows using the LUT without having to restart
the editor.

> **Note**
>
> 3D LUT color correction is only supported in Godot 4, not Godot 3.x.
> Godot 3.x is limited to 1D LUT color correction, which doesn't allow adjusting
> each channel's output individually (red/green/blue).
## License

Copyright © 2022 Hugo Locurcio and contributors

Unless otherwise specified, files in this repository are licensed under the
MIT license. See [LICENSE.md](LICENSE.md) for more information.
Binary file added generated/lut_neutral_17x17x17_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions generated/lut_neutral_17x17x17_horizontal.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://bltpkc15qgxdu"
path="res://.godot/imported/lut_neutral_17x17x17_horizontal.png-e7b79b75e8939dc107e83184170a765a.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://generated/lut_neutral_17x17x17_horizontal.png"
dest_files=["res://.godot/imported/lut_neutral_17x17x17_horizontal.png-e7b79b75e8939dc107e83184170a765a.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=17
slices/vertical=1
Binary file added generated/lut_neutral_17x17x17_vertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions generated/lut_neutral_17x17x17_vertical.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://cxe5mtcgxagrn"
path="res://.godot/imported/lut_neutral_17x17x17_vertical.png-87b5e381f94d7288f0216ac37f421cdb.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://generated/lut_neutral_17x17x17_vertical.png"
dest_files=["res://.godot/imported/lut_neutral_17x17x17_vertical.png-87b5e381f94d7288f0216ac37f421cdb.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=1
slices/vertical=17
Binary file added generated/lut_neutral_33x33x33_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions generated/lut_neutral_33x33x33_horizontal.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://q5me8eo3omhu"
path="res://.godot/imported/lut_neutral_33x33x33_horizontal.png-074e3dec47a1470994ca965bce966284.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://generated/lut_neutral_33x33x33_horizontal.png"
dest_files=["res://.godot/imported/lut_neutral_33x33x33_horizontal.png-074e3dec47a1470994ca965bce966284.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=33
slices/vertical=11
Binary file added generated/lut_neutral_33x33x33_vertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions generated/lut_neutral_33x33x33_vertical.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://kjxutkb40b1"
path="res://.godot/imported/lut_neutral_33x33x33_vertical.png-b20904315527cbaa974b5f6466f82060.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://generated/lut_neutral_33x33x33_vertical.png"
dest_files=["res://.godot/imported/lut_neutral_33x33x33_vertical.png-b20904315527cbaa974b5f6466f82060.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=1
slices/vertical=33
Binary file added generated/lut_neutral_51x51x51_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions generated/lut_neutral_51x51x51_horizontal.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://dofdniooup5s4"
path="res://.godot/imported/lut_neutral_51x51x51_horizontal.png-a736654980c8e5d48f6f87b96ec80e52.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://generated/lut_neutral_51x51x51_horizontal.png"
dest_files=["res://.godot/imported/lut_neutral_51x51x51_horizontal.png-a736654980c8e5d48f6f87b96ec80e52.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=51
slices/vertical=1
Binary file added generated/lut_neutral_51x51x51_vertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions generated/lut_neutral_51x51x51_vertical.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://bfc0its36y4sx"
path="res://.godot/imported/lut_neutral_51x51x51_vertical.png-1e5cf37ced5e473386c7ac28d056172c.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://generated/lut_neutral_51x51x51_vertical.png"
dest_files=["res://.godot/imported/lut_neutral_51x51x51_vertical.png-1e5cf37ced5e473386c7ac28d056172c.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=1
slices/vertical=51
Binary file added generated/lut_neutral_65x65x65_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions generated/lut_neutral_65x65x65_horizontal.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://dedfx4qadga8v"
path="res://.godot/imported/lut_neutral_65x65x65_horizontal.png-de7ab7af90b0e021a5cd3ab6eb567d1b.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://generated/lut_neutral_65x65x65_horizontal.png"
dest_files=["res://.godot/imported/lut_neutral_65x65x65_horizontal.png-de7ab7af90b0e021a5cd3ab6eb567d1b.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=65
slices/vertical=1
Binary file added generated/lut_neutral_65x65x65_vertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions generated/lut_neutral_65x65x65_vertical.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://pnwc1ekstrak"
path="res://.godot/imported/lut_neutral_65x65x65_vertical.png-f4fd1e319aca723c71e99d8dcac42c2e.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://generated/lut_neutral_65x65x65_vertical.png"
dest_files=["res://.godot/imported/lut_neutral_65x65x65_vertical.png-f4fd1e319aca723c71e99d8dcac42c2e.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=1
slices/vertical=65
Binary file added lut_dramatic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions lut_dramatic.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[remap]

importer="3d_texture"
type="CompressedTexture3D"
uid="uid://c6xhnhtelbuox"
path="res://.godot/imported/lut_dramatic.png-eace9591a84e05e5f3650c7ffedb83ce.ctex3d"
metadata={
"vram_texture": false
}

[deps]

source_file="res://lut_dramatic.png"
dest_files=["res://.godot/imported/lut_dramatic.png-eace9591a84e05e5f3650c7ffedb83ce.ctex3d"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=33
slices/vertical=1
38 changes: 38 additions & 0 deletions node_3d.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
extends Node3D


func create_neutral_lut(p_name: String, p_size: int, p_vertical: bool):
var image = Image.new()
image.create(
p_size if p_vertical else (p_size * p_size),
(p_size * p_size) if p_vertical else p_size,
false,
Image.FORMAT_RGB8
)

for z in p_size:
var x_offset := int(z * p_size) if not p_vertical else 0
var y_offset := int(z * p_size) if p_vertical else 0
for x in p_size:
for y in p_size:
image.set_pixel(x_offset + x, y_offset + y, Color8(
roundi((x / float(p_size - 1)) * 255),
roundi((y / float(p_size - 1)) * 255),
roundi((z / float(p_size - 1)) * 255)
))

image.save_png("user://" + p_name + ".png")


func _ready() -> void:
create_neutral_lut("lut_neutral_17x17x17_horizontal", 17, false)
create_neutral_lut("lut_neutral_33x33x33_horizontal", 33, false)
create_neutral_lut("lut_neutral_51x51x51_horizontal", 51, false)
create_neutral_lut("lut_neutral_65x65x65_horizontal", 65, false)
create_neutral_lut("lut_neutral_17x17x17_vertical", 17, true)
create_neutral_lut("lut_neutral_33x33x33_vertical", 33, true)
create_neutral_lut("lut_neutral_51x51x51_vertical", 51, true)
create_neutral_lut("lut_neutral_65x65x65_vertical", 65, true)

OS.shell_open(ProjectSettings.globalize_path("user://"))
get_tree().quit()
Loading

0 comments on commit cd87faa

Please sign in to comment.