2014-07-27 18:02:35 +02:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 06:38:14 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-07-27 18:02:35 +02:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-12-19 08:43:37 +01:00
|
|
|
#include "video_core/shader/shader.h"
|
2014-07-27 18:02:35 +02:00
|
|
|
|
2019-02-19 09:09:57 +01:00
|
|
|
namespace Pica::Rasterizer {
|
2014-07-27 18:02:35 +02:00
|
|
|
|
2016-12-19 08:43:37 +01:00
|
|
|
struct Vertex : Shader::OutputVertex {
|
|
|
|
Vertex(const OutputVertex& v) : OutputVertex(v) {}
|
|
|
|
|
|
|
|
// Attributes used to store intermediate results
|
|
|
|
// position after perspective divide
|
|
|
|
Math::Vec3<float24> screenpos;
|
|
|
|
|
|
|
|
// Linear interpolation
|
|
|
|
// factor: 0=this, 1=vtx
|
2017-08-17 10:02:19 +02:00
|
|
|
// Note: This function cannot be called after perspective divide
|
2016-12-19 08:43:37 +01:00
|
|
|
void Lerp(float24 factor, const Vertex& vtx) {
|
|
|
|
pos = pos * factor + vtx.pos * (float24::FromFloat32(1) - factor);
|
2017-05-20 22:17:12 +02:00
|
|
|
quat = quat * factor + vtx.quat * (float24::FromFloat32(1) - factor);
|
|
|
|
color = color * factor + vtx.color * (float24::FromFloat32(1) - factor);
|
2016-12-19 08:43:37 +01:00
|
|
|
tc0 = tc0 * factor + vtx.tc0 * (float24::FromFloat32(1) - factor);
|
|
|
|
tc1 = tc1 * factor + vtx.tc1 * (float24::FromFloat32(1) - factor);
|
2017-05-20 22:17:12 +02:00
|
|
|
tc0_w = tc0_w * factor + vtx.tc0_w * (float24::FromFloat32(1) - factor);
|
|
|
|
view = view * factor + vtx.view * (float24::FromFloat32(1) - factor);
|
2016-12-19 08:43:37 +01:00
|
|
|
tc2 = tc2 * factor + vtx.tc2 * (float24::FromFloat32(1) - factor);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Linear interpolation
|
|
|
|
// factor: 0=v0, 1=v1
|
2017-08-17 10:02:19 +02:00
|
|
|
// Note: This function cannot be called after perspective divide
|
2016-12-19 08:43:37 +01:00
|
|
|
static Vertex Lerp(float24 factor, const Vertex& v0, const Vertex& v1) {
|
|
|
|
Vertex ret = v0;
|
|
|
|
ret.Lerp(factor, v1);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void ProcessTriangle(const Vertex& v0, const Vertex& v1, const Vertex& v2);
|
2014-07-27 18:02:35 +02:00
|
|
|
|
2019-02-19 09:09:57 +01:00
|
|
|
} // namespace Pica::Rasterizer
|