Unverified Commit 756b0aa4 authored by Alister's avatar Alister Committed by GitHub
Browse files

Bugfix/maguire7/trilinear shading dev (#4547)

* Fix harshness of lighting power in Headlight

* adding gradient lighting test

* adding baselines

* cleanup

* cleanup: inconsistent spacing and lines > 80 char

* updating release notes
parent f5367506
......@@ -36,6 +36,7 @@ avtPhong::avtPhong(double gmax, double lpow)
: gradMax(gmax), lightingPower(lpow)
{
inv_gradMax = 1. / gmax;
inv_lightingPower = 1. / lightingPower;
}
......@@ -246,7 +247,8 @@ double dot(double v1[3], double v2[3]){
}
void avtPhong::AddLightingHeadlight(int index, const avtRay *ray, unsigned char *rgb, double alpha, double matProperties[4]) const
void avtPhong::AddLightingHeadlight(int index, const avtRay *ray,
unsigned char *rgb, double alpha, double matProperties[4]) const
{
const LightAttributes &l = lights.GetLight(0);
if (l.GetEnabledFlag()){
......@@ -300,9 +302,18 @@ void avtPhong::AddLightingHeadlight(int index, const avtRay *ray, unsigned char
if (nl < 0.0)
nl = -nl;
//
// Lighting power is too harsh if we just multiply it in. Incorporating it
// into diffuse gives a much more palatable result.
//
for (int i=0; i<3; i++)
col[i] = ( ((matProperties[0] + (matProperties[1] * nl)) * col[i]) + ((matProperties[2] * pow(nl,matProperties[3])) * alpha) ) * lightingPower;
// amb + diff + spec
{
// amb + diff + spec
double amb = matProperties[0];
double diff = pow(matProperties[1], inv_lightingPower) * nl;
double spec = matProperties[2] * pow(nl,matProperties[3]) * alpha;
col[i] = ((amb + diff) * col[i]) + spec;
}
// convert to unsignedChar
if ((col[0] * 255) > 255.0)
......
......@@ -38,6 +38,9 @@
// Added ability to reduce amount of lighting for low-gradient-mag areas.
// Default values to constructor leave the old behavior (i.e. gradmax=0).
//
// Alister Maguire, Fri Mar 20 16:02:16 PDT 2020
// Added inv_lightingPower for use in AddLightingHeadlight.
//
// ****************************************************************************
class PIPELINE_API avtPhong : public avtLightingModel
......@@ -49,10 +52,13 @@ class PIPELINE_API avtPhong : public avtLightingModel
virtual void AddLighting(int, const avtRay *, unsigned char *)
const;
virtual void AddLightingHeadlight(int, const avtRay *, unsigned char *, double alpha, double matProperties[4])
const;
virtual void AddLightingHeadlight(int, const avtRay *,
unsigned char *,
double alpha,
double matProperties[4]) const;
private:
double gradMax, inv_gradMax, lightingPower;
double inv_lightingPower;
};
......
......@@ -31,6 +31,7 @@ enhancements and bug-fixes that were added to this release.</p>
<li>Fixed ability to save a movie template via the Save Movie Wizard on Windows.</li>
<li>Fixed bugs with the avtLinesFileFormat reader. The reader can now distinguish 2D from 3D, and it will not remove identical consecutive points that exist on different lines.</li>
<li>Fixed a crash with the generation of ghost zones using global node ids where there were NULL domains.</li>
<li>Fixed a bug that caused trilinear ray casting to have very harsh lighting.</li>
</ul>
<a name="Enhancements"></a>
......
......@@ -44,6 +44,9 @@
# Alister Maguire, Wed Jun 5 11:01:31 PDT 2019
# Added opacity attenuation test.
#
# Alister Maguire, Fri Mar 20 15:36:37 PDT 2020
# Added gradient lighting reduction test.
#
# ----------------------------------------------------------------------------
def InitAnnotations():
......@@ -360,6 +363,42 @@ def TestVolumeSampling():
DeleteAllPlots()
def TestGradientLightingReduction():
view = GetView3D()
view.viewNormal = (0.746662961825451, 0.1647201021100829, 0.6444856161303283)
SetView3D(view)
OpenDatabase(silo_data_path("globe.silo"))
AddPlot("Volume", "v")
DrawPlots()
#
# Trilinear ray casting used to have very harsh results with
# gradient lighting reduction. Let's make sure they're better
# now.
#
v = VolumeAttributes()
v.lightingFlag = 1
v.rendererType = v.RayCasting
v.sampling = v.Trilinear
v.lowGradientLightingReduction = v.Lower
SetPlotOptions(v)
Test("graidentLighting_00")
v.lowGradientLightingReduction = v.Medium
SetPlotOptions(v)
Test("graidentLighting_01")
v.lowGradientLightingReduction = v.Higher
SetPlotOptions(v)
Test("graidentLighting_02")
DeleteAllPlots()
CloseDatabase(silo_data_path("globe.silo"))
#FIXME: For some reason, if you render using the ray caster,
# attempting to render using the default renderer afterwards
# will result in a blank test result. I have not been able
......@@ -375,5 +414,6 @@ InitAnnotations()
TestVolumeScaling()
TestVolumeSampling()
TestOpacityAttenuation()
TestGradientLightingReduction()
Exit()
version https://git-lfs.github.com/spec/v1
oid sha256:d9d0a77c3ed54d48a71e14a0eb44310eee419568df7bc0ba92d9bd3273d0fc9b
size 13284
version https://git-lfs.github.com/spec/v1
oid sha256:3a464c629acb1767fbcaea641402496392d8e9a77b1d20c72b152f6526472089
size 16504
version https://git-lfs.github.com/spec/v1
oid sha256:e29e1b9b2bea1df3d0492c26100bd1bf5d7864d308d2c5633caad7cdcec2aea8
size 17099
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment