only round vertices if AA is on
[skip ci]
This commit is contained in:
parent
2a4bd82605
commit
63c9e3ec8b
@ -1,7 +1,13 @@
|
|||||||
{
|
{
|
||||||
"blitFrameBuffer" : "main",
|
"blitFrameBuffer" : "main",
|
||||||
|
|
||||||
"effectParameters" : {},
|
"effectParameters" : {
|
||||||
|
"vertexRounding" : {
|
||||||
|
"type" : "bool",
|
||||||
|
"default" : false,
|
||||||
|
"uniform" : "vertexRounding"
|
||||||
|
}
|
||||||
|
},
|
||||||
"effectTextures" : {},
|
"effectTextures" : {},
|
||||||
|
|
||||||
"effectShaders" : {
|
"effectShaders" : {
|
||||||
|
@ -6,6 +6,7 @@ uniform vec2 textureSize2;
|
|||||||
uniform vec2 textureSize3;
|
uniform vec2 textureSize3;
|
||||||
uniform vec2 screenSize;
|
uniform vec2 screenSize;
|
||||||
uniform mat3 vertexTransform;
|
uniform mat3 vertexTransform;
|
||||||
|
uniform bool vertexRounding;
|
||||||
|
|
||||||
in vec2 vertexPosition;
|
in vec2 vertexPosition;
|
||||||
in vec4 vertexColor;
|
in vec4 vertexColor;
|
||||||
@ -19,10 +20,14 @@ out vec4 fragmentColor;
|
|||||||
void main() {
|
void main() {
|
||||||
vec2 screenPosition = (vertexTransform * vec3(vertexPosition, 1.0)).xy;
|
vec2 screenPosition = (vertexTransform * vec3(vertexPosition, 1.0)).xy;
|
||||||
gl_Position = vec4(screenPosition / screenSize * 2.0 - 1.0, 0.0, 1.0);
|
gl_Position = vec4(screenPosition / screenSize * 2.0 - 1.0, 0.0, 1.0);
|
||||||
if (((vertexData >> 3) & 0x1) == 1)
|
|
||||||
screenPosition.x = round(screenPosition.x);
|
if (vertexRounding) {
|
||||||
if (((vertexData >> 4) & 0x1) == 1)
|
if (((vertexData >> 3) & 0x1) == 1)
|
||||||
screenPosition.y = round(screenPosition.y);
|
screenPosition.x = round(screenPosition.x);
|
||||||
|
if (((vertexData >> 4) & 0x1) == 1)
|
||||||
|
screenPosition.y = round(screenPosition.y);
|
||||||
|
}
|
||||||
|
|
||||||
int vertexTextureIndex = vertexData & 0x3;
|
int vertexTextureIndex = vertexData & 0x3;
|
||||||
if (vertexTextureIndex == 3)
|
if (vertexTextureIndex == 3)
|
||||||
fragmentTextureCoordinate = vertexTextureCoordinate / textureSize3;
|
fragmentTextureCoordinate = vertexTextureCoordinate / textureSize3;
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
"type" : "float",
|
"type" : "float",
|
||||||
"default" : 1.0,
|
"default" : 1.0,
|
||||||
"uniform" : "lightMapMultiplier"
|
"uniform" : "lightMapMultiplier"
|
||||||
|
},
|
||||||
|
"vertexRounding" : {
|
||||||
|
"type" : "bool",
|
||||||
|
"default" : false,
|
||||||
|
"uniform" : "vertexRounding"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ uniform vec2 textureSize2;
|
|||||||
uniform vec2 textureSize3;
|
uniform vec2 textureSize3;
|
||||||
uniform vec2 screenSize;
|
uniform vec2 screenSize;
|
||||||
uniform mat3 vertexTransform;
|
uniform mat3 vertexTransform;
|
||||||
|
uniform bool vertexRounding;
|
||||||
uniform vec2 lightMapSize;
|
uniform vec2 lightMapSize;
|
||||||
uniform vec2 lightMapScale;
|
uniform vec2 lightMapScale;
|
||||||
uniform vec2 lightMapOffset;
|
uniform vec2 lightMapOffset;
|
||||||
@ -24,10 +25,12 @@ out vec2 fragmentLightMapCoordinate;
|
|||||||
void main() {
|
void main() {
|
||||||
vec2 screenPosition = (vertexTransform * vec3(vertexPosition, 1.0)).xy;
|
vec2 screenPosition = (vertexTransform * vec3(vertexPosition, 1.0)).xy;
|
||||||
|
|
||||||
if (((vertexData >> 3) & 0x1) == 1)
|
if (vertexRounding) {
|
||||||
screenPosition.x = round(screenPosition.x);
|
if (((vertexData >> 3) & 0x1) == 1)
|
||||||
if (((vertexData >> 4) & 0x1) == 1)
|
screenPosition.x = round(screenPosition.x);
|
||||||
screenPosition.y = round(screenPosition.y);
|
if (((vertexData >> 4) & 0x1) == 1)
|
||||||
|
screenPosition.y = round(screenPosition.y);
|
||||||
|
}
|
||||||
|
|
||||||
fragmentLightMapMultiplier = float((vertexData >> 2) & 0x1);
|
fragmentLightMapMultiplier = float((vertexData >> 2) & 0x1);
|
||||||
int vertexTextureIndex = vertexData & 0x3;
|
int vertexTextureIndex = vertexData & 0x3;
|
||||||
|
@ -394,6 +394,8 @@ bool OpenGlRenderer::switchEffectConfig(String const& name) {
|
|||||||
setupGlUniforms(effect);
|
setupGlUniforms(effect);
|
||||||
m_currentEffect = &effect;
|
m_currentEffect = &effect;
|
||||||
|
|
||||||
|
setEffectParameter("vertexRounding", m_multiSampling > 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +434,7 @@ void OpenGlRenderer::setMultiSampling(unsigned multiSampling) {
|
|||||||
if (m_multiSampling) {
|
if (m_multiSampling) {
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
glEnable(GL_SAMPLE_SHADING);
|
glEnable(GL_SAMPLE_SHADING);
|
||||||
glMinSampleShading(1.0f);
|
glMinSampleShading(1.f);
|
||||||
} else {
|
} else {
|
||||||
glMinSampleShading(0.f);
|
glMinSampleShading(0.f);
|
||||||
glDisable(GL_SAMPLE_SHADING);
|
glDisable(GL_SAMPLE_SHADING);
|
||||||
|
@ -223,7 +223,7 @@ void CellularLightIntensityCalculator::addSpreadLight(Vec2F const& position, flo
|
|||||||
|
|
||||||
void CellularLightIntensityCalculator::addPointLight(Vec2F const& position, float light, float beam, float beamAngle, float beamAmbience) {
|
void CellularLightIntensityCalculator::addPointLight(Vec2F const& position, float light, float beam, float beamAngle, float beamAmbience) {
|
||||||
Vec2F arrayPosition = position - Vec2F(m_calculationRegion.min());
|
Vec2F arrayPosition = position - Vec2F(m_calculationRegion.min());
|
||||||
m_lightArray.addPointLight({arrayPosition, light, beam, beamAngle, beamAmbience});
|
m_lightArray.addPointLight({arrayPosition, light, beam, beamAngle, beamAmbience, false});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ IODevicePtr MemoryAssetSource::open(String const& path) {
|
|||||||
String deviceName() const override { return name; }
|
String deviceName() const override { return name; }
|
||||||
|
|
||||||
bool atEnd() override {
|
bool atEnd() override {
|
||||||
return assetPos >= assetSize;
|
return assetPos >= (StreamOffset)assetSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void seek(StreamOffset p, IOSeek mode) override {
|
void seek(StreamOffset p, IOSeek mode) override {
|
||||||
|
@ -110,6 +110,8 @@ public:
|
|||||||
template <typename T2>
|
template <typename T2>
|
||||||
Vec3 operator*(Vector<T2, 3> const& v) const;
|
Vec3 operator*(Vector<T2, 3> const& v) const;
|
||||||
|
|
||||||
|
template <typename T2>
|
||||||
|
Vec2 operator*(Vector<T2, 2> const& v) const;
|
||||||
private:
|
private:
|
||||||
Rows m_rows;
|
Rows m_rows;
|
||||||
};
|
};
|
||||||
@ -304,8 +306,7 @@ void Matrix3<T>::scale(T scale, Vec2 const& point) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
Vector<T2, 2> Matrix3<T>::transformVec2(Vector<T2, 2> const& point) const {
|
Vector<T2, 2> Matrix3<T>::transformVec2(Vector<T2, 2> const& point) const {
|
||||||
Vector<T2, 3> res = (*this) * Vector<T2, 3>(point, 1);
|
return (*this) * point;
|
||||||
return res.vec2();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -412,6 +413,13 @@ auto Matrix3<T>::operator*(const Vector<T2, 3>& u) const -> Vec3 {
|
|||||||
m_rows[2][0] * u[0] + m_rows[2][1] * u[1] + m_rows[2][2] * u[2]);
|
m_rows[2][0] * u[0] + m_rows[2][1] * u[1] + m_rows[2][2] * u[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
template <typename T2>
|
||||||
|
auto Matrix3<T>::operator*(const Vector<T2, 2>& u) const -> Vec2 {
|
||||||
|
return Vec2(m_rows[0][0] * u[0] + m_rows[0][1] * u[1] + m_rows[0][2],
|
||||||
|
m_rows[1][0] * u[0] + m_rows[1][1] * u[1] + m_rows[1][2]);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Matrix3<T> Matrix3<T>::operator/(const T& s) const {
|
Matrix3<T> Matrix3<T>::operator/(const T& s) const {
|
||||||
return Matrix3<T>(m_rows[0] / s, m_rows[1] / s, m_rows[2] / s);
|
return Matrix3<T>(m_rows[0] / s, m_rows[1] / s, m_rows[2] / s);
|
||||||
|
@ -36,15 +36,13 @@ void DrawablePainter::drawDrawable(Drawable const& drawable) {
|
|||||||
} else if (auto imagePart = drawable.part.ptr<Drawable::ImagePart>()) {
|
} else if (auto imagePart = drawable.part.ptr<Drawable::ImagePart>()) {
|
||||||
TexturePtr texture = m_textureGroup->loadTexture(imagePart->image);
|
TexturePtr texture = m_textureGroup->loadTexture(imagePart->image);
|
||||||
|
|
||||||
|
Vec2F position = drawable.position;
|
||||||
Vec2F textureSize(texture->size());
|
Vec2F textureSize(texture->size());
|
||||||
RectF imageRect(Vec2F(), textureSize);
|
Mat3F transformation = imagePart->transformation;
|
||||||
|
Vec2F lowerLeft = { transformation[0][2] += position.x(), transformation[1][2] += position.y() };
|
||||||
Mat3F transformation = Mat3F::translation(drawable.position) * imagePart->transformation;
|
Vec2F lowerRight = transformation * Vec2F(textureSize.x(), 0.f);
|
||||||
|
Vec2F upperRight = transformation * textureSize;
|
||||||
Vec2F lowerLeft = transformation.transformVec2(Vec2F(imageRect.xMin(), imageRect.yMin()));
|
Vec2F upperLeft = transformation * Vec2F(0.f, textureSize.y());
|
||||||
Vec2F lowerRight = transformation.transformVec2(Vec2F(imageRect.xMax(), imageRect.yMin()));
|
|
||||||
Vec2F upperRight = transformation.transformVec2(Vec2F(imageRect.xMax(), imageRect.yMax()));
|
|
||||||
Vec2F upperLeft = transformation.transformVec2(Vec2F(imageRect.xMin(), imageRect.yMax()));
|
|
||||||
|
|
||||||
float param1 = drawable.fullbright ? 0.0f : 1.0f;
|
float param1 = drawable.fullbright ? 0.0f : 1.0f;
|
||||||
|
|
||||||
|
@ -26,15 +26,17 @@ void WorldCamera::setCenterWorldPosition(Vec2F const& position, bool force) {
|
|||||||
// elements drawn in world space that are aligned with TilePixels will
|
// elements drawn in world space that are aligned with TilePixels will
|
||||||
// eventually also be aligned to real screen pixels.
|
// eventually also be aligned to real screen pixels.
|
||||||
|
|
||||||
|
float ratio = TilePixels * m_pixelRatio;
|
||||||
|
|
||||||
if (m_screenSize[0] % 2 == 0)
|
if (m_screenSize[0] % 2 == 0)
|
||||||
m_worldCenter[0] = round(m_worldCenter[0] * (TilePixels * m_pixelRatio)) / (TilePixels * m_pixelRatio);
|
m_worldCenter[0] = round(m_worldCenter[0] * ratio) / ratio;
|
||||||
else
|
else
|
||||||
m_worldCenter[0] = (round(m_worldCenter[0] * (TilePixels * m_pixelRatio) + 0.5f) - 0.5f) / (TilePixels * m_pixelRatio);
|
m_worldCenter[0] = (round(m_worldCenter[0] * ratio + 0.5f) - 0.5f) / ratio;
|
||||||
|
|
||||||
if (m_screenSize[1] % 2 == 0)
|
if (m_screenSize[1] % 2 == 0)
|
||||||
m_worldCenter[1] = round(m_worldCenter[1] * (TilePixels * m_pixelRatio)) / (TilePixels * m_pixelRatio);
|
m_worldCenter[1] = round(m_worldCenter[1] * ratio) / ratio;
|
||||||
else
|
else
|
||||||
m_worldCenter[1] = (round(m_worldCenter[1] * (TilePixels * m_pixelRatio) + 0.5f) - 0.5f) / (TilePixels * m_pixelRatio);
|
m_worldCenter[1] = (round(m_worldCenter[1] * ratio + 0.5f) - 0.5f) / ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user