Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Office
Calligra
Commits
a9784a79
Commit
a9784a79
authored
Jul 08, 2011
by
José Luis Vergara
Browse files
Remove hardcoded area assumption in Phong Bumpmap
BUG:275693
parent
d8abe220
Changes
3
Hide whitespace changes
Inline
Side-by-side
krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.cpp
View file @
a9784a79
...
...
@@ -44,7 +44,9 @@ void KisFilterPhongBumpmap::process(KisPaintDeviceSP device,
const
KisFilterConfiguration
*
config
,
KoUpdater
*
progressUpdater
)
const
{
{
if
(
!
config
)
return
;
if
(
progressUpdater
)
progressUpdater
->
setProgress
(
0
);
// Benchmark
...
...
@@ -56,9 +58,6 @@ void KisFilterPhongBumpmap::process(KisPaintDeviceSP device,
qDebug
(
"FIX YOUR FILTER"
);
return
;
}
// TODO complete this part
userChosenHeightChannel
=
"Red"
;
timer
.
start
();
...
...
@@ -88,31 +87,32 @@ void KisFilterPhongBumpmap::process(KisPaintDeviceSP device,
//Hardcoded facts about Phong Bumpmap: it _will_ generate an RGBA16 bumpmap
const
quint8
BYTE_DEPTH_OF_BUMPMAP
=
2
;
// 16 bits per channel
const
quint8
CHANNEL_COUNT_OF_BUMPMAP
=
4
;
// RGBA
const
quint32
pixelsOfInputArea
=
abs
(
inputArea
.
width
()
*
inputArea
.
height
());
const
quint32
pixelsOfOutputArea
=
abs
(
outputArea
.
width
()
*
outputArea
.
height
());
const
quint8
pixelSize
=
BYTE_DEPTH_OF_BUMPMAP
*
CHANNEL_COUNT_OF_BUMPMAP
;
const
quint32
bytesToFillBumpmapArea
=
pixelsOfOutputArea
*
pixelSize
;
QVector
<
quint8
>
bumpmap
(
bytesToFillBumpmapArea
);
quint8
*
bumpmapDataPointer
=
bumpmap
.
data
();
quint32
ki
=
m_heightChannel
->
index
();
PhongPixelProcessor
tileRenderer
(
config
);
PhongPixelProcessor
tileRenderer
(
pixelsOfInputArea
,
config
);
if
(
progressUpdater
)
progressUpdater
->
setProgress
(
2
);
//===============RENDER=================
QVector
<
PtrToDouble
>
toDoubleFuncPtr
(
device
->
colorSpace
()
->
channels
().
count
());
KisMathToolbox
*
mathToolbox
=
KisMathToolboxRegistry
::
instance
()
->
value
(
device
->
colorSpace
()
->
mathToolboxId
().
id
());
if
(
!
mathToolbox
->
getToDoubleChannelPtr
(
device
->
colorSpace
()
->
channels
(),
toDoubleFuncPtr
))
{
return
;
}
KisHLineIteratorSP
iterator
;
quint32
curPixel
=
0
;
iterator
=
device
->
createHLineIteratorNG
(
inputArea
.
x
(),
inputArea
.
y
(),
inputArea
.
width
()
);
for
(
qint32
srcRow
=
0
;
srcRow
<
inputArea
.
height
();
++
srcRow
)
{
do
{
const
quint8
*
data
=
iterator
->
rawData
();
...
...
@@ -144,7 +144,7 @@ void KisFilterPhongBumpmap::process(KisPaintDeviceSP device,
}
if
(
progressUpdater
)
progressUpdater
->
setProgress
(
90
);
KisPaintDeviceSP
bumpmapPaintDevice
=
new
KisPaintDevice
(
KoColorSpaceRegistry
::
instance
()
->
rgb16
());
bumpmapPaintDevice
->
writeBytes
(
bumpmap
.
data
(),
outputArea
.
x
(),
outputArea
.
y
(),
outputArea
.
width
(),
outputArea
.
height
());
KUndo2Command
*
leaker
=
bumpmapPaintDevice
->
convertTo
(
device
->
colorSpace
());
...
...
krita/plugins/filters/phongbumpmap/phong_pixel_processor.cpp
View file @
a9784a79
...
...
@@ -22,8 +22,9 @@
#include
<KoColorSpaceRegistry.h>
#include
<iostream>
PhongPixelProcessor
::
PhongPixelProcessor
(
const
KisPropertiesConfiguration
*
config
)
PhongPixelProcessor
::
PhongPixelProcessor
(
quint32
pixelArea
,
const
KisPropertiesConfiguration
*
config
)
{
m_pixelArea
=
pixelArea
;
initialize
(
config
);
}
...
...
@@ -87,8 +88,7 @@ void PhongPixelProcessor::initialize(const KisPropertiesConfiguration* config)
diffuseLightIsEnabled
=
config
->
getBool
(
PHONG_DIFFUSE_REFLECTIVITY_IS_ENABLED
);
specularLightIsEnabled
=
config
->
getBool
(
PHONG_SPECULAR_REFLECTIVITY_IS_ENABLED
);
//TODO BUG THIS IS HARDCODED FIX IT
realheightmap
=
QVector
<
double
>
(
300000
,
0
);
realheightmap
=
QVector
<
double
>
(
m_pixelArea
,
0
);
}
...
...
krita/plugins/filters/phongbumpmap/phong_pixel_processor.h
View file @
a9784a79
...
...
@@ -38,7 +38,7 @@ class PhongPixelProcessor
{
public:
PhongPixelProcessor
(
const
KisPropertiesConfiguration
*
config
);
PhongPixelProcessor
(
quint32
pixelArea
,
const
KisPropertiesConfiguration
*
config
);
~
PhongPixelProcessor
();
void
initialize
(
const
KisPropertiesConfiguration
*
config
);
...
...
@@ -96,6 +96,9 @@ public:
bool
diffuseLightIsEnabled
;
bool
specularLightIsEnabled
;
private:
quint32
m_pixelArea
;
};
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment