Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fadecandy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scanlime
Fadecandy
Commits
2b931bad
Commit
2b931bad
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
Fix color contrast calculations
parent
dcf1ccb8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/cpp/rings.cpp
+6
-5
6 additions, 5 deletions
examples/cpp/rings.cpp
with
6 additions
and
5 deletions
examples/cpp/rings.cpp
+
6
−
5
View file @
2b931bad
...
@@ -40,7 +40,8 @@ public:
...
@@ -40,7 +40,8 @@ public:
static
const
float
targetBrightness
=
0.1
;
static
const
float
targetBrightness
=
0.1
;
static
const
float
thresholdGain
=
0.1
;
static
const
float
thresholdGain
=
0.1
;
static
const
float
thresholdStepLimit
=
0.02
;
static
const
float
thresholdStepLimit
=
0.02
;
static
const
unsigned
octaves
=
4
;
static
const
unsigned
brightnessOctaves
=
4
;
static
const
unsigned
colorOctaves
=
2
;
// Sample colors along a curved path through a texture
// Sample colors along a curved path through a texture
Texture
palette
;
Texture
palette
;
...
@@ -119,7 +120,7 @@ public:
...
@@ -119,7 +120,7 @@ public:
float
n
=
threshold
*
brightnessContrast
;
float
n
=
threshold
*
brightnessContrast
;
float
amplitude
=
brightnessContrast
;
float
amplitude
=
brightnessContrast
;
Vec4
arg
=
s
+
pulse
;
Vec4
arg
=
s
+
pulse
;
unsigned
i
=
o
ctaves
;
unsigned
i
=
brightnessO
ctaves
;
while
(
true
)
{
while
(
true
)
{
n
+=
amplitude
*
dNoise
(
arg
);
n
+=
amplitude
*
dNoise
(
arg
);
...
@@ -137,7 +138,7 @@ public:
...
@@ -137,7 +138,7 @@ public:
amplitude
*=
0.5
f
;
amplitude
*=
0.5
f
;
arg
*=
2.0
f
;
arg
*=
2.0
f
;
}
}
n
/=
fbmTotal
(
o
ctaves
);
n
/=
fbmTotal
(
brightnessO
ctaves
);
/*
/*
* Another hybrid 2D/3D fbm for chroma. Use half the octaves.
* Another hybrid 2D/3D fbm for chroma. Use half the octaves.
...
@@ -146,7 +147,7 @@ public:
...
@@ -146,7 +147,7 @@ public:
float
m
=
0
;
float
m
=
0
;
amplitude
=
colorContrast
;
amplitude
=
colorContrast
;
arg
=
s
+
Vec4
(
0
,
0
,
0
,
10
);
arg
=
s
+
Vec4
(
0
,
0
,
0
,
10
);
i
=
o
ctaves
;
i
=
colorO
ctaves
;
while
(
true
)
{
while
(
true
)
{
m
+=
amplitude
*
dNoise
(
arg
);
m
+=
amplitude
*
dNoise
(
arg
);
...
@@ -157,7 +158,7 @@ public:
...
@@ -157,7 +158,7 @@ public:
amplitude
*=
0.5
f
;
amplitude
*=
0.5
f
;
arg
*=
2.0
f
;
arg
*=
2.0
f
;
}
}
n
/=
fbmTotal
(
o
ctaves
);
m
/=
fbmTotal
(
colorO
ctaves
);
// Assemble color using a lookup through our palette
// Assemble color using a lookup through our palette
rgb
=
color
(
colorParam
+
m
,
sq
(
n
));
rgb
=
color
(
colorParam
+
m
,
sq
(
n
));
...
...
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