TextureEffect: Server basics¶
A TextureEffect is a plug-in server that defines a texture output or gradient input. These can be extended to provide access to any attributes in any packets in the sample vector.
Overview¶
Effects are used when texturing. A texture evaluates to a percentage or color, and that is applied as an effect, like diffuse color or luminous amount. Some effects can also be used as gradient inputs. Each effect is implemented by a TextureEffect server, providing a way of interpreting one aspect of shading as a simple value. The value can be scalar or RGB, and it can be read from the sample vector and/or written to the sample vector.
Headers¶
- ‘’’vector (lx-vector.hpp)’’’
‘’CLxImpl_TextureEffect’’
‘’CLxUser_PacketService’’
LXsTFX_CATEGORY – the category of the effect. ‘’NOTE: needs SDK defines’’
The plug-in server class derives from CLxImpl_TextureEffect, and exports the ILxTextureEffect interface.
TextureEffect::Type()¶
The Type() method returns the base type, scalar or color, plus bits indicating whether the effect can be read, written, or used as a gradient input.
1 2 3 4 5 | unsigned int
tfx_Type () LXx_OVERRIDE
{
return LXi_TFX_SCALAR | LXf_TFX_READ | LXf_TFX_WRITE;
}
|
TextureEffect::TypeName()¶
The TypeName() method returns the type of the value, in this case a percent.
1 2 3 4 5 | const char *
tfx_TypeName () LXx_OVERRIDE
{
return LXs_TYPE_PERCENT;
}
|
TextureEffect::Get()¶
The Get() method reads packets from the sample vector, and outputs a value. Color values write to three sequential locations.
1 2 3 4 5 6 7 | LxResult
tfx_Get (
ILxUnknownID sv,
float *val,
void *item) LXx_OVERRIDE
{
LXpSampleParms *sParm = (LXpSampleParms *) packet_svc.FastPacket (sv, sParm_offset);
|
1 2 3 | val[0] = sParm->rough;
return LXe_OK;
}
|
TextureEffect::Set()¶
The Set() method does the reverse. For writable effects it takes an input value and deposits that into the sample vector.
1 2 3 4 5 6 7 | LxResult
tfx_Set (
ILxUnknownID sv,
const float *val,
void *item) LXx_OVERRIDE
{
LXpSampleParms *sParm = (LXpSampleParms *) packet_svc.FastPacket (sv, sParm_offset);
|
1 2 3 | sParm->rough = val[0];
return LXe_OK;
}
|