Skip to content

Commit

Permalink
Added optical vignetting highlights and general exposure control
Browse files Browse the repository at this point in the history
  • Loading branch information
zpelgrims committed Feb 22, 2016
1 parent d855f60 commit 1987419
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 31 deletions.
4 changes: 4 additions & 0 deletions ae/aiZoicTemplate.py 100755 → 100644
Expand Up @@ -37,8 +37,12 @@ def setup(self):
self.addControl("aiFocalDistance", label="Focus distance (cm)")
self.addSeparator()
self.addControl("aiOpticalVignetting", label="Optical Vignetting")
self.addControl("aiHighlightWidth", label="Highlight Width")
self.addControl("aiHighlightStrength", label="Highlight Strength")
self.addSeparator()
self.addControl("aiUseImage", label="Enable Image based bokeh")
self.addCustom('aiBokehPath', self.filenameNew, self.filenameReplace)
self.addSeparator()
self.addControl("aiExposureControl", label="Exposure")

templates.registerTranslatorUI(aiZoicTemplate, "camera", "zoic")
Binary file modified ae/aiZoicTemplate.pyc
Binary file not shown.
Empty file modified bin/.nfs00000000015c2b8c0000160e 100755 → 100644
Empty file.
27 changes: 27 additions & 0 deletions bin/zoic.mtd 100755 → 100644
Expand Up @@ -60,6 +60,22 @@
default FLOAT 0
desc STRING "Sometimes referred to as the cat-eye effect, this is a lens imperfection that is not caused by the glass but by the outer edge of the lens, also known as the exit aperture. When the main aperture is fully open, light coming into the camera from steep angles will be blocked partially by the edge of the lens. This creates cat-eye like bokeh shapes near the edges of an image. It should be noted that this lens effect is purely mechanical and can not be confused with lens distortion."

[attr highlightWidth]
maya.name STRING "aiHighlightWidth"
min FLOAT 0.0
softmax FLOAT 0.2
max FLOAT 1.0
default FLOAT 0.0
desc STRING "Width of the highlight on the inner side of the bokeh in relationship to the origin in image space. This is a percentage of the lens radius."

[attr highlightStrength]
maya.name STRING "aiHighlightStrength"
min FLOAT 0.0
softmax FLOAT 20.0
max FLOAT 100.0
default FLOAT 0.0
desc STRING "Strength of the highlight on the inner side of the bokeh in relationship to the origin in image space. This is a multiplier on the weight of the rays."

[attr useImage]
maya.name STRING "aiUseImage"
default BOOL false
Expand All @@ -69,3 +85,14 @@
maya.name STRING "aiBokehPath"
default STRING ""
desc STRING "Path to bokeh image. No need to convert to .tx"


[attr exposureControl]
maya.name STRING "aiExposureControl"
min FLOAT -100.0
softmin FLOAT -5.0
softmax FLOAT 5.0
max FLOAT 100.0
default FLOAT 0.0
desc STRING "Multiplier on the ray weight."

Binary file modified bin/zoic.so 100755 → 100644
Binary file not shown.
Empty file modified src/arnoldCamera.pro 100755 → 100644
Empty file.
Empty file modified src/arnoldCamera.pro.user 100755 → 100644
Empty file.
Empty file modified src/imageReader.cpp 100755 → 100644
Empty file.
12 changes: 6 additions & 6 deletions src/imgs/wip/testScene_lights.ass
@@ -1,12 +1,12 @@
### exported: Sun Feb 21 14:14:25 2016
### exported: Mon Feb 22 13:20:38 2016
### from: Arnold 4.2.11.0 linux clang-3.6.0 glibc-2.12 oiio-1.5.20 rlm-11.3.1 2015/10/27 15:51:25
### host app: MtoA 1.2.4.3 Maya 2016



options
{
AA_samples 20
AA_samples 10
outputs "RGBA RGBA defaultArnoldFilter@gaussian_filter defaultArnoldDriver@driver_exr.RGBA"
xres 960
yres 350
Expand All @@ -33,7 +33,7 @@ options
fps 24
}

