angle and eyefish render
This commit is contained in:
parent
7c7f109a69
commit
bb618cff88
2 changed files with 38 additions and 12 deletions
33
app.py
33
app.py
|
@ -2,6 +2,7 @@ import tkinter
|
|||
import tkintermapview
|
||||
import requests
|
||||
import skydome
|
||||
import math
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
|
||||
|
@ -128,9 +129,18 @@ class renderedImageZoom:
|
|||
|
||||
p_frame.grid(column=0,row=8,columnspan=2,padx=20)
|
||||
|
||||
s_frame = tkinter.Frame(self.aerosol_window)
|
||||
text_s = tkinter.Text(s_frame,height=1,width=10)
|
||||
submit_s_button = tkinter.Button(s_frame,text="set direction of the sun",command=lambda: self.set_sun(text_s.get("1.0","end-1c")))
|
||||
text_s.pack(side=tkinter.LEFT)
|
||||
submit_s_button.pack(side=tkinter.RIGHT)
|
||||
|
||||
s_frame.grid(column=0,row=9,columnspan=2,padx=20)
|
||||
|
||||
|
||||
|
||||
testing_info_text = tkinter.Label(self.aerosol_window, text="Change y heights between which average redness and blueness will be calculated")
|
||||
testing_info_text.grid(column=0,row=9,columnspan=2,pady=20,padx=10)
|
||||
testing_info_text.grid(column=0,row=10,columnspan=2,pady=20,padx=10)
|
||||
|
||||
r_frame = tkinter.Frame(self.aerosol_window)
|
||||
text_r_l = tkinter.Text(r_frame,height=1,width=10)
|
||||
|
@ -142,7 +152,7 @@ class renderedImageZoom:
|
|||
text_r_u.pack(side=tkinter.LEFT)
|
||||
average_r_label.pack(side=tkinter.RIGHT)
|
||||
submit_r_button.pack(side=tkinter.RIGHT)
|
||||
r_frame.grid(column=0,row=10,columnspan=2,padx=20)
|
||||
r_frame.grid(column=0,row=11,columnspan=2,padx=20)
|
||||
|
||||
|
||||
b_frame = tkinter.Frame(self.aerosol_window)
|
||||
|
@ -155,7 +165,7 @@ class renderedImageZoom:
|
|||
text_b_u.pack(side=tkinter.LEFT)
|
||||
average_b_label.pack(side=tkinter.RIGHT)
|
||||
submit_b_button.pack(side=tkinter.RIGHT)
|
||||
b_frame.grid(column=0,row=11,columnspan=2,padx=20)
|
||||
b_frame.grid(column=0,row=12,columnspan=2,padx=20)
|
||||
|
||||
#self.img = Image.fromarray(image,mode="RGB")
|
||||
#self.tk_image = ImageTk.PhotoImage(width=256,height=256,image=self.img)
|
||||
|
@ -181,6 +191,20 @@ class renderedImageZoom:
|
|||
else:
|
||||
self.temperature = int(temp)
|
||||
|
||||
|
||||
def set_sun(self,angle):
|
||||
if angle is None:
|
||||
angle_degrees:cython.int = 90 # Sun direction in degrees (0 to 90, noon to sunset)
|
||||
elif int(angle) > 90 or int(angle) < 0:
|
||||
angle_degrees:cython.int = 90 # Sun direction in degrees (0 to 90, noon to sunset)
|
||||
else:
|
||||
angle_degrees:cython.int = int(angle) # Sun direction in degrees (0 to 90, noon to sunset)
|
||||
|
||||
angle_radians:cython.double = math.radians(angle_degrees) # Convert to radians
|
||||
sunDir:skydome.Vec3 = skydome.Vec3(0, math.cos(angle_radians), -math.sin(angle_radians))
|
||||
self.sunDir = sunDir
|
||||
|
||||
|
||||
def set_press(self,press):
|
||||
if press is None:
|
||||
self.pressure = 720
|
||||
|
@ -206,7 +230,8 @@ class renderedImageZoom:
|
|||
self.g = g
|
||||
|
||||
def render(self):
|
||||
self.image = skydome.renderFromCamera(self.coords,self.betaM,self.g,self.altitude,self.temperature,self.pressure)
|
||||
#self.image = skydome.renderFromCamera(self.coords,self.betaM,self.g,self.altitude,self.temperature,self.pressure,self.sunDir)
|
||||
self.image = skydome.renderSkydome(self.coords,self.betaM,self.g,self.altitude,self.temperature,self.pressure,self.sunDir)
|
||||
self.img = Image.fromarray(self.image,mode="RGB")
|
||||
self.tk_image = ImageTk.PhotoImage(width=256,height=256,image=self.img)
|
||||
#img = ImageTk.PhotoImage(Image.open("highpress_camera.png"))
|
||||
|
|
17
skydome.py
17
skydome.py
|
@ -127,9 +127,9 @@ beta_values = beta(n_values)
|
|||
# We will have a scattering enhancement factor for our scattering values
|
||||
|
||||
kInfinity = float('inf')
|
||||
angle_degrees:cython.int = 90 # Sun direction in degrees (0 to 90, noon to sunset)
|
||||
angle_degrees:cython.int = 0 # Sun direction in degrees (0 to 90, noon to sunset)
|
||||
angle_radians:cython.double = math.radians(angle_degrees) # Convert to radians
|
||||
sunDir:Vec3 = Vec3(0, math.cos(angle_radians), -math.sin(angle_radians))
|
||||
#sunDir:Vec3 = Vec3(0, math.cos(angle_radians), -math.sin(angle_radians))
|
||||
|
||||
"""
|
||||
The values for betaR depend on many things
|
||||
|
@ -180,7 +180,7 @@ Hm:cython.int = 1200
|
|||
|
||||
# The direction will change for each pixel
|
||||
@cython.cfunc
|
||||
def computeIncidentLight(direction:Vec3,betaM,g,observerEarthRadius) -> tuple[float,float,float]:
|
||||
def computeIncidentLight(direction:Vec3,betaM,g,observerEarthRadius,sunDir) -> tuple[float,float,float]:
|
||||
tmin:cython.float=0
|
||||
tmax:cython.float=kInfinity
|
||||
|
||||
|
@ -289,7 +289,7 @@ def solveQuadratic(a:cython.float, b:cython.float, c:cython.float) -> tuple[cyth
|
|||
|
||||
|
||||
@cython.cfunc
|
||||
def renderSkydome(filename,betaM,g,altitude):
|
||||
def renderSkydome(filename,betaM,g,altitude,T,P,sunDir):
|
||||
width:cython.int
|
||||
height:cython.int
|
||||
width, height = 256,256
|
||||
|
@ -316,7 +316,7 @@ def renderSkydome(filename,betaM,g,altitude):
|
|||
theta = math.acos(1 - z2)
|
||||
# This changes for each pixel
|
||||
direction = Vec3(math.sin(theta) * math.cos(phi), math.cos(theta), math.sin(theta) * math.sin(phi))
|
||||
color = computeIncidentLight(direction,betaM,g,observerEarthRadius)
|
||||
color = computeIncidentLight(direction,betaM,g,observerEarthRadius,sunDir)
|
||||
#color = computeIncidentLight(direction)
|
||||
|
||||
|
||||
|
@ -332,11 +332,12 @@ def renderSkydome(filename,betaM,g,altitude):
|
|||
|
||||
# Save result to a PNG image
|
||||
image = np.clip(image, 0, 1) * 255 # change 255
|
||||
imageio.imwrite(filename, image.astype(np.uint8))
|
||||
return image.astype(np.uint8)
|
||||
#imageio.imwrite(filename, image.astype(np.uint8))
|
||||
|
||||
|
||||
|
||||
def renderFromCamera(filename,betaM,g,altitude,T,P):
|
||||
def renderFromCamera(filename,betaM,g,altitude,T,P,sunDir):
|
||||
|
||||
print(wavelengths)
|
||||
n_s_values, n_values = refraction_calculator(T, P)
|
||||
|
@ -374,7 +375,7 @@ def renderFromCamera(filename,betaM,g,altitude,T,P):
|
|||
|
||||
#This changes for each pixel, it is the direction we are looking in
|
||||
direction = Vec3(rayx, rayy, -1).normalize()
|
||||
color = computeIncidentLight(direction,betaM,g,observerEarthRadius)
|
||||
color = computeIncidentLight(direction,betaM,g,observerEarthRadius,sunDir)
|
||||
#image[y, x] = np.array(color)
|
||||
image[y][x] = np.clip(color, 0, 1)
|
||||
|
||||
|
|
Loading…
Reference in a new issue