6 #include "PackedDiffuseShader.h"
8 #include "GlobalLighting.h"
9 #include "GlobalFogging.h"
10 #include "IDiffuseMaterial.h"
11 #include "LightmappedPackedDiffuseTransitionShader.h"
12 #include "LightmappedRenderable.h"
13 #include "TextureMinifyType.h"
14 #include "VectorMath.h"
15 #include "GLHelpers.h"
16 #include "IAsyncTexture.h"
29 const TMaterialId materialId,
30 const std::string& name,
36 Rendering::TextureMinifyType textureMinifyType,
37 bool useAlternativeAmbient,
43 , m_lighting(lighting)
45 , m_fromTextureId(&fromTextureId)
46 , m_toTextureId(&toTextureId)
47 , m_textureMinifyType(textureMinifyType)
48 , m_useAlternativeAmbient(useAlternativeAmbient)
49 , m_textureRepeat(textureRepeat)
58 bool IsUsingAlternativeAmbient()
const {
return m_useAlternativeAmbient; }
59 void UseAlternativeAmbient(
bool useAlternativeAmbient) { m_useAlternativeAmbient = useAlternativeAmbient; }
61 const TMaterialId GetId()
const {
return m_id; }
62 const Shader& GetShader()
const {
return m_shader; }
63 const std::string& GetName()
const {
return m_name; }
71 void SetLerpParam(
float t) { m_lerpParam = t; }
72 float GetLerpParam()
const {
return m_lerpParam; }
76 m_shader.Use(glState);
78 glState.Blend.Disable();
79 glState.DepthTest.Enable();
81 const Eegeo::m44 &lightColors = m_lighting.GetColors(m_useAlternativeAmbient);
82 m_shader.SetLightColors(lightColors);
83 m_shader.SetLightmapColour(m_lighting.GetNightLightmapColour());
84 m_shader.SetLightmapIntensity(m_lighting.GetNightGlowLightmapIntensity());
85 v4 ambientColorRow = lightColors.GetRow(3);
88 m_fogging.GetUniformValues(fogValues);
89 m_shader.SetFogUniforms(fogValues);
91 m_shader.SetAmbientColor(
v3(ambientColorRow.GetX(), ambientColorRow.GetY(), ambientColorRow.GetZ()));
92 m_shader.SetLerpParam(m_lerpParam);
94 Helpers::GLHelpers::BindTexture2D(glState, m_shader.GetFromDiffuseSamplerId(), m_fromTextureId->GetTextureInfo().textureId, m_textureMinifyType, m_textureRepeat);
95 Helpers::GLHelpers::BindTexture2D(glState, m_shader.GetToDiffuseSamplerId(), m_toTextureId->GetTextureInfo().textureId, m_textureMinifyType, m_textureRepeat);
101 BindLightmapTexture(glState, lightmappedRenderable->GetLightmapTextureId());
102 m_shader.SetMVP(lightmappedRenderable->GetModelViewProjection());
103 m_shader.SetUVBounds(lightmappedRenderable->GetUVBoundsMin(), lightmappedRenderable->GetUVBoundsMax());
104 m_shader.SetPositionBounds(lightmappedRenderable->GetPositionBoundsMin(), lightmappedRenderable->GetPositionBoundsMax());
105 m_shader.SetCameraRelativeOrigin(lightmappedRenderable->GetCameraRelativeModelOrigin());
111 Helpers::GLHelpers::BindTexture2D(glState, m_shader.GetLightmapSamplerId(), lightmapId, Rendering::TextureMinify_Nearest,
false);
114 const TMaterialId m_id;
115 const std::string m_name;
121 Rendering::TextureMinifyType m_textureMinifyType;
122 bool m_useAlternativeAmbient;
123 bool m_textureRepeat;