zenoCamera
zoic
{
name perspShape
sensorWidth 3.5999999
Expand All @@ -42,9 +42,9 @@ zenoCamera
useDof on
fStop 1.39999998
focalDistance 115
opticalVignetting 3.80952382
useImage on
bokehPath "/home/i7210038/qt_arnoldCamera/arnoldCamera/imgs/collected_real/bokeh_31.jpg"
opticalVignetting 8
useImage off
bokehPath "/home/i7210038/qt_arnoldCamera/arnoldCamera/imgs/collected_real/bokeh_18.jpg"
matrix
0.312334925 0 -0.949972034 0
0.153605282 -0.986840844 0.0505028479 0
Expand Down
Binary file added src/imgs/wip/testScene_lights.exr
Binary file not shown.
Empty file modified src/releases/zoic_linux_v1.0/ae/aiZoicTemplate.py 100755 → 100644
Empty file.
Empty file modified src/releases/zoic_linux_v1.0/bin/.nfs00000000015c2b8c0000160e 100755 → 100644
Empty file.
Empty file modified src/releases/zoic_linux_v1.0/bin/zoic.mtd 100755 → 100644
Empty file.
Empty file modified src/releases/zoic_linux_v1.0/bin/zoic.so 100755 → 100644
Empty file.
Empty file modified src/testScene_lights.ma 100755 → 100644
Empty file.
48 changes: 23 additions & 25 deletions src/zoic.cpp 100755 → 100644
Expand Up @@ -59,13 +59,6 @@
*/

/* CATEYE IDEA
Cateye effect gives the inner edges of the spheres a brighter rim, so give more weight to the samples on the opposite corner of the screen.
I think I can easily do this by scaling the weight of the samples based on the relationship between the screen space coordinates.
*/

/* TODO
Make a standard for this optical vignetting thing, not just random values
Expand Down Expand Up @@ -102,8 +95,11 @@ bool debug = false;
#define _fStop (params[4].FLT)
#define _focalDistance (params[5].FLT)
#define _opticalVignetting (params[6].FLT)
#define _useImage (params[7].BOOL)
#define _bokehPath (params[8].STR)
#define _highlightWidth (params[7].FLT)
#define _highlightStrength (params[8].FLT)
#define _useImage (params[9].BOOL)
#define _bokehPath (params[10].STR)
#define _exposureControl (params[11].FLT)


struct imageData{
Expand Down Expand Up @@ -594,9 +590,12 @@ node_parameters {
AiParameterBOOL("useDof", true);
AiParameterFLT("fStop", 1.4f);
AiParameterFLT("focalDistance", 110.0f); // distance from lens to focal point
AiParameterFLT("opticalVignetting", 0.0f); //distance of the opticalVignetting virtual aperture
AiParameterBOOL("useImage", true);
AiParameterFLT("opticalVignetting", 20.0f); //distance of the opticalVignetting virtual aperture
AiParameterFLT("highlightWidth", 0.2f);
AiParameterFLT("highlightStrength", 10.0f);
AiParameterBOOL("useImage", false);
AiParameterStr("bokehPath", ""); //bokeh shape image location
AiParameterFLT("exposureControl", 0.0f);
}


Expand Down Expand Up @@ -694,29 +693,28 @@ camera_create_ray {
// find hypotenuse of x, y points.
float pointHypotenuse = sqrt((opticalVignetPoint.x * opticalVignetPoint.x) + (opticalVignetPoint.y * opticalVignetPoint.y));

float opticalVignetApertureRadius = camera.apertureRadius * 1.0f;

// if intersection point on the optical vignetting virtual aperture is within the radius of the aperture from the plane origin, kill ray
if (ABS(pointHypotenuse) > opticalVignetApertureRadius){
if (ABS(pointHypotenuse) > camera.apertureRadius){
// set ray weight to 0, there is an optimisation inside Arnold that doesn't send rays if they will return black anyway.
output->weight = 0.0f;
}

// testing cateye technique, adding weight to opposite edges to get nice rim on the highlights, this will need to be more complicated
//if (input->sy < 0){
// output->weight *= 1 + (input->sx * output->origin.x + input->sy * output->origin.y) / 2;
//}
//else{
// output->weight *= 1 + (input->sx * output->origin.x - input->sy * output->origin.y) / 2;
//}
// inner highlight,if point is within domain between lens radius and new inner radius (defined by the width)
// adding weight to opposite edges to get nice rim on the highlights
else if (ABS(pointHypotenuse) < camera.apertureRadius && ABS(pointHypotenuse) > (camera.apertureRadius - _highlightWidth)){
output->weight *= _highlightStrength * (1 - (camera.apertureRadius - ABS(pointHypotenuse))) * sqrt(input->sx * input->sx + input->sy * input->sy);
}
}
}


// vignetting
// float dist2 = input->sx * input->sx + input->sy * input->sy;
// output->weight = 1.0f - .5*dist2;

// control to go light stops up and down
if (_exposureControl > 0){
output->weight *= 1.0 + (_exposureControl * _exposureControl);
}
else if (_exposureControl < 0){
output->weight *= 1.0 / (1.0 + (-_exposureControl * -_exposureControl));
}

// not sure if needed, but can't hurt. Taken from solidangle website.
// ----------------------------------------------------------------------------------------------
Expand Down
Binary file modified src/zoic.os
Binary file not shown.

0 comments on commit 1987419

Please sign in to comment.