Merge pull request #1342 from colobot/dev-lighting-fix
Fixes lighting issues and mipmappingpyro-refactor
commit
5749fff377
|
@ -886,6 +886,8 @@ void CGL33Device::UpdateTexture(const Texture& texture, Math::IntPoint offset, I
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, offset.x, offset.y, texData.actualSurface->w, texData.actualSurface->h,
|
glTexSubImage2D(GL_TEXTURE_2D, 0, offset.x, offset.y, texData.actualSurface->w, texData.actualSurface->h,
|
||||||
texData.sourceFormat, GL_UNSIGNED_BYTE, texData.actualSurface->pixels);
|
texData.sourceFormat, GL_UNSIGNED_BYTE, texData.actualSurface->pixels);
|
||||||
|
|
||||||
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|
||||||
SDL_FreeSurface(texData.convertedSurface);
|
SDL_FreeSurface(texData.convertedSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ void main()
|
||||||
{
|
{
|
||||||
LightParams light = uni_Light[i];
|
LightParams light = uni_Light[i];
|
||||||
|
|
||||||
vec3 lightDirection = normalize(light.Position.xyz);
|
vec3 lightDirection = light.Position.xyz;
|
||||||
vec3 reflectAxis = normalize(lightDirection + camera);
|
vec3 reflectAxis = normalize(normalize(lightDirection) + camera);
|
||||||
|
|
||||||
float diffuseComponent = clamp(dot(normal, lightDirection), 0.0f, 1.0f);
|
float diffuseComponent = clamp(dot(normal, lightDirection), 0.0f, 1.0f);
|
||||||
float specularComponent = pow(clamp(dot(normal, reflectAxis), 0.0f, 1.0f), 10.0f);
|
float specularComponent = pow(clamp(dot(normal, reflectAxis), 0.0f, 1.0f), 10.0f);
|
||||||
|
|
|
@ -83,8 +83,8 @@ void main()
|
||||||
|
|
||||||
for (int i = 0; i < uni_LightCount; i++)
|
for (int i = 0; i < uni_LightCount; i++)
|
||||||
{
|
{
|
||||||
vec3 lightDirection = normalize(uni_Light[i].Position.xyz);
|
vec3 lightDirection = uni_Light[i].Position.xyz;
|
||||||
vec3 reflectAxis = normalize(lightDirection + camera);
|
vec3 reflectAxis = normalize(normalize(lightDirection) + camera);
|
||||||
|
|
||||||
ambient += uni_Light[i].Ambient;
|
ambient += uni_Light[i].Ambient;
|
||||||
diffuse += clamp(dot(normal, lightDirection), 0.0f, 1.0f)
|
diffuse += clamp(dot(normal, lightDirection), 0.0f, 1.0f)
|
||||||
|
|
Loading…
Reference in New Issue