[colobot] 375/390: Added shadow color setting
Didier Raboud
odyx at moszumanska.debian.org
Fri Jun 12 14:22:06 UTC 2015
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch upstream/latest
in repository colobot.
commit 08bf066f78a30902603418b3616f80da756152c4
Author: Tomasz Kapuściński <tomaszkax86 at gmail.com>
Date: Wed May 27 21:58:32 2015 +0200
Added shadow color setting
---
src/graphics/core/device.h | 3 +++
src/graphics/core/nulldevice.cpp | 4 ++++
src/graphics/core/nulldevice.h | 2 ++
src/graphics/opengl/gl33device.cpp | 15 +++++++++++++++
src/graphics/opengl/gl33device.h | 5 +++++
src/graphics/opengl/gldevice.cpp | 5 +++++
src/graphics/opengl/gldevice.h | 2 ++
.../opengl/shaders/fragment_shader_33_perpixel.glsl | 4 +++-
.../opengl/shaders/fragment_shader_33_pervertex.glsl | 4 +++-
9 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h
index f99127a..a7d10b5 100644
--- a/src/graphics/core/device.h
+++ b/src/graphics/core/device.h
@@ -387,6 +387,9 @@ public:
//! Sets the shade model
virtual void SetShadeModel(ShadeModel model) = 0;
+ //! Sets shadow color
+ virtual void SetShadowColor(float value) = 0;
+
//! Sets the current fill mode
virtual void SetFillMode(FillMode mode) = 0;
diff --git a/src/graphics/core/nulldevice.cpp b/src/graphics/core/nulldevice.cpp
index acac78d..3fe45a0 100644
--- a/src/graphics/core/nulldevice.cpp
+++ b/src/graphics/core/nulldevice.cpp
@@ -342,6 +342,10 @@ ShadeModel CNullDevice::GetShadeModel()
return SHADE_FLAT;
}
+void CNullDevice::SetShadowColor(float value)
+{
+}
+
void CNullDevice::SetFillMode(FillMode mode)
{
}
diff --git a/src/graphics/core/nulldevice.h b/src/graphics/core/nulldevice.h
index 07abf3a..583747d 100644
--- a/src/graphics/core/nulldevice.h
+++ b/src/graphics/core/nulldevice.h
@@ -134,6 +134,8 @@ public:
virtual void SetShadeModel(ShadeModel model);
virtual ShadeModel GetShadeModel();
+
+ virtual void SetShadowColor(float value);
virtual void SetFillMode(FillMode mode) ;
virtual FillMode GetFillMode();
diff --git a/src/graphics/opengl/gl33device.cpp b/src/graphics/opengl/gl33device.cpp
index 8930423..da05c0b 100644
--- a/src/graphics/opengl/gl33device.cpp
+++ b/src/graphics/opengl/gl33device.cpp
@@ -390,6 +390,8 @@ bool CGL33Device::Create()
uni_AlphaTestEnabled = glGetUniformLocation(m_shaderProgram, "uni_AlphaTestEnabled");
uni_AlphaReference = glGetUniformLocation(m_shaderProgram, "uni_AlphaReference");
+ uni_ShadowColor = glGetUniformLocation(m_shaderProgram, "uni_ShadowColor");
+
uni_SmoothShading = glGetUniformLocation(m_shaderProgram, "uni_SmoothShading");
uni_LightingEnabled = glGetUniformLocation(m_shaderProgram, "uni_LightingEnabled");
@@ -445,6 +447,8 @@ bool CGL33Device::Create()
glUniform2f(uni_FogRange, 100.0f, 200.0f);
glUniform4f(uni_FogColor, 0.8f, 0.8f, 0.8f, 1.0f);
+ glUniform1f(uni_ShadowColor, 0.5f);
+
glUniform1i(uni_AlphaTestEnabled, 0);
glUniform1f(uni_AlphaReference, 1.0f);
@@ -1244,6 +1248,7 @@ void CGL33Device::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int
}
else
{
+ CLogger::GetInstance().Debug("Resizing dynamic buffer: %d->%d\n", info.size, size);
glBufferData(GL_ARRAY_BUFFER, size, vs, GL_STREAM_DRAW);
info.size = size;
@@ -1295,6 +1300,7 @@ void CGL33Device::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices,
}
else
{
+ CLogger::GetInstance().Debug("Resizing dynamic buffer: %d->%d\n", info.size, size);
glBufferData(GL_ARRAY_BUFFER, size, vs, GL_STREAM_DRAW);
info.size = size;
@@ -1346,6 +1352,7 @@ void CGL33Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, i
}
else
{
+ CLogger::GetInstance().Debug("Resizing dynamic buffer: %d->%d\n", info.size, size);
glBufferData(GL_ARRAY_BUFFER, size, vs, GL_STREAM_DRAW);
info.size = size;
@@ -1537,6 +1544,7 @@ void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
if (info.size < size)
{
+ CLogger::GetInstance().Debug("Resizing static buffer: %d->%d\n", info.size, size);
glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
info.size = size;
}
@@ -1594,6 +1602,7 @@ void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
if (info.size < size)
{
+ CLogger::GetInstance().Debug("Resizing static buffer: %d->%d\n", info.size, size);
glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
info.size = size;
}
@@ -1652,6 +1661,7 @@ void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
if (info.size < size)
{
+ CLogger::GetInstance().Debug("Resizing static buffer: %d->%d\n", info.size, size);
glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
info.size = size;
}
@@ -1938,6 +1948,11 @@ void CGL33Device::SetShadeModel(ShadeModel model)
glUniform1i(uni_SmoothShading, (model == SHADE_SMOOTH ? 1 : 0));
}
+void CGL33Device::SetShadowColor(float value)
+{
+ glUniform1f(uni_ShadowColor, value);
+}
+
void CGL33Device::SetFillMode(FillMode mode)
{
if (mode == FILL_POINT) glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
diff --git a/src/graphics/opengl/gl33device.h b/src/graphics/opengl/gl33device.h
index 242c79d..2d0f8ab 100644
--- a/src/graphics/opengl/gl33device.h
+++ b/src/graphics/opengl/gl33device.h
@@ -131,6 +131,8 @@ public:
virtual void SetShadeModel(ShadeModel model) OVERRIDE;
+ virtual void SetShadowColor(float value) OVERRIDE;
+
virtual void SetFillMode(FillMode mode) OVERRIDE;
virtual void InitOffscreenBuffer(int width, int height) OVERRIDE;
@@ -272,6 +274,9 @@ private:
//! Alpha test reference value
GLint uni_AlphaReference;
+ //! Shadow color
+ GLint uni_ShadowColor;
+
// Lighting parameters
GLint uni_SmoothShading;
//! true enables lighting
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 811ae5b..f75d57e 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -1837,6 +1837,11 @@ void CGLDevice::SetShadeModel(ShadeModel model)
else assert(false);
}
+void CGLDevice::SetShadowColor(float value)
+{
+ // doesn't do anything because it can't
+}
+
void CGLDevice::SetFillMode(FillMode mode)
{
if (mode == FILL_POINT) glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index 2ffefdf..fc71d09 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -154,6 +154,8 @@ public:
virtual void SetShadeModel(ShadeModel model) OVERRIDE;
+ virtual void SetShadowColor(float value) OVERRIDE;
+
virtual void SetFillMode(FillMode mode) OVERRIDE;
virtual void InitOffscreenBuffer(int width, int height) OVERRIDE;
diff --git a/src/graphics/opengl/shaders/fragment_shader_33_perpixel.glsl b/src/graphics/opengl/shaders/fragment_shader_33_perpixel.glsl
index ee5064a..9a09532 100644
--- a/src/graphics/opengl/shaders/fragment_shader_33_perpixel.glsl
+++ b/src/graphics/opengl/shaders/fragment_shader_33_perpixel.glsl
@@ -43,6 +43,8 @@ uniform bool uni_FogEnabled;
uniform vec2 uni_FogRange;
uniform vec4 uni_FogColor;
+uniform float uni_ShadowColor;
+
uniform bool uni_AlphaTestEnabled;
uniform float uni_AlphaReference;
@@ -132,7 +134,7 @@ void main()
if (uni_ShadowTextureEnabled)
{
- color = color * (0.35f + 0.65f * texture(uni_ShadowTexture, data.ShadowCoord.xyz));
+ color = color * mix(uni_ShadowColor, 1.0f, texture(uni_ShadowTexture, data.ShadowCoord.xyz));
}
if (uni_FogEnabled)
diff --git a/src/graphics/opengl/shaders/fragment_shader_33_pervertex.glsl b/src/graphics/opengl/shaders/fragment_shader_33_pervertex.glsl
index 40d4f34..e8a8724 100644
--- a/src/graphics/opengl/shaders/fragment_shader_33_pervertex.glsl
+++ b/src/graphics/opengl/shaders/fragment_shader_33_pervertex.glsl
@@ -32,6 +32,8 @@ uniform bool uni_FogEnabled;
uniform vec2 uni_FogRange;
uniform vec4 uni_FogColor;
+uniform float uni_ShadowColor;
+
uniform bool uni_AlphaTestEnabled;
uniform float uni_AlphaReference;
@@ -63,7 +65,7 @@ void main()
if (uni_ShadowTextureEnabled)
{
- color = color * (0.35f + 0.65f * texture(uni_ShadowTexture, data.ShadowCoord.xyz));
+ color = color * mix(uni_ShadowColor, 1.0f, texture(uni_ShadowTexture, data.ShadowCoord.xyz));
}
if (uni_FogEnabled)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list