Skip to content

Commit

Permalink
done crop feature
Browse files Browse the repository at this point in the history
  • Loading branch information
SAM-tak committed Jul 24, 2022
1 parent b7a8c6e commit 1c5f0a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions VRRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
pt.x = cos(elevation) * sin(azimuth);
pt.y = sin(elevation);
pt.z = cos(elevation) * cos(azimuth);
if(abs(pt.y) > VCLIP) discard;
'''

fetch_setup = '''
Expand All @@ -134,29 +133,34 @@
float tob = (1.0 - lor) * step(abs(pt.z), abs(pt.y));
// front or back
float fob = (1.0 - lor) * (1.0 - tob);
float right = step(0.0, pt.x);
float up = step(0.0, pt.y);
float front = step(0.0, pt.z);
float angle = 0.0;
angle = fob * abs(pt.y/pt.z) * 0.5;
angle += lor * abs(pt.y/pt.x) * 0.5;
angle += tob * (2 - abs(pt.z/pt.y)) * 0.5;
if(angle > VCLIP) discard;
'''

fetch_sides = '''
float right = step(0.0, pt.x);
fragColor += lor * right * texture(cubeRightImage, to_uv_right(pt));
fragColor += lor * (1.0 - right) * texture(cubeLeftImage, to_uv_left(pt));
'''

fetch_top_bottom = '''
float up = step(0.0, pt.y);
fragColor += tob * up * texture(cubeTopImage, to_uv_top(pt));
fragColor += tob * (1.0 - up) * texture(cubeBottomImage, to_uv_bottom(pt));
'''

fetch_front_back = '''
float front = step(0.0, pt.z);
fragColor += fob * front * texture(cubeFrontImage, to_uv_front(pt));
fragColor += fob * (1.0 - front) * texture(cubeBackImage, to_uv_back(pt));
}
'''

fetch_front_only = '''
fragColor += fob * step(0.0, pt.z) * texture(cubeFrontImage, to_uv_front(pt));
fragColor += fob * front * texture(cubeFrontImage, to_uv_front(pt));
}
'''

Expand Down Expand Up @@ -312,6 +316,7 @@ def cubemap_to_panorama(self, imageList, outputName):
offscreen = gpu.types.GPUOffScreen(width, height)

with offscreen.bind():
bgl.glClearColor(0.0, 0.0, 0.0, 1.0)
bgl.glClear(bgl.GL_COLOR_BUFFER_BIT)

shader.bind()
Expand Down Expand Up @@ -432,8 +437,8 @@ def clean_up(self, context):
if self.is_stereo:
self.scene.render.image_settings.views_format = self.view_format
self.scene.render.image_settings.stereo_3d_format.display_mode = self.stereo_mode
# for filename in self.createdFiles:
# os.remove(filename)
for filename in self.createdFiles:
os.remove(filename)
self.createdFiles.clear()


Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def draw(self, context):
else:
col.prop(props, 'equi360HFOV')
col.prop(props, 'equiVFOV')
col.prop(props, 'stitchMargin')
# col.prop(props, 'stitchMargin')
layout.separator()
col = layout.column()
col.operator(RenderImage.bl_idname, text="Render Image")
Expand Down

0 comments on commit 1c5f0a9

Please sign in to comment.