mirror of
https://github.com/AntonioND/nitro-engine.git
synced 2025-06-18 16:45:33 -04:00
library: Support modifying shininess table
This commit is contained in:
parent
13e2fef76c
commit
17e0288486
@ -72,6 +72,20 @@ void NE_LightSetI(int index, u32 color, int x, int y, int z);
|
||||
/// @param color Color.
|
||||
void NE_LightSetColor(int index, u32 color);
|
||||
|
||||
/// Types of functions used to generate a shininess table.
|
||||
typedef enum {
|
||||
NE_SHININESS_NONE, ///< Fill table with zeroes
|
||||
NE_SHININESS_LINEAR, ///< Increase values linearly
|
||||
NE_SHININESS_QUADRATIC, ///< Increase values proportionaly to x^2
|
||||
NE_SHININESS_CUBIC, ///< Increase values proportionaly to x^3
|
||||
NE_SHININESS_QUARTIC ///< Increase values proportionaly to x^4
|
||||
} NE_ShininessFunction;
|
||||
|
||||
/// Generate and load a shininess table used for specular lighting.
|
||||
///
|
||||
/// @param function The name of the function used to generate the table.
|
||||
void NE_ShininessTableGenerate(NE_ShininessFunction function);
|
||||
|
||||
/// Begins a polygon.
|
||||
///
|
||||
/// @param mode Type of polygon to draw (GL_TRIANGLE, GL_QUAD...).
|
||||
|
@ -149,8 +149,8 @@ static void NE_Init__(void)
|
||||
MATRIX_CONTROL = GL_PROJECTION;
|
||||
MATRIX_IDENTITY = 0;
|
||||
|
||||
// The DS uses a table for shinyness..this generates a half-ass one
|
||||
glMaterialShinyness();
|
||||
// Shininess table used for specular lighting
|
||||
NE_ShininessTableGenerate(NE_SHININESS_CUBIC);
|
||||
|
||||
// setup default material properties
|
||||
NE_MaterialSetDefaultPropierties(RGB15(20, 20, 20), RGB15(16, 16, 16),
|
||||
|
@ -37,6 +37,56 @@ void NE_LightSetI(int index, u32 color, int x, int y, int z)
|
||||
GFX_LIGHT_COLOR = ((index & 3) << 30) | color;
|
||||
}
|
||||
|
||||
void NE_ShininessTableGenerate(NE_ShininessFunction function)
|
||||
{
|
||||
uint32_t table[128 / 4];
|
||||
uint8_t *bytes = (uint8_t *)table;
|
||||
|
||||
if (function == NE_SHININESS_LINEAR)
|
||||
{
|
||||
for (int i = 0; i < 128; i++)
|
||||
bytes[i] = i * 2;
|
||||
//bytes[i] = 128 - i;
|
||||
}
|
||||
else if (function == NE_SHININESS_QUADRATIC)
|
||||
{
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
int v = i * i;
|
||||
int div = 128;
|
||||
bytes[i] = v * 2 / div;
|
||||
}
|
||||
}
|
||||
else if (function == NE_SHININESS_CUBIC)
|
||||
{
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
int v = i * i * i;
|
||||
int div = 128 * 128;
|
||||
bytes[i] = v * 2 / div;
|
||||
}
|
||||
}
|
||||
else if (function == NE_SHININESS_QUARTIC)
|
||||
{
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
int v = i * i * i * i;
|
||||
int div = 128 * 128 * 128;
|
||||
bytes[i] = v * 2 / div;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 128 / 4; i++)
|
||||
GFX_SHININESS = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 128 / 4; i++)
|
||||
GFX_SHININESS = table[i];
|
||||
}
|
||||
|
||||
void NE_PolyBegin(int mode)
|
||||
{
|
||||
GFX_BEGIN = mode;
|
||||
|
Loading…
Reference in New Issue
Block a user