Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CppRaytracer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yoel
CppRaytracer
Commits
f5fcf0b0
Commit
f5fcf0b0
authored
4 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Added new function to gammaCorrect the whole image vector
parent
562839f7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
RayTracer/sampling/Image.cpp
+13
-1
13 additions, 1 deletion
RayTracer/sampling/Image.cpp
RayTracer/sampling/Image.h
+1
-0
1 addition, 0 deletions
RayTracer/sampling/Image.h
with
14 additions
and
1 deletion
RayTracer/sampling/Image.cpp
+
13
−
1
View file @
f5fcf0b0
...
...
@@ -35,7 +35,18 @@ void Image::setPixels(size_t threadcount, std::shared_ptr<Sampler> sampler) {
}
void
Image
::
setPixelsTask
(
int
x
,
int
y
,
std
::
shared_ptr
<
Sampler
>
sampler
)
{
setPixel
(
x
,
y
,
sampler
->
color
(
x
,
y
));
Vec3
v
=
sampler
->
color
(
x
,
y
);
setPixel
(
x
,
y
,
v
);
}
void
Image
::
gammaCorrect
(
float
gamma
)
{
// correct the whole data-array with the given gamma
std
::
transform
(
vec
.
begin
(),
vec
.
end
(),
vec
.
begin
(),
[
gamma
](
util
::
Vec3
v
)
->
util
::
Vec3
{
return
util
::
Vec3
(
std
::
powf
(
v
.
x
(),
1
/
gamma
),
std
::
powf
(
v
.
y
(),
1
/
gamma
),
std
::
powf
(
v
.
z
(),
1
/
gamma
));
});
}
Vec3
Image
::
operator
[](
const
std
::
array
<
int
,
2
>&
i
)
const
{
return
vec
[
width
*
i
[
1
]
+
i
[
0
]];
...
...
@@ -51,6 +62,7 @@ Image raytrace(size_t threadcount, const cam::CamObs& cam,
StratifiedSampler
(
sampler
,
n
))
// sampler
);
result
.
gammaCorrect
(
2.2
);
return
result
;
}
}
// namespace util
\ No newline at end of file
This diff is collapsed.
Click to expand it.
RayTracer/sampling/Image.h
+
1
−
0
View file @
f5fcf0b0
...
...
@@ -18,6 +18,7 @@ class Image {
const
int
width
;
const
int
height
;
void
gammaCorrect
(
float
gamma
);
protected:
void
setPixelsTask
(
int
x
,
int
y
,
std
::
shared_ptr
<
Sampler
>
sampler
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment