Skip to content

Commit

Permalink
Add a bit of ambient to the sectorview spheres
Browse files Browse the repository at this point in the history
  • Loading branch information
kko committed Feb 3, 2014
1 parent 43ba6eb commit 42568d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion data/shaders/gl2/billboard_sphereimpostor.frag
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ varying vec4 color;
varying vec2 uv;
varying vec3 lightDir;

uniform Scene scene;

void main(void)
{
float len = dot(uv, uv);
if (len > 1.0)
discard;
vec3 normal = vec3(uv.x, uv.y, sqrt(1.0 - len));
float diff = dot(normal, lightDir);
gl_FragColor = color * diff;
gl_FragColor = color * diff + scene.ambient;
SetFragDepth();
}
1 change: 1 addition & 0 deletions src/SectorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ void SectorView::Draw3D()
m_renderer->SetTransform(matrix4x4f::Identity());

//draw star billboards in one go
m_renderer->SetAmbientColor(Color(30));
m_renderer->DrawTriangles(m_starVerts.get(), m_solidState, m_starMaterial.Get());

//draw sector legs in one go
Expand Down
5 changes: 5 additions & 0 deletions src/graphics/gl2/SphereImpostorMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace Graphics {
Program *CreateProgram(const MaterialDescriptor &) {
return new Program("billboard_sphereimpostor", "");
}

virtual void Apply() override {
GL2::Material::Apply();
m_program->sceneAmbient.Set(m_renderer->GetAmbientColor());
}
};
}
}
Expand Down

0 comments on commit 42568d6

Please sign in to comment.