forked from Mirrors/openclonk
Blit every landscape texture separately and with higher resolution
ApplyLighting copies all values of Surface8 to Blue-Channel of Surface32, BlitLandscape loops over all textures. This enables multiple material texture pixels per landscape pixel.stable-5.2
parent
27e8c4026e
commit
806cd10f7b
|
@ -295,7 +295,12 @@ void C4Landscape::Draw(C4TargetFacet &cgo, int32_t iPlayer)
|
|||
if (Game.GraphicsSystem.ShowSolidMask)
|
||||
Application.DDraw->Blit8Fast(Surface8, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt);
|
||||
else
|
||||
Application.DDraw->BlitLandscape(Surface32, AnimationSurface, &Game.GraphicsResource.sfcLiquidAnimation, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt);
|
||||
{
|
||||
const CSurface * Surfaces[C4M_MaxTexIndex];
|
||||
for (int i = 0; i < C4M_MaxTexIndex; ++i)
|
||||
Surfaces[i] = Game.TextureMap.GetEntry(i)->getPattern().getSurface();
|
||||
Application.DDraw->BlitLandscape(Surface32, AnimationSurface, &Game.GraphicsResource.sfcLiquidAnimation, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt,Surfaces);
|
||||
}
|
||||
if (Modulation) Application.DDraw->DeactivateBlitModulation();
|
||||
}
|
||||
|
||||
|
@ -2506,6 +2511,11 @@ bool C4Landscape::ApplyLighting(C4Rect To)
|
|||
BelowDensity -= GetPlacement(iX, iY);
|
||||
BelowDensity += GetPlacement(iX, iY + 8);
|
||||
BYTE pix = _GetPix(iX, iY);
|
||||
|
||||
if(DDrawCfg.Shader) {
|
||||
Surface32->SetPixDw(iX, iY, pix);
|
||||
continue;
|
||||
};
|
||||
// Sky
|
||||
if(!pix)
|
||||
{
|
||||
|
|
|
@ -136,6 +136,7 @@ class CPattern
|
|||
uint32_t *pAlpha;
|
||||
public:
|
||||
CPattern& operator=(const CPattern&);
|
||||
const CSurface *getSurface() const { return sfcPattern32; }
|
||||
bool PatternClr(int iX, int iY, BYTE &byClr, DWORD &dwClr, CStdPalette &rPal) const; // apply pattern to color
|
||||
bool IsNewStyle() { if (sfcPattern32) return true; }
|
||||
bool Set(class CSurface *sfcSource, int iZoom=0, bool fMonochrome=false); // set and enable pattern
|
||||
|
@ -286,7 +287,7 @@ class CStdDDraw
|
|||
virtual bool PrepareRendering(SURFACE sfcToSurface) = 0; // check if/make rendering possible to given surface
|
||||
// Blit
|
||||
virtual void BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiquidAnimation, float fx, float fy,
|
||||
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt);
|
||||
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, const SURFACE textures[]);
|
||||
void Blit8Fast(CSurface8 * sfcSource, int fx, int fy,
|
||||
SURFACE sfcTarget, int tx, int ty, int wdt, int hgt);
|
||||
BOOL Blit(SURFACE sfcSource, float fx, float fy, float fwdt, float fhgt,
|
||||
|
|
|
@ -92,7 +92,7 @@ class CStdGL : public CStdDDraw
|
|||
bool fFullscreen; // fullscreen mode?
|
||||
int iClrDpt; // color depth
|
||||
// shaders for the ARB extension
|
||||
GLuint shaders[12];
|
||||
GLuint shaders[13];
|
||||
// vertex buffer object
|
||||
GLuint vbo;
|
||||
public:
|
||||
|
@ -117,7 +117,7 @@ class CStdGL : public CStdDDraw
|
|||
// Blit
|
||||
void PerformBlt(CBltData &rBltData, CTexRef *pTex, DWORD dwModClr, bool fMod2, bool fExact);
|
||||
virtual void BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiquidAnimation, float fx, float fy,
|
||||
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt);
|
||||
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, const SURFACE textures[]);
|
||||
void FillBG(DWORD dwClr=0);
|
||||
// Drawing
|
||||
void DrawQuadDw(SURFACE sfcTarget, float *ipVtx, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4);
|
||||
|
|
|
@ -829,7 +829,7 @@ bool CStdDDraw::ClipPoly(CBltData &rBltData)
|
|||
}
|
||||
|
||||
void CStdDDraw::BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcSource3, float fx, float fy,
|
||||
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt)
|
||||
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, const SURFACE textures[])
|
||||
{
|
||||
Blit(sfcSource, fx, fy, wdt, hgt, sfcTarget, tx, ty, wdt, hgt, FALSE);
|
||||
}
|
||||
|
|
|
@ -303,9 +303,9 @@ void CStdGL::PerformBlt(CBltData &rBltData, CTexRef *pTex, DWORD dwModClr, bool
|
|||
}
|
||||
|
||||
void CStdGL::BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiquidAnimation, float fx, float fy,
|
||||
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt)
|
||||
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, const SURFACE mattextures[])
|
||||
{
|
||||
Blit(sfcSource, fx, fy, wdt, hgt, sfcTarget, tx, ty, wdt, hgt);return;
|
||||
//Blit(sfcSource, fx, fy, wdt, hgt, sfcTarget, tx, ty, wdt, hgt);return;
|
||||
// safety
|
||||
if (!sfcSource || !sfcTarget || !wdt || !hgt) return;
|
||||
assert(sfcTarget->IsRenderTarget());
|
||||
|
@ -401,6 +401,7 @@ void CStdGL::BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiq
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
s=12; //Special-Shader!
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shaders[s]);
|
||||
if (Saturation < 255)
|
||||
{
|
||||
|
@ -465,10 +466,10 @@ void CStdGL::BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiq
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
CTexRef *pTex = *(sfcSource->ppTex + iY * sfcSource->iTexX + iX);
|
||||
glBindTexture(GL_TEXTURE_2D, pTex->texName);
|
||||
if (Zoom != 1.0 && !DDrawCfg.PointFiltering)
|
||||
if (Zoom != 1.0);// && !DDrawCfg.PointFiltering)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
}
|
||||
if (sfcSource2)
|
||||
{
|
||||
|
@ -540,9 +541,38 @@ void CStdGL::BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiq
|
|||
Vtx[i].fty += DDrawCfg.fBlitOff;
|
||||
Vtx[i].ftz = 0;
|
||||
}
|
||||
if(DDrawCfg.Shader)
|
||||
{
|
||||
GLfloat shaderparam[4];
|
||||
for (int cnt=1;cnt<127;cnt++)
|
||||
{
|
||||
if(mattextures[cnt])
|
||||
{
|
||||
shaderparam[0]=static_cast<GLfloat>(cnt)/255.0f;
|
||||
glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 0, shaderparam);
|
||||
|
||||
glActiveTexture(GL_TEXTURE1); //Bind Mat Texture
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, (*(mattextures[cnt]->ppTex))->texName);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
glInterleavedArrays(GL_T2F_C4UB_V3F, sizeof(CBltVertex), Vtx);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glInterleavedArrays(GL_T2F_C4UB_V3F, sizeof(CBltVertex), Vtx);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
}
|
||||
|
||||
glInterleavedArrays(GL_T2F_C4UB_V3F, sizeof(CBltVertex), Vtx);
|
||||
glDrawArrays(GL_POLYGON, 0, 4);
|
||||
}
|
||||
}
|
||||
if (shaders[0])
|
||||
|
@ -834,6 +864,22 @@ bool CStdGL::RestoreDeviceObjects()
|
|||
// sample the texture
|
||||
"TXP fow, fragment.texcoord[3], texture[3], 2D;\n"
|
||||
"LRP tmp.rgb, fow.aaaa, tmp, fow;\n";
|
||||
const char * landscape =
|
||||
"TEMP col;\n"
|
||||
"MOV col.x, program.local[0].x;\n" //Load color to indentify
|
||||
"ADD col.y, col.x, 0.001;\n"
|
||||
"SUB col.z, col.x, 0.001;\n" //epsilon-range
|
||||
"SGE tmp.r, tmp.b, 0.5015;\n" //Tunnel?
|
||||
"MAD tmp.r, tmp.r, -0.5019, tmp.b;\n"
|
||||
"SGE col.z, tmp.r, col.z;\n" //mat identified?
|
||||
"SLT col.y, tmp.r, col.y;\n"
|
||||
"TEMP coo;\n"
|
||||
"MOV coo, fragment.texcoord;\n"
|
||||
"MUL coo.xy, coo, 3.0;\n"
|
||||
"TXP tmp, coo, texture[1], 2D;\n"
|
||||
"MUL tmp.a, col.y, col.z;\n"
|
||||
"SUB tmp.a, 1.0, tmp.a;\n"
|
||||
;
|
||||
const char * end =
|
||||
"MOV result.color, tmp;\n"
|
||||
"END\n";
|
||||
|
@ -849,6 +895,7 @@ bool CStdGL::RestoreDeviceObjects()
|
|||
DefineShaderARB(FormatString("%s%s%s%s%s", preface, alpha_add, grey, fow, end).getData(), shaders[9]);
|
||||
DefineShaderARB(FormatString("%s%s%s%s%s", preface, funny_add, grey, fow, end).getData(), shaders[10]);
|
||||
DefineShaderARB(FormatString("%s%s%s%s%s%s", preface, liquid, alpha_add, grey, fow, end).getData(), shaders[11]);
|
||||
DefineShaderARB(FormatString("%s%s%s", preface, landscape, end).getData(), shaders[12]);
|
||||
}
|
||||
// done
|
||||
return Active;
|
||||
|
|
Loading…
Reference in New Issue