COLORSPACETRANSFORMATION
transform =
COLORSPACETRANSFORMATION::NONE
;
// check if linear workflow is enabled
if
(irs.linear_workflow)
transform =
COLORSPACETRANSFORMATION::LINEAR_TO_SRGB
;
const
INITRENDERRESULT
res = shader->
InitRender
(irs);
if
(res !=
INITRENDERRESULT::OK
)
return
maxon::UnexpectedError(
MAXON_SOURCE_LOCATION
);
// sample the shader in UV space
ChannelData
channelData;
channelData.
off
= 0;
channelData.
scale
= 0;
channelData.
t
= doc->
GetTime
().
Get
();
channelData.
texflag
=
CALC_TEXINFO
(0,
CHANNEL_COLOR
);
channelData.
d
=
向量
{ 1, 1, 1 };
channelData.
n
=
向量
{ 0, 1, 0 };
channelData.
vd
=
nullptr
;
// VolumeData is nullptr
for
(
Int32
y = 0; y < height; ++y)
{
for
(
Int32
x = 0; x < width; ++x)
{
// generate UV coordinates
const
Float64
xFloat = (
Float64
)x;
const
Float64
yFloat = (
Float64
)y;
const
Float64
u = xFloat / widthFloat;
const
Float64
v = yFloat / heightFloat;
channelData.
p
.
x
= u;
channelData.
p
.
y
= v;
channelData.
p
.
z
= 0.0f;
const
向量
color = shader->
Sample
(&channelData);
const
向量
transformedColor =
TransformColor
(color, transform).
Clamp01
();
// write into the given BaseBitmap
const
Int32
r =
SAFEINT32
(transformedColor.
x
*
COLORTOINT_MULTIPLIER
);
const
Int32
g =
SAFEINT32
(transformedColor.
y
*
COLORTOINT_MULTIPLIER
);
const
Int32
b =
SAFEINT32
(transformedColor.
z
*
COLORTOINT_MULTIPLIER
);
bitmap->
SetPixel
(x, y, r, g, b);
}
}
// free shader resources
shader->
FreeRender
();
特性
The settings of
InitRenderStruct
are:
延伸阅读
Int32 texflag
[READ ONLY] The texture flags: TEX
定义:
c4d_shader.h:969
constexpr Unstrided Clamp01() const
Returns a vector that is clamped to the range [0.0 .. 1.0].
定义:
vec.h:399
Int32 SAFEINT32(Float32 x)
定义:
apibasemath.h:266
#define MAXON_SOURCE_LOCATION
定义:
memoryallocationbase.h:66
Float t
[READ ONLY] The current time in seconds.
定义:
c4d_shader.h:968
Vector p
[READ ONLY] The texture position in UVW coordinates.
定义:
c4d_shader.h:965
Float off
定义:
c4d_shader.h:971
void FreeRender(void)
Frees all resources used by this shader that were allocated by calling InitRender().
定义:
c4d_basechannel.h:110
INITRENDERRESULT InitRender(const InitRenderStruct &is)
定义:
c4d_basechannel.h:105
Float Get(void) const
定义:
c4d_basetime.h:66
BaseTime GetTime(void) const
Bool SetPixel(Int32 x, Int32 y, Int32 r, Int32 g, Int32 b)
定义:
c4d_basebitmap.h:704
Vector TransformColor(const Vector &input, COLORSPACETRANSFORMATION colortransformation)
INITRENDERRESULT
定义:
ge_prepass.h:395
Vector d
[READ ONLY] The MIP sample radius in UVW coordinates.
定义:
c4d_shader.h:967
maxon::Int32 Int32
定义:
ge_sys_math.h:58
@ LINEAR_TO_SRGB
Linear to sRGB color space transformation.
Vector n
[READ ONLY] The surface normal.
定义:
c4d_shader.h:966
Int32 CALC_TEXINFO(Int32 texflag, Int32 channel)
定义:
c4d_shader.h:52
COLORSPACETRANSFORMATION
定义:
ge_prepass.h:483
Float scale
[READ ONLY] The MIP blur offset.
定义:
c4d_shader.h:971
VolumeData * vd
[READ ONLY] The volume information, can be nullptr.
定义:
c4d_shader.h:970
Vector Sample(ChannelData *cd)
定义:
c4d_basechannel.h:123
#define CHANNEL_COLOR
The color channel of a material.
定义:
c4d_shader.h:94
@ OK
Everything is OK, there was no error.