-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathevaluate_exr_texture.py
61 lines (55 loc) · 2.13 KB
/
evaluate_exr_texture.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# DO NOT EDIT THIS FILE DIRECTLY. This is generated from a literate program
# with the VSCode extension Literate Programming (jesterking.literate).
#
# These literate programs are Rhino 3D scripts explaining how scripting works
# in Rhino 3D with Python.
#
# Read the literate programs at:
# https://jesterking.github.io/literate
#
# This code is part of the repository:
# https://github.com/jesterKing/rhipy
#
# The Literate Programming extension repository is at:
# https://github.com/jesterKing/literate
#
# Licensed under Apache 2.0
# See https://github.com/jesterKing/rhipy/blob/master/LICENSE
#
# Copyright (C) Nathan 'jesterKing' Letwory
#
import Rhino
file_dialog = Rhino.UI.OpenFileDialog()
file_dialog.Filter = "EXR (*.exr)|*.exr"
if file_dialog.ShowDialog():
print(file_dialog.FileName)
render_texture = Rhino.Render.RenderContentType.NewContentFromTypeId(
Rhino.Render.ContentUuids.HDRTextureType
)
render_texture.BeginChange(Rhino.Render.RenderContent.ChangeContexts.Program)
render_texture.SetParameter("filename", file_dialog.FileName)
render_texture.EndChange()
evaluator = render_texture.CreateEvaluator(
Rhino.Render.RenderTexture.TextureEvaluatorFlags.DisableLocalMapping
| Rhino.Render.RenderTexture.TextureEvaluatorFlags.DisableAdjustment
| Rhino.Render.RenderTexture.TextureEvaluatorFlags.DisableProjectionChange
)
size = render_texture.PixelSize2
if size:
width = size[0]
height = size[1]
half_pixel_u = 0.5 / width
half_pixel_v = 0.5 / height
col4f = Rhino.Display.Color4f()
pt = Rhino.Geometry.Point3d.Origin
dummy_duvw = Rhino.Geometry.Vector3d.Zero
count = 0
for y in range(height):
for x in range(width):
if count % 1013 == 0:
pt.X = float(x) / float(width) + half_pixel_u
pt.Y = float(y) / float(height) + half_pixel_v
ok, col4f = evaluator.GetColor(pt, dummy_duvw, dummy_duvw, col4f)
if ok:
print col4f.R, col4f.G, col4f.B, col4f.A
count += 1