PointLights work now
This commit is contained in:
parent
1551af28cc
commit
1ed03fec3f
3 changed files with 34 additions and 13 deletions
|
|
@ -5,6 +5,9 @@ struct Light {
|
|||
int Type;
|
||||
vec2 Position;
|
||||
vec4 Color;
|
||||
|
||||
// pointStuff;
|
||||
float Power;
|
||||
};
|
||||
|
||||
in vec2 vTexture;
|
||||
|
|
@ -19,10 +22,12 @@ layout(location = 0) out vec4 color;
|
|||
vec4 GetRenderColor();
|
||||
|
||||
vec3 calcPointLight(Light light) {
|
||||
float dis = distance(FragPos, light.Position);
|
||||
float intensity = 4 / 4 * PI * pow(dis, 2);
|
||||
|
||||
return vec3(light.Color * intensity);
|
||||
vec2 diff = light.Position - FragPos;
|
||||
|
||||
float dif = light.Power / length(diff);
|
||||
float intensity = 4 * PI * dif * (dif * dif);
|
||||
|
||||
return vec3(intensity);
|
||||
}
|
||||
|
||||
vec3 calcLight() {
|
||||
|
|
@ -42,6 +47,9 @@ vec3 calcLight() {
|
|||
}
|
||||
|
||||
void main() {
|
||||
color = GetRenderColor() * Ambient;
|
||||
color += vec4(calcLight(), 1);
|
||||
vec4 render = GetRenderColor();
|
||||
|
||||
color = render * Ambient;
|
||||
|
||||
color += vec4(calcLight() * render.xyz, 1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue