18 #include "precompiled.h"
42 : m_Decal(decal), m_IndexArray(GL_STATIC_DRAW), m_Array(GL_STATIC_DRAW), m_Simulation(simulation)
77 contextDecal.
Add(str_DECAL, str_1);
79 for (
size_t i = 0; i < decals.size(); ++i)
87 LOGERROR(L
"Terrain renderer failed to load shader effect.\n");
96 techBase =
g_Renderer.GetShaderManager().LoadEffect(
101 LOGERROR(L
"Terrain renderer failed to load shader effect (%hs)\n",
106 numPasses = techBase->GetNumPasses();
109 for (
int pass = 0; pass < numPasses; ++pass)
113 techBase->BeginPass(pass);
117 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
120 const CShaderProgramPtr& shader = isDummyShader ? dummy : techBase->GetShader(pass);
125 size_t samplersNum = samplers.size();
127 for (
size_t s = 0; s < samplersNum; ++s)
163 shader->VertexPointer(3, GL_FLOAT, stride, base + decal->
m_Position.
offset);
165 shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, stride, base + decal->
m_UV.
offset);
167 shader->AssertPointersBound();
216 for (
ssize_t j = j0; j <= j1; ++j)
218 for (
ssize_t i = i0; i <= i1; ++i)
231 *DiffuseColor = cpuLighting ? lightEnv.EvaluateTerrainDiffuseScaled(normal) : lightEnv.EvaluateTerrainDiffuseFactor(normal);
253 for (
ssize_t dj = 0; dj < j1-j0; ++dj)
255 for (
ssize_t di = 0; di < i1-i0; ++di)
260 *Index++ =
u16(((dj+0)*w+(di+0))+base);
261 *Index++ =
u16(((dj+0)*w+(di+1))+base);
262 *Index++ =
u16(((dj+1)*w+(di+0))+base);
264 *Index++ =
u16(((dj+0)*w+(di+1))+base);
265 *Index++ =
u16(((dj+1)*w+(di+1))+base);
266 *Index++ =
u16(((dj+1)*w+(di+0))+base);
270 *Index++ =
u16(((dj+0)*w+(di+0))+base);
271 *Index++ =
u16(((dj+0)*w+(di+1))+base);
272 *Index++ =
u16(((dj+1)*w+(di+1))+base);
274 *Index++ =
u16(((dj+1)*w+(di+1))+base);
275 *Index++ =
u16(((dj+1)*w+(di+0))+base);
276 *Index++ =
u16(((dj+0)*w+(di+0))+base);
void Add(CStrIntern name, CStrIntern value)
Add a name and associated value to the map of defines.
CSimulation2 * m_Simulation
const std::string & string() const
Returns as std::string.
const CMatrix3D & GetInvTransform() const
size_t length() const
Returns length of string in bytes.
VertexArrayIterator< u16 > GetIterator() const
Gets the iterator over the (only) attribute in this array, i.e. a u16.
VertexArray::Attribute m_UV
void CalcPosition(ssize_t i, ssize_t j, CVector3D &pos) const
CVector3D Transform(const CVector3D &vector) const
bool GetTriangulationDir(ssize_t i, ssize_t j) const
void AddAttribute(Attribute *attr)
shared_ptr< CShaderTechnique > CShaderTechniquePtr
VertexArray::Attribute m_Position
Class ShadowMap: Maintain the shadow map texture and perform necessary OpenGL setup, including matrix calculations.
VertexArray::Attribute m_DiffuseColor
CDecalRData(CModelDecal *decal, CSimulation2 *simulation)
const entity_id_t SYSTEM_ENTITY
Entity ID for singleton 'system' components.
Public API for simulation system.
void Update(CSimulation2 *simulation)
void CalcNormal(ssize_t i, ssize_t j, CVector3D &normal) const
virtual float GetExactWaterLevel(float x, float z)=0
Get the current water level at the given point.
void CalcVertexExtents(ssize_t &i0, ssize_t &j0, ssize_t &i1, ssize_t &j1)
Compute the terrain vertex indexes that bound the decal's projection onto the terrain.
void SetNumVertices(size_t num)
Terrain decal definition.
VertexIndexArray m_IndexArray
A simplified syntax for accessing entity components.
VertexArrayIterator< T > GetIterator() const
Represents a mapping of name strings to value strings, for use with #if and #ifdef and similar condit...
static void PrepareShader(const CShaderProgramPtr &shader, ShadowMap *shadow)
Set up all the uniforms for a shader pass.
const SamplersVector & GetSamplers() const
const CShaderUniforms & GetStaticUniforms() const
const float * FloatArray() const
std::vector< TextureSampler > SamplersVector
const CShaderDefines & GetShaderDefines(uint32_t conditionFlags) const
virtual CColor GetShadingColor() const
static void Unbind()
Unbind any currently-bound buffer, so glVertexPointer etc calls will not attempt to use it...
Class CLightEnv: description of a lighting environment - contains all the necessary parameters for re...
CStrIntern GetShaderEffect() const
static void RenderDecals(std::vector< CDecalRData * > &decals, const CShaderDefines &context, ShadowMap *shadow, bool isDummyShader=false, const CShaderProgramPtr &dummy=CShaderProgramPtr())
shared_ptr< CShaderProgram > CShaderProgramPtr
size_t GetNumVertices() const