利用者:Jwilkins/VFX/Common/Lighting
< 利用者:Jwilkins | VFX
2013年9月24日 (火) 09:04時点におけるwiki>Jwilkinsによる版 (Created page with "= Lighting = == Material == <source lang="c"> void GPU_set_basic_material_shininess(int shininess); void GPU_set_basic_material_specular(const float specular[4]); </source> ==...")
Lighting
Material
void GPU_set_basic_material_shininess(int shininess);
void GPU_set_basic_material_specular(const float specular[4]);
Lights
uniform mat3 b_NormalMatrix; // Transpose of upper 3x3 of b_ModelViewMatrix
uniform mat4 b_ModelViewMatrixInverse;
struct b_MaterialParameters {
vec4 specular; // Scm * Scli
float shininess; // Srm
};
uniform b_MaterialParameters b_FrontMaterial;
struct b_LightSourceParameters {
vec4 diffuse; // Dcli
vec4 specular; // Scli
vec4 position; // Ppli
vec3 spotDirection; // Sdli
float spotExponent; // Srli
float spotCutoff; // Crli
// (range: [0.0,90.0], 180.0)
float spotCosCutoff; // Derived: cos(Crli)
// (range: [1.0,0.0],-1.0)
float constantAttenuation; // K0
float linearAttenuation; // K1
float quadraticAttenuation; // K2
};
uniform b_LightSourceParameters b_LightSource[b_MaxLights];
uniform int b_LightCount;
typedef struct GPUbasiclight {
float position[4];
float diffuse [4];
float specular[4];
float constant_attenuation;
float linear_attenuation;
float quadratic_attenuation;
float spot_direction[3];
float spot_cutoff;
float spot_exponent;
} GPUbasiclight;
Set lights and also applies appropriate transformations on the positions and spot directions.
void GPU_set_basic_lights(int light_count, GPUbasiclight lights[]);
int GPU_get_basic_lights(GPUbasiclight lights_out[]);
Set lights without transforming position or spot_direction. Suitable for restoring a backup copy of previous light state. Keeps position and spot position from getting transformed twice.
void GPU_restore_basic_lights(int light_count, GPUbasiclight lights[]);
A white directional light shining straight down with no attenuation or spot effects. Same as the default legacy OpenGL light number 0.
extern const GPUbasiclight GPU_DEFAULT_LIGHT;