67 #ifndef _graphicsproceduralnormalsmodifier_cpp
68 #define _graphicsproceduralnormalsmodifier_cpp
70 #include "Graphics/Procedural/Texture/normalsmodifier.h"
72 #include "MathTools/mathtools.h"
97 for(
Whole Y = 0 ; Y < Height ; ++Y )
99 for(
Whole X = 0 ; X < Width ; ++X )
101 Whole XPrev = (X < 1) ? 0 : (X - 1) % Width;
102 Whole XNext = (X + 1) % Width;
103 Whole YPrev = (Y < 1) ? 0 : (Y - 1) % Height;
104 Whole YNext = (Y + 1) % Height;
108 Real dY = fPix * -1.0f;
122 Real dX = fPix * -1.0f;
134 Real NormX = -dX * fAmp / 255.0f;
135 Real NormY = -dY * fAmp / 255.0f;
136 Real Norm = MathTools::Sqrt(NormX * NormX + NormY * NormY + 1.0f);
137 if( Norm > (
Real)10e-6 ) {
142 NormX = (NormX * Norm) * 127.0f + 128.0f;
143 NormY = (NormY * Norm) * 127.0f + 128.0f;
144 Real NormZ = Norm * 127.0f + 128.0f;
147 static_cast<UInt8>( NormX ),
148 static_cast<UInt8>( NormY ),
149 static_cast<UInt8>( NormZ ),
158 {
return "NormalsModifier"; }
164 { this->
Amplify = Amp;
return *
this; }
virtual ~NormalsModifier()
Class destructor.
void SetPixelByte(const Whole X, const Whole Y, const ColourChannelType Red, const ColourChannelType Green, const ColourChannelType Blue, const ColourChannelType Alpha=255)
Set colour of a specified pixel using a 0-255 range. the X or Y location go beyond the set size of th...
Whole GetWidth() const
Get the pixel width of this texture.
A modifier that will convery a greyscale image into a normals map.
uint8_t UInt8
An 8-bit unsigned integer.
ColourChannelType GetAlphaByte(const Whole X, const Whole Y) const
Gets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
float Real
A Datatype used to represent a real floating point number.
virtual String GetName() const
Gets the name of this modifier.
NormalsModifier()
Blank constructor.
A convenience buffer that stores pixel colour values of a texture to be generated.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Whole GetHeight() const
Get the pixel height of this texture.
virtual void Modify(TextureBuffer &Buffer)
Alters the generated pixels in a TextureBuffer.
NormalsModifier & SetAmplify(const UInt8 Amp)
Unknown.
std::string String
A datatype used to a series of characters.
void SetData(const TextureBuffer &Other)
Copies image data from another buffer into this buffer.
ColourChannelType GetRedByte(const Whole X, const Whole Y) const
Gets the red colour value of a specified pixel. the X or Y location go beyond the set size of this te...