Created
January 18, 2011 00:12
-
-
Save aras-p/783759 to your computer and use it in GitHub Desktop.
Lighting texture creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lr,lg,lb - light color | |
// spec = specular power | |
int idx = 0; | |
for (int y = 0; y < height; ++y) | |
{ | |
for (int x = 0; x < width; ++x, idx+=4) | |
{ | |
float vx = float(x) / width; | |
float vy = float(y) / height; | |
float nl = vx; | |
float nh = vy; | |
float s = powf (nh, spec); | |
data[idx+0] = nl * lr * 255.0f; | |
data[idx+1] = nl * lg * 255.0f; | |
data[idx+2] = nl * lb * 255.0f; | |
data[idx+3] = s * 255.0f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment