Skip to content

Commit b6c3edf

Browse files
authored
Merge pull request #687 from CodeFHD/for_v2.11
Various fixes to BiDir, light tracing, and orthographic camera
2 parents d23e5c1 + c7de075 commit b6c3edf

File tree

16 files changed

+161
-32
lines changed

16 files changed

+161
-32
lines changed

include/slg/bsdf/bsdf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class BSDF {
128128

129129
luxrays::Spectrum GetPassThroughTransparency(const bool backTracing) const;
130130
const luxrays::Spectrum &GetPassThroughShadowTransparency() const { return material->GetPassThroughShadowTransparency(); }
131+
const bool &GetPassThroughShadowTransparencyOverride() const { return material->GetPassThroughShadowTransparencyOverride(); }
131132
const luxrays::Frame &GetFrame() const { return frame; }
132133

133134
luxrays::Spectrum Albedo() const;

include/slg/cameras/camera.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class Camera {
9696
float *filmX, float *filmY) const = 0;
9797
virtual bool GetSamplePosition(const luxrays::Point &p,
9898
float *filmX, float *filmY) const;
99+
virtual bool ProjectToImage(luxrays::Ray *ray, float *filmX, float *filmY) const;
99100
virtual bool SampleLens(const float time, const float u1, const float u2,
100101
luxrays::Point *lensPoint) const = 0;
101102
virtual void GetPDF(const luxrays::Ray &eyeRay, const float eyeDistance,

include/slg/cameras/orthographic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class OrthographicCamera : public ProjectiveCamera {
3434
virtual ~OrthographicCamera() { }
3535

3636
virtual void ClampRay(luxrays::Ray *ray) const;
37+
virtual bool ProjectToImage(luxrays::Ray *ray, float *filmX, float *filmY) const;
3738
virtual bool GetSamplePosition(luxrays::Ray *eyeRay, float *filmX, float *filmY) const;
3839
virtual bool LocalSampleLens(const float time, const float u1, const float u2,
3940
luxrays::Point *lensPoint) const;

include/slg/engines/bidircpu/bidircpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class BiDirCPURenderThread : public CPUNoTileRenderThread {
9797
const luxrays::Point &lensPoint, std::vector<SampleResult> &sampleResults) const;
9898

9999
bool TraceLightPath(const float time,
100-
Sampler *sampler, const luxrays::Point &lensPoint,
100+
Sampler *sampler, Camera *camera,
101101
std::vector<PathVertexVM> &lightPathVertices,
102102
std::vector<SampleResult> &sampleResults) const;
103103
bool Bounce(const float time, Sampler *sampler, const u_int sampleOffset,

include/slg/engines/pathocl/pathocl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,9 @@ class PathOCLRenderEngine : public PathOCLBaseRenderEngine {
112112
void UpdateTaskCount();
113113

114114
u_int GetTotalEyeSPP() const;
115-
115+
116116
FilmSampleSplatter *lightSampleSplatter;
117117
SamplerSharedData *eyeSamplerSharedData;
118-
SamplerSharedData *lightSamplerSharedData;
119118

120119
bool hasStartFilm, allRenderingThreadsStarted;
121120
};

include/slg/engines/pathoclbase/pathoclbase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class PathOCLBaseRenderEngine : public OCLRenderEngine {
9898
slg::ocl::Sampler *oclSampler;
9999
slg::ocl::Filter *oclPixelFilter;
100100
PhotonGICache *photonGICache;
101+
102+
SamplerSharedData *lightSamplerSharedData;
101103
};
102104

103105
}

include/slg/materials/material.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class Material : public luxrays::NamedObject {
123123

124124
void SetPassThroughShadowTransparency(const luxrays::Spectrum &t) { passThroughShadowTransparency = t; }
125125
const luxrays::Spectrum &GetPassThroughShadowTransparency() const { return passThroughShadowTransparency; }
126+
void SetPassThroughShadowTransparencyOverride(const bool &o) { passThroughShadowTransparencyOverride = o; }
127+
const bool &GetPassThroughShadowTransparencyOverride() const { return passThroughShadowTransparencyOverride; }
126128

127129
virtual luxrays::Spectrum GetEmittedRadiance(const HitPoint &hitPoint,
128130
const float oneOverPrimitiveArea) const;
@@ -225,6 +227,7 @@ class Material : public luxrays::NamedObject {
225227
const Texture *frontTransparencyTex;
226228
const Texture *backTransparencyTex;
227229
luxrays::Spectrum passThroughShadowTransparency;
230+
bool passThroughShadowTransparencyOverride;
228231
const Texture *emittedTex;
229232
const Texture *bumpTex;
230233
float bumpSampleDistance;

include/slg/utils/pathvolumeinfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class PathVolumeInfo {
5050

5151
void AddVolume(const Volume *vol);
5252
void RemoveVolume(const Volume *vol);
53+
void SetCurrentVolume(const Volume *vol) { currentVolume = vol; }
5354

5455
const Volume *SimulateRemoveVolume(const Volume *vol) const;
5556
const Volume *SimulateAddVolume(const Volume *vol) const;

src/slg/cameras/camera.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ bool Camera::GetSamplePosition(const luxrays::Point &p,
5353
return GetSamplePosition(&eyeRay, filmX, filmY);
5454
}
5555

56+
bool Camera::ProjectToImage(luxrays::Ray *ray, float *filmX, float *filmY) const{
57+
// Intended only for implementation in OrthographicCamera
58+
return false;
59+
}
60+
5661
void Camera::Update(const u_int width, const u_int height, const u_int *subRegion) {
5762
filmWidth = width;
5863
filmHeight = height;

src/slg/cameras/orthographic.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,44 @@ void OrthographicCamera::ClampRay(Ray *ray) const {
7575
ray->maxt = Min(ray->maxt, clipYon);
7676
}
7777

78+
bool OrthographicCamera::ProjectToImage(Ray *ray, float *x, float *y) const {
79+
// check if point is behind camera
80+
const float cosi = Dot(ray->d, dir);
81+
82+
if ((cosi <= 0.f) || (!isinf(ray->maxt) && (ray->maxt < clipHither ||
83+
ray->maxt > clipYon)))
84+
return false;
85+
86+
// Get coordinates of point in image plane
87+
Point pO = Inverse(camTrans.rasterToWorld) * ray->o;
88+
if (motionSystem)
89+
pO *= motionSystem->Sample(ray->time);
90+
91+
*x = pO.x;
92+
*y = filmHeight - 1 - pO.y;
93+
94+
// Update the ray origin
95+
pO.z = 0.f;
96+
ray->o = camTrans.rasterToWorld * pO;
97+
98+
// Check if we are inside the image plane
99+
if ((*x < filmSubRegion[0]) || (*x >= filmSubRegion[1] + 1) ||
100+
(*y < filmSubRegion[2]) || (*y >= filmSubRegion[3] + 1))
101+
return false;
102+
else {
103+
// World arbitrary clipping plane support
104+
if (enableClippingPlane) {
105+
// Check if the ray end point is on the not visible side of the plane
106+
if (Dot(clippingPlaneNormal, ray->o - clippingPlaneCenter) <= 0.f)
107+
return false;
108+
// Update ray mint/maxt
109+
ApplyArbitraryClippingPlane(ray);
110+
}
111+
112+
return true;
113+
}
114+
}
115+
78116
bool OrthographicCamera::GetSamplePosition(Ray *ray, float *x, float *y) const {
79117
const float cosi = Dot(ray->d, dir);
80118

0 commit comments

Comments
 (0)