refactored vertex streams
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
|
||||
// Platform agnostic:
|
||||
#include <DirectXMath.h>
|
||||
#include <DirectXPackedVector.h>
|
||||
using namespace DirectX;
|
||||
using namespace DirectX::PackedVector;
|
||||
|
||||
#define ALIGN_16 void* operator new(size_t i){return _mm_malloc(i, 16);} void operator delete(void* p){_mm_free(p);}
|
||||
#define SAFE_INIT(a) (a) = nullptr;
|
||||
|
||||
@@ -67,9 +67,8 @@
|
||||
// Skinning:
|
||||
#define SKINNINGSLOT_IN_VERTEX_POS 0
|
||||
#define SKINNINGSLOT_IN_VERTEX_NOR 1
|
||||
#define SKINNINGSLOT_IN_VERTEX_WEI 2
|
||||
#define SKINNINGSLOT_IN_VERTEX_BON 3
|
||||
#define SKINNINGSLOT_IN_BONEBUFFER 4
|
||||
#define SKINNINGSLOT_IN_VERTEX_BON 2
|
||||
#define SKINNINGSLOT_IN_BONEBUFFER 3
|
||||
|
||||
#define SKINNINGSLOT_OUT_VERTEX_POS 0
|
||||
#define SKINNINGSLOT_OUT_VERTEX_NOR 1
|
||||
|
||||
@@ -9,7 +9,6 @@ STRUCTUREDBUFFER(boneBuffer, Bone, SKINNINGSLOT_IN_BONEBUFFER);
|
||||
|
||||
RAWBUFFER(vertexBuffer_POS, SKINNINGSLOT_IN_VERTEX_POS);
|
||||
RAWBUFFER(vertexBuffer_NOR, SKINNINGSLOT_IN_VERTEX_NOR);
|
||||
RAWBUFFER(vertexBuffer_WEI, SKINNINGSLOT_IN_VERTEX_WEI);
|
||||
RAWBUFFER(vertexBuffer_BON, SKINNINGSLOT_IN_VERTEX_BON);
|
||||
|
||||
RWRAWBUFFER(streamoutBuffer_POS, SKINNINGSLOT_OUT_VERTEX_POS);
|
||||
@@ -49,24 +48,32 @@ inline void Skinning(inout float4 pos, inout float4 nor, in float4 inBon, in flo
|
||||
[numthreads(SKINNING_COMPUTE_THREADCOUNT, 1, 1)]
|
||||
void main( uint3 DTid : SV_DispatchThreadID )
|
||||
{
|
||||
const uint fetchAddress = DTid.x * 16;
|
||||
const uint stride_POS = 16;
|
||||
const uint stride_NOR = 16;
|
||||
const uint stride_BON_IND = 16;
|
||||
const uint stride_BON_WEI = 16;
|
||||
|
||||
uint4 pos_u = vertexBuffer_POS.Load4(fetchAddress);
|
||||
uint4 nor_u = vertexBuffer_NOR.Load4(fetchAddress);
|
||||
uint4 wei_u = vertexBuffer_WEI.Load4(fetchAddress);
|
||||
uint4 bon_u = vertexBuffer_BON.Load4(fetchAddress);
|
||||
const uint fetchAddress_POS = DTid.x * stride_POS;
|
||||
const uint fetchAddress_NOR = DTid.x * stride_NOR;
|
||||
const uint fetchAddress_BON_IND = DTid.x * (stride_BON_IND + stride_BON_WEI) + 0;
|
||||
const uint fetchAddress_BON_WEI = DTid.x * (stride_BON_IND + stride_BON_WEI) + stride_BON_IND;
|
||||
|
||||
uint4 pos_u = vertexBuffer_POS.Load4(fetchAddress_POS);
|
||||
uint4 nor_u = vertexBuffer_NOR.Load4(fetchAddress_NOR);
|
||||
uint4 ind_u = vertexBuffer_BON.Load4(fetchAddress_BON_IND);
|
||||
uint4 wei_u = vertexBuffer_BON.Load4(fetchAddress_BON_WEI);
|
||||
|
||||
float4 pos = asfloat(pos_u);
|
||||
float4 nor = asfloat(nor_u);
|
||||
float4 ind = asfloat(ind_u);
|
||||
float4 wei = asfloat(wei_u);
|
||||
float4 bon = asfloat(bon_u);
|
||||
|
||||
Skinning(pos, nor, bon, wei);
|
||||
Skinning(pos, nor, ind, wei);
|
||||
|
||||
pos_u = asuint(pos);
|
||||
nor_u = asuint(nor);
|
||||
|
||||
streamoutBuffer_PRE.Store4(fetchAddress, streamoutBuffer_POS.Load4(fetchAddress)); // copy prev frame current pos to current frame prev pos
|
||||
streamoutBuffer_POS.Store4(fetchAddress, pos_u);
|
||||
streamoutBuffer_NOR.Store4(fetchAddress, nor_u);
|
||||
streamoutBuffer_PRE.Store4(fetchAddress_POS, streamoutBuffer_POS.Load4(fetchAddress_POS)); // copy prev frame current pos to current frame prev pos
|
||||
streamoutBuffer_POS.Store4(fetchAddress_POS, pos_u);
|
||||
streamoutBuffer_NOR.Store4(fetchAddress_NOR, nor_u);
|
||||
}
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "BulletSoftBody/btDefaultSoftBodySolver.h"
|
||||
#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int PHYSICS::softBodyIterationCount=5;
|
||||
bool PHYSICS::rigidBodyPhysicsEnabled = true, PHYSICS::softBodyPhysicsEnabled = true;
|
||||
bool wiBULLET::grab=false;
|
||||
@@ -585,15 +587,15 @@ void wiBULLET::connectVerticesToSoftBody(Mesh* const mesh, int objectI){
|
||||
btSoftBody::tNodeArray& nodes(softBody->m_nodes);
|
||||
|
||||
int gvg = mesh->goalVG;
|
||||
for (unsigned int i = 0; i<mesh->vertices[VPROP_POS].size(); ++i)
|
||||
for (unsigned int i = 0; i<mesh->vertices_POS.size(); ++i)
|
||||
{
|
||||
int indexP = mesh->physicalmapGP[i];
|
||||
float weight = mesh->vertexGroups[gvg].vertices[indexP];
|
||||
mesh->vertices_Transformed[VPROP_PRE][i] = mesh->vertices_Transformed[VPROP_POS][i];
|
||||
mesh->vertices_Transformed[VPROP_POS][i] = XMFLOAT4(nodes[indexP].m_x.getX(), nodes[indexP].m_x.getY(), nodes[indexP].m_x.getZ(), mesh->vertices[VPROP_POS][i].w);
|
||||
mesh->vertices_Transformed[VPROP_NOR][i].x = -nodes[indexP].m_n.getX();
|
||||
mesh->vertices_Transformed[VPROP_NOR][i].y = -nodes[indexP].m_n.getY();
|
||||
mesh->vertices_Transformed[VPROP_NOR][i].z = -nodes[indexP].m_n.getZ();
|
||||
mesh->vertices_Transformed_PRE[i].pos = mesh->vertices_Transformed_POS[i].pos;
|
||||
mesh->vertices_Transformed_POS[i].pos = XMFLOAT4(nodes[indexP].m_x.getX(), nodes[indexP].m_x.getY(), nodes[indexP].m_x.getZ(), mesh->vertices_POS[i].pos.w);
|
||||
mesh->vertices_Transformed_NOR[i].nor.x = -nodes[indexP].m_n.getX();
|
||||
mesh->vertices_Transformed_NOR[i].nor.y = -nodes[indexP].m_n.getY();
|
||||
mesh->vertices_Transformed_NOR[i].nor.z = -nodes[indexP].m_n.getZ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -699,8 +701,14 @@ void wiBULLET::registerObject(Object* object){
|
||||
object->physicsObjectID = ++registeredObjects;
|
||||
}
|
||||
if(!object->collisionShape.compare("CONVEX_HULL")){
|
||||
vector<XMFLOAT4> pos_stream(object->mesh->vertices_POS.size());
|
||||
for (size_t i = 0; i < object->mesh->vertices_POS.size(); ++i)
|
||||
{
|
||||
pos_stream[i] = object->mesh->vertices_POS[i].pos;
|
||||
}
|
||||
|
||||
addConvexHull(
|
||||
object->mesh->vertices[VPROP_POS],
|
||||
pos_stream,
|
||||
S,R,T
|
||||
,object->mass,object->friction,object->restitution
|
||||
,object->damping,object->kinematic
|
||||
@@ -708,8 +716,14 @@ void wiBULLET::registerObject(Object* object){
|
||||
object->physicsObjectID = ++registeredObjects;
|
||||
}
|
||||
if(!object->collisionShape.compare("MESH")){
|
||||
vector<XMFLOAT4> pos_stream(object->mesh->vertices_POS.size());
|
||||
for (size_t i = 0; i < object->mesh->vertices_POS.size(); ++i)
|
||||
{
|
||||
pos_stream[i] = object->mesh->vertices_POS[i].pos;
|
||||
}
|
||||
|
||||
addTriangleMesh(
|
||||
object->mesh->vertices[VPROP_POS],object->mesh->indices,
|
||||
pos_stream,object->mesh->indices,
|
||||
S,R,T
|
||||
,object->mass,object->friction,object->restitution
|
||||
,object->damping,object->kinematic
|
||||
|
||||
@@ -144,16 +144,16 @@ void wiEmittedParticle::addPoint(const XMMATRIX& t4, const XMMATRIX& t3)
|
||||
XMFLOAT3 pos;
|
||||
XMFLOAT3 vel;
|
||||
XMVECTOR& vbar=XMVectorBaryCentric(
|
||||
XMLoadFloat4(&object->mesh->vertices[VPROP_POS][object->mesh->indices[gen[0]]])
|
||||
, XMLoadFloat4(&object->mesh->vertices[VPROP_POS][object->mesh->indices[gen[1]]])
|
||||
, XMLoadFloat4(&object->mesh->vertices[VPROP_POS][object->mesh->indices[gen[2]]])
|
||||
XMLoadFloat4(&object->mesh->vertices_POS[object->mesh->indices[gen[0]]].pos)
|
||||
, XMLoadFloat4(&object->mesh->vertices_POS[object->mesh->indices[gen[1]]].pos)
|
||||
, XMLoadFloat4(&object->mesh->vertices_POS[object->mesh->indices[gen[2]]].pos)
|
||||
, f
|
||||
, g
|
||||
);
|
||||
XMVECTOR& nbar=XMVectorBaryCentric(
|
||||
XMLoadFloat4(&object->mesh->vertices[VPROP_NOR][object->mesh->indices[gen[0]]])
|
||||
, XMLoadFloat4(&object->mesh->vertices[VPROP_NOR][object->mesh->indices[gen[1]]])
|
||||
, XMLoadFloat4(&object->mesh->vertices[VPROP_NOR][object->mesh->indices[gen[2]]])
|
||||
XMLoadFloat4(&object->mesh->vertices_NOR[object->mesh->indices[gen[0]]].nor)
|
||||
, XMLoadFloat4(&object->mesh->vertices_NOR[object->mesh->indices[gen[1]]].nor)
|
||||
, XMLoadFloat4(&object->mesh->vertices_NOR[object->mesh->indices[gen[2]]].nor)
|
||||
, f
|
||||
, g
|
||||
);
|
||||
|
||||
@@ -312,13 +312,17 @@ void wiHairParticle::Generate()
|
||||
if (lenMod[m] < 0) lenMod[m] = 0;
|
||||
}
|
||||
|
||||
Vertex verts[3];
|
||||
verts[0].pos = mesh->vertices[VPROP_POS][vi[0]];
|
||||
verts[0].nor = mesh->vertices[VPROP_NOR][vi[0]];
|
||||
verts[1].pos = mesh->vertices[VPROP_POS][vi[1]];
|
||||
verts[1].nor = mesh->vertices[VPROP_NOR][vi[1]];
|
||||
verts[2].pos = mesh->vertices[VPROP_POS][vi[2]];
|
||||
verts[2].nor = mesh->vertices[VPROP_NOR][vi[2]];
|
||||
Mesh::Vertex_FULL verts[] = {
|
||||
mesh->vertices_FULL[vi[0]],
|
||||
mesh->vertices_FULL[vi[1]],
|
||||
mesh->vertices_FULL[vi[2]],
|
||||
};
|
||||
//verts[0].pos = mesh->vertices_POS[vi[0]].pos;
|
||||
//verts[0].nor = mesh->vertices_NOR[vi[0]].nor;
|
||||
//verts[1].pos = mesh->vertices_POS[vi[1]].pos;
|
||||
//verts[1].nor = mesh->vertices_NOR[vi[1]].nor;
|
||||
//verts[2].pos = mesh->vertices_POS[vi[2]].pos;
|
||||
//verts[2].nor = mesh->vertices_NOR[vi[2]].nor;
|
||||
|
||||
if(
|
||||
(denMod[0]>FLT_EPSILON || denMod[1]>FLT_EPSILON || denMod[2]>FLT_EPSILON) &&
|
||||
|
||||
+263
-221
File diff suppressed because it is too large
Load Diff
+126
-67
@@ -34,68 +34,68 @@ typedef std::map<std::string,Material*> MaterialCollection;
|
||||
|
||||
class wiArchive;
|
||||
|
||||
enum VERTEXPROPERTY
|
||||
{
|
||||
VPROP_POS, // pos, wind
|
||||
VPROP_NOR, // normal, vertexao
|
||||
VPROP_TEX, // texcoord, materialindex, unused
|
||||
VPROP_BON, // boneindices
|
||||
VPROP_WEI, // boneweights
|
||||
VPROP_COUNT,
|
||||
};
|
||||
#define VPROP_PRE VPROP_BON // posprev
|
||||
struct SkinnedVertex
|
||||
{
|
||||
XMFLOAT4 pos; //pos, wind
|
||||
XMFLOAT4 nor; //normal, vertex ao
|
||||
XMFLOAT4 tex; //tex, matIndex, unused
|
||||
XMFLOAT4 bon; //bone indices
|
||||
XMFLOAT4 wei; //bone weights
|
||||
|
||||
|
||||
SkinnedVertex(){
|
||||
pos=XMFLOAT4(0,0,0,0);
|
||||
nor=XMFLOAT4(0,0,0,1);
|
||||
tex=XMFLOAT4(0,0,0,0);
|
||||
bon=XMFLOAT4(0,0,0,0);
|
||||
wei=XMFLOAT4(0,0,0,0);
|
||||
};
|
||||
SkinnedVertex(const XMFLOAT3& newPos){
|
||||
pos=XMFLOAT4(newPos.x,newPos.y,newPos.z,1);
|
||||
nor=XMFLOAT4(0,0,0,1);
|
||||
tex=XMFLOAT4(0,0,0,0);
|
||||
bon=XMFLOAT4(0,0,0,0);
|
||||
wei=XMFLOAT4(0,0,0,0);
|
||||
}
|
||||
//void Serialize(wiArchive& archive);
|
||||
};
|
||||
struct Vertex
|
||||
{
|
||||
XMFLOAT4 pos; //pos, wind
|
||||
XMFLOAT4 nor; //normal, vertex ao
|
||||
XMFLOAT4 tex; //tex, matIndex, unused
|
||||
XMFLOAT4 pre; //previous frame position
|
||||
|
||||
Vertex(){
|
||||
pos=XMFLOAT4(0,0,0,0);
|
||||
nor=XMFLOAT4(0,0,0,1);
|
||||
tex=XMFLOAT4(0,0,0,0);
|
||||
pre=XMFLOAT4(0,0,0,0);
|
||||
};
|
||||
Vertex(const XMFLOAT3& newPos){
|
||||
pos=XMFLOAT4(newPos.x,newPos.y,newPos.z,1);
|
||||
nor=XMFLOAT4(0,0,0,1);
|
||||
tex=XMFLOAT4(0,0,0,0);
|
||||
pre=XMFLOAT4(0,0,0,0);
|
||||
}
|
||||
Vertex(const SkinnedVertex& copyFromSkinnedVert)
|
||||
{
|
||||
pos = copyFromSkinnedVert.pos;
|
||||
nor = copyFromSkinnedVert.nor;
|
||||
tex = copyFromSkinnedVert.tex;
|
||||
pre = XMFLOAT4(0, 0, 0, 0);
|
||||
}
|
||||
};
|
||||
//enum VERTEXPROPERTY
|
||||
//{
|
||||
// VPROP_POS, // pos, wind
|
||||
// VPROP_NOR, // normal, vertexao
|
||||
// VPROP_TEX, // texcoord, materialindex, unused
|
||||
// VPROP_BON, // boneindices
|
||||
// VPROP_WEI, // boneweights
|
||||
// VPROP_COUNT,
|
||||
//};
|
||||
//#define VPROP_PRE VPROP_BON // posprev
|
||||
//struct SkinnedVertex
|
||||
//{
|
||||
// XMFLOAT4 pos; //pos, wind
|
||||
// XMFLOAT4 nor; //normal, vertex ao
|
||||
// XMFLOAT4 tex; //tex, matIndex, unused
|
||||
// XMFLOAT4 bon; //bone indices
|
||||
// XMFLOAT4 wei; //bone weights
|
||||
//
|
||||
//
|
||||
// SkinnedVertex(){
|
||||
// pos=XMFLOAT4(0,0,0,0);
|
||||
// nor=XMFLOAT4(0,0,0,1);
|
||||
// tex=XMFLOAT4(0,0,0,0);
|
||||
// bon=XMFLOAT4(0,0,0,0);
|
||||
// wei=XMFLOAT4(0,0,0,0);
|
||||
// };
|
||||
// SkinnedVertex(const XMFLOAT3& newPos){
|
||||
// pos=XMFLOAT4(newPos.x,newPos.y,newPos.z,1);
|
||||
// nor=XMFLOAT4(0,0,0,1);
|
||||
// tex=XMFLOAT4(0,0,0,0);
|
||||
// bon=XMFLOAT4(0,0,0,0);
|
||||
// wei=XMFLOAT4(0,0,0,0);
|
||||
// }
|
||||
// //void Serialize(wiArchive& archive);
|
||||
//};
|
||||
//struct Vertex
|
||||
//{
|
||||
// XMFLOAT4 pos; //pos, wind
|
||||
// XMFLOAT4 nor; //normal, vertex ao
|
||||
// XMFLOAT4 tex; //tex, matIndex, unused
|
||||
// XMFLOAT4 pre; //previous frame position
|
||||
//
|
||||
// Vertex(){
|
||||
// pos=XMFLOAT4(0,0,0,0);
|
||||
// nor=XMFLOAT4(0,0,0,1);
|
||||
// tex=XMFLOAT4(0,0,0,0);
|
||||
// pre=XMFLOAT4(0,0,0,0);
|
||||
// };
|
||||
// Vertex(const XMFLOAT3& newPos){
|
||||
// pos=XMFLOAT4(newPos.x,newPos.y,newPos.z,1);
|
||||
// nor=XMFLOAT4(0,0,0,1);
|
||||
// tex=XMFLOAT4(0,0,0,0);
|
||||
// pre=XMFLOAT4(0,0,0,0);
|
||||
// }
|
||||
// Vertex(const SkinnedVertex& copyFromSkinnedVert)
|
||||
// {
|
||||
// pos = copyFromSkinnedVert.pos;
|
||||
// nor = copyFromSkinnedVert.nor;
|
||||
// tex = copyFromSkinnedVert.tex;
|
||||
// pre = XMFLOAT4(0, 0, 0, 0);
|
||||
// }
|
||||
//};
|
||||
GFX_STRUCT Instance
|
||||
{
|
||||
XMFLOAT4A mat0;
|
||||
@@ -324,10 +324,59 @@ struct MeshSubset
|
||||
struct Mesh
|
||||
{
|
||||
public:
|
||||
struct Vertex_FULL
|
||||
{
|
||||
XMFLOAT4 pos; //pos, wind
|
||||
XMFLOAT4 nor; //normal, vertex ao
|
||||
XMFLOAT4 tex; //tex, matIndex, unused
|
||||
XMFLOAT4 ind; //bone indices
|
||||
XMFLOAT4 wei; //bone weights
|
||||
|
||||
Vertex_FULL(){
|
||||
pos=XMFLOAT4(0,0,0,0);
|
||||
nor=XMFLOAT4(0,0,0,1);
|
||||
tex=XMFLOAT4(0,0,0,0);
|
||||
ind=XMFLOAT4(0,0,0,0);
|
||||
wei=XMFLOAT4(0,0,0,0);
|
||||
};
|
||||
Vertex_FULL(const XMFLOAT3& newPos){
|
||||
pos=XMFLOAT4(newPos.x,newPos.y,newPos.z,1);
|
||||
nor=XMFLOAT4(0,0,0,1);
|
||||
tex=XMFLOAT4(0,0,0,0);
|
||||
ind=XMFLOAT4(0,0,0,0);
|
||||
wei=XMFLOAT4(0,0,0,0);
|
||||
}
|
||||
};
|
||||
struct Vertex_POS
|
||||
{
|
||||
XMFLOAT4 pos;
|
||||
};
|
||||
struct Vertex_NOR
|
||||
{
|
||||
XMFLOAT4 nor;
|
||||
};
|
||||
struct Vertex_TEX
|
||||
{
|
||||
XMFLOAT4 tex;
|
||||
};
|
||||
struct Vertex_BON
|
||||
{
|
||||
XMFLOAT4 ind;
|
||||
XMFLOAT4 wei;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::string parent;
|
||||
std::vector<XMFLOAT4> vertices_Transformed[VPROP_COUNT]; // for CPU skinning / soft body simulation
|
||||
std::vector<XMFLOAT4> vertices[VPROP_COUNT];
|
||||
//std::vector<XMFLOAT4> vertices_Transformed[VPROP_COUNT]; // for CPU skinning / soft body simulation
|
||||
//std::vector<XMFLOAT4> vertices[VPROP_COUNT];
|
||||
std::vector<Vertex_FULL> vertices_FULL;
|
||||
std::vector<Vertex_POS> vertices_POS; // position(xyz), wind(w)
|
||||
std::vector<Vertex_NOR> vertices_NOR; // normal
|
||||
std::vector<Vertex_TEX> vertices_TEX; // texcoords
|
||||
std::vector<Vertex_BON> vertices_BON; // bone indices, bone weights
|
||||
std::vector<Vertex_POS> vertices_Transformed_POS; // for soft body simulation
|
||||
std::vector<Vertex_NOR> vertices_Transformed_NOR; // for soft body simulation
|
||||
std::vector<Vertex_POS> vertices_Transformed_PRE; // for soft body simulation
|
||||
std::vector<unsigned int> indices;
|
||||
std::vector<XMFLOAT3> physicsverts;
|
||||
std::vector<unsigned int> physicsindices;
|
||||
@@ -335,8 +384,15 @@ public:
|
||||
std::vector<MeshSubset> subsets;
|
||||
std::vector<std::string> materialNames;
|
||||
|
||||
wiGraphicsTypes::GPUBuffer vertexBuffers[VPROP_COUNT];
|
||||
wiGraphicsTypes::GPUBuffer streamoutBuffers[VPROP_COUNT]; // omit texcoord, omit weights, change boneindices to posprev
|
||||
//wiGraphicsTypes::GPUBuffer vertexBuffers[VPROP_COUNT];
|
||||
//wiGraphicsTypes::GPUBuffer streamoutBuffers[VPROP_COUNT]; // omit texcoord, omit weights, change boneindices to posprev
|
||||
wiGraphicsTypes::GPUBuffer vertexBuffer_POS;
|
||||
wiGraphicsTypes::GPUBuffer vertexBuffer_NOR;
|
||||
wiGraphicsTypes::GPUBuffer vertexBuffer_TEX;
|
||||
wiGraphicsTypes::GPUBuffer vertexBuffer_BON;
|
||||
wiGraphicsTypes::GPUBuffer streamoutBuffer_POS;
|
||||
wiGraphicsTypes::GPUBuffer streamoutBuffer_NOR;
|
||||
wiGraphicsTypes::GPUBuffer streamoutBuffer_PRE;
|
||||
wiGraphicsTypes::GPUBuffer instanceBuffer;
|
||||
wiGraphicsTypes::GPUBuffer instanceBufferPrev;
|
||||
|
||||
@@ -363,7 +419,10 @@ public:
|
||||
|
||||
wiRenderTarget impostorTarget;
|
||||
float impostorDistance;
|
||||
static wiGraphicsTypes::GPUBuffer impostorVBs[VPROP_COUNT]; // omit weights, omit posprev
|
||||
//static wiGraphicsTypes::GPUBuffer impostorVBs[VPROP_COUNT]; // omit weights, omit posprev
|
||||
static wiGraphicsTypes::GPUBuffer impostorVB_POS;
|
||||
static wiGraphicsTypes::GPUBuffer impostorVB_NOR;
|
||||
static wiGraphicsTypes::GPUBuffer impostorVB_TEX;
|
||||
|
||||
float tessellationFactor;
|
||||
|
||||
|
||||
+50
-52
@@ -1480,24 +1480,24 @@ Light* wiRenderer::getLightByName(const std::string& name)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vertex wiRenderer::TransformVertex(const Mesh* mesh, int vertexI, const XMMATRIX& mat)
|
||||
Mesh::Vertex_FULL wiRenderer::TransformVertex(const Mesh* mesh, int vertexI, const XMMATRIX& mat)
|
||||
{
|
||||
XMMATRIX sump;
|
||||
XMVECTOR pos = XMLoadFloat4(&mesh->vertices[VPROP_POS][vertexI]);
|
||||
XMVECTOR nor = XMLoadFloat4(&mesh->vertices[VPROP_NOR][vertexI]);
|
||||
XMVECTOR pos = XMLoadFloat4(&mesh->vertices_POS[vertexI].pos);
|
||||
XMVECTOR nor = XMLoadFloat4(&mesh->vertices_NOR[vertexI].nor);
|
||||
|
||||
if (mesh->hasArmature() && !mesh->armature->boneCollection.empty())
|
||||
{
|
||||
float inWei[4] = {
|
||||
mesh->vertices[VPROP_WEI][vertexI].x
|
||||
, mesh->vertices[VPROP_WEI][vertexI].y
|
||||
, mesh->vertices[VPROP_WEI][vertexI].z
|
||||
, mesh->vertices[VPROP_WEI][vertexI].w };
|
||||
mesh->vertices_BON[vertexI].wei.x,
|
||||
mesh->vertices_BON[vertexI].wei.y,
|
||||
mesh->vertices_BON[vertexI].wei.z,
|
||||
mesh->vertices_BON[vertexI].wei.w };
|
||||
float inBon[4] = {
|
||||
mesh->vertices[VPROP_BON][vertexI].x
|
||||
, mesh->vertices[VPROP_BON][vertexI].y
|
||||
, mesh->vertices[VPROP_BON][vertexI].z
|
||||
, mesh->vertices[VPROP_BON][vertexI].w };
|
||||
mesh->vertices_BON[vertexI].ind.x,
|
||||
mesh->vertices_BON[vertexI].ind.y,
|
||||
mesh->vertices_BON[vertexI].ind.z,
|
||||
mesh->vertices_BON[vertexI].ind.w };
|
||||
if (inWei[0] || inWei[1] || inWei[2] || inWei[3])
|
||||
{
|
||||
sump = XMMATRIX(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
@@ -1522,10 +1522,9 @@ Vertex wiRenderer::TransformVertex(const Mesh* mesh, int vertexI, const XMMATRIX
|
||||
|
||||
XMStoreFloat3(&transformedN, XMVector3Normalize(XMVector3TransformNormal(nor, sump)));
|
||||
|
||||
Vertex retV(transformedP);
|
||||
Mesh::Vertex_FULL retV(transformedP);
|
||||
retV.nor = XMFLOAT4(transformedN.x, transformedN.y, transformedN.z, retV.nor.w);
|
||||
retV.tex = mesh->vertices[VPROP_TEX][vertexI];
|
||||
retV.pre = XMFLOAT4(0, 0, 0, 1);
|
||||
retV.tex = mesh->vertices_TEX[vertexI].tex;
|
||||
|
||||
return retV;
|
||||
}
|
||||
@@ -1787,8 +1786,8 @@ void wiRenderer::UpdateRenderData(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
Mesh* mesh = iter->second;
|
||||
|
||||
if (mesh->hasArmature() && !mesh->softBody && mesh->renderable && !mesh->vertices[VPROP_POS].empty()
|
||||
&& mesh->streamoutBuffers[VPROP_POS].IsValid() && mesh->vertexBuffers[VPROP_POS].IsValid())
|
||||
if (mesh->hasArmature() && !mesh->softBody && mesh->renderable && !mesh->vertices_POS.empty()
|
||||
&& mesh->streamoutBuffer_POS.IsValid() && mesh->vertexBuffer_POS.IsValid())
|
||||
{
|
||||
Armature* armature = mesh->armature;
|
||||
|
||||
@@ -1818,30 +1817,29 @@ void wiRenderer::UpdateRenderData(GRAPHICSTHREAD threadID)
|
||||
|
||||
// Do the skinning
|
||||
const GPUResource* vbs[] = {
|
||||
static_cast<const GPUResource*>(&mesh->vertexBuffers[VPROP_POS]),
|
||||
static_cast<const GPUResource*>(&mesh->vertexBuffers[VPROP_NOR]),
|
||||
static_cast<const GPUResource*>(&mesh->vertexBuffers[VPROP_WEI]),
|
||||
static_cast<const GPUResource*>(&mesh->vertexBuffers[VPROP_BON]),
|
||||
static_cast<const GPUResource*>(&mesh->vertexBuffer_POS),
|
||||
static_cast<const GPUResource*>(&mesh->vertexBuffer_NOR),
|
||||
static_cast<const GPUResource*>(&mesh->vertexBuffer_BON),
|
||||
};
|
||||
const GPUUnorderedResource* sos[] = {
|
||||
static_cast<const GPUUnorderedResource*>(&mesh->streamoutBuffers[VPROP_POS]),
|
||||
static_cast<const GPUUnorderedResource*>(&mesh->streamoutBuffers[VPROP_NOR]),
|
||||
static_cast<const GPUUnorderedResource*>(&mesh->streamoutBuffers[VPROP_PRE]),
|
||||
static_cast<const GPUUnorderedResource*>(&mesh->streamoutBuffer_POS),
|
||||
static_cast<const GPUUnorderedResource*>(&mesh->streamoutBuffer_NOR),
|
||||
static_cast<const GPUUnorderedResource*>(&mesh->streamoutBuffer_PRE),
|
||||
};
|
||||
|
||||
GetDevice()->BindResourcesCS(vbs, SKINNINGSLOT_IN_VERTEX_POS, ARRAYSIZE(vbs), threadID);
|
||||
GetDevice()->BindUnorderedAccessResourcesCS(sos, 0, ARRAYSIZE(sos), threadID);
|
||||
|
||||
GetDevice()->Dispatch((UINT)ceilf((float)mesh->vertices[VPROP_POS].size() / SKINNING_COMPUTE_THREADCOUNT), 1, 1, threadID);
|
||||
GetDevice()->Dispatch((UINT)ceilf((float)mesh->vertices_POS.size() / SKINNING_COMPUTE_THREADCOUNT), 1, 1, threadID);
|
||||
|
||||
}
|
||||
|
||||
// Upload CPU skinned vertex buffer (Soft body VB)
|
||||
if (mesh->softBody)
|
||||
{
|
||||
GetDevice()->UpdateBuffer(&mesh->vertexBuffers[VPROP_POS], mesh->vertices_Transformed[VPROP_POS].data(), threadID, (int)(sizeof(XMFLOAT4)*mesh->vertices_Transformed[VPROP_POS].size()));
|
||||
GetDevice()->UpdateBuffer(&mesh->vertexBuffers[VPROP_NOR], mesh->vertices_Transformed[VPROP_NOR].data(), threadID, (int)(sizeof(XMFLOAT4)*mesh->vertices_Transformed[VPROP_NOR].size()));
|
||||
GetDevice()->UpdateBuffer(&mesh->vertexBuffers[VPROP_PRE], mesh->vertices_Transformed[VPROP_PRE].data(), threadID, (int)(sizeof(XMFLOAT4)*mesh->vertices_Transformed[VPROP_PRE].size()));
|
||||
GetDevice()->UpdateBuffer(&mesh->vertexBuffer_POS, mesh->vertices_Transformed_POS.data(), threadID, (int)(sizeof(XMFLOAT4)*mesh->vertices_Transformed_POS.size()));
|
||||
GetDevice()->UpdateBuffer(&mesh->vertexBuffer_NOR, mesh->vertices_Transformed_NOR.data(), threadID, (int)(sizeof(XMFLOAT4)*mesh->vertices_Transformed_NOR.size()));
|
||||
GetDevice()->UpdateBuffer(&mesh->streamoutBuffer_PRE, mesh->vertices_Transformed_PRE.data(), threadID, (int)(sizeof(XMFLOAT4)*mesh->vertices_Transformed_PRE.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2653,7 +2651,7 @@ void wiRenderer::DrawDebugEmitters(Camera* camera, GRAPHICSTHREAD threadID)
|
||||
for (auto& y : x->object->mesh->subsets)
|
||||
{
|
||||
const GPUBuffer* vbs[] = {
|
||||
&x->object->mesh->vertexBuffers[VPROP_POS],
|
||||
&x->object->mesh->vertexBuffer_POS,
|
||||
};
|
||||
const UINT strides[] = {
|
||||
sizeof(XMFLOAT4),
|
||||
@@ -3968,8 +3966,8 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
if (realVL == VLTYPE_OBJECT_POS_TEX)
|
||||
{
|
||||
GPUBuffer* vbs[] = {
|
||||
&Mesh::impostorVBs[VPROP_POS],
|
||||
&Mesh::impostorVBs[VPROP_TEX],
|
||||
&Mesh::impostorVB_POS,
|
||||
&Mesh::impostorVB_TEX,
|
||||
&mesh->instanceBuffer
|
||||
};
|
||||
UINT strides[] = {
|
||||
@@ -3982,10 +3980,10 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
else
|
||||
{
|
||||
GPUBuffer* vbs[] = {
|
||||
&Mesh::impostorVBs[VPROP_POS],
|
||||
&Mesh::impostorVBs[VPROP_NOR],
|
||||
&Mesh::impostorVBs[VPROP_TEX],
|
||||
&Mesh::impostorVBs[VPROP_POS],
|
||||
&Mesh::impostorVB_POS,
|
||||
&Mesh::impostorVB_NOR,
|
||||
&Mesh::impostorVB_TEX,
|
||||
&Mesh::impostorVB_POS,
|
||||
&mesh->instanceBuffer,
|
||||
&mesh->instanceBufferPrev,
|
||||
};
|
||||
@@ -4209,7 +4207,7 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
case BOUNDVERTEXBUFFERTYPE::POSITION:
|
||||
{
|
||||
GPUBuffer* vbs[] = {
|
||||
(mesh->streamoutBuffers[VPROP_POS].IsValid() ? &mesh->streamoutBuffers[VPROP_POS] : &mesh->vertexBuffers[VPROP_POS]),
|
||||
(mesh->streamoutBuffer_POS.IsValid() ? &mesh->streamoutBuffer_POS : &mesh->vertexBuffer_POS),
|
||||
&mesh->instanceBuffer
|
||||
};
|
||||
UINT strides[] = {
|
||||
@@ -4222,8 +4220,8 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
case BOUNDVERTEXBUFFERTYPE::POSITION_TEXCOORD:
|
||||
{
|
||||
GPUBuffer* vbs[] = {
|
||||
(mesh->streamoutBuffers[VPROP_POS].IsValid() ? &mesh->streamoutBuffers[VPROP_POS] : &mesh->vertexBuffers[VPROP_POS]),
|
||||
&mesh->vertexBuffers[VPROP_TEX],
|
||||
(mesh->streamoutBuffer_POS.IsValid() ? &mesh->streamoutBuffer_POS : &mesh->vertexBuffer_POS),
|
||||
&mesh->vertexBuffer_TEX,
|
||||
&mesh->instanceBuffer
|
||||
};
|
||||
UINT strides[] = {
|
||||
@@ -4237,10 +4235,10 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
case BOUNDVERTEXBUFFERTYPE::EVERYTHING:
|
||||
{
|
||||
GPUBuffer* vbs[] = {
|
||||
(mesh->streamoutBuffers[VPROP_POS].IsValid() ? &mesh->streamoutBuffers[VPROP_POS] : &mesh->vertexBuffers[VPROP_POS]),
|
||||
(mesh->streamoutBuffers[VPROP_NOR].IsValid() ? &mesh->streamoutBuffers[VPROP_NOR] : &mesh->vertexBuffers[VPROP_NOR]),
|
||||
&mesh->vertexBuffers[VPROP_TEX],
|
||||
(mesh->streamoutBuffers[VPROP_PRE].IsValid() ? &mesh->streamoutBuffers[VPROP_PRE] : &mesh->vertexBuffers[mesh->softBody ? VPROP_PRE : VPROP_POS]), // this is getting out of hand!
|
||||
(mesh->streamoutBuffer_POS.IsValid() ? &mesh->streamoutBuffer_POS : &mesh->vertexBuffer_POS),
|
||||
(mesh->streamoutBuffer_NOR.IsValid() ? &mesh->streamoutBuffer_NOR : &mesh->vertexBuffer_NOR),
|
||||
&mesh->vertexBuffer_TEX,
|
||||
(mesh->streamoutBuffer_PRE.IsValid() ? &mesh->streamoutBuffer_PRE : &mesh->vertexBuffer_POS),
|
||||
&mesh->instanceBuffer,
|
||||
&mesh->instanceBufferPrev,
|
||||
};
|
||||
@@ -5703,11 +5701,11 @@ void wiRenderer::RayIntersectMeshes(const RAY& ray, const CulledList& culledObje
|
||||
}
|
||||
|
||||
Mesh* mesh = object->mesh;
|
||||
if (mesh->vertices[VPROP_POS].size() >= _arraySize)
|
||||
if (mesh->vertices_POS.size() >= _arraySize)
|
||||
{
|
||||
// grow preallocated vector helper array
|
||||
_mm_free(_vertices);
|
||||
_arraySize = (mesh->vertices[VPROP_POS].size() + 1) * 2;
|
||||
_arraySize = (mesh->vertices_POS.size() + 1) * 2;
|
||||
_vertices = (XMVECTOR*)_mm_malloc(sizeof(XMVECTOR)*_arraySize, 16);
|
||||
}
|
||||
|
||||
@@ -5717,8 +5715,8 @@ void wiRenderer::RayIntersectMeshes(const RAY& ray, const CulledList& culledObje
|
||||
XMVECTOR& rayOrigin_local = XMVector3Transform(rayOrigin, objectMat_Inverse);
|
||||
XMVECTOR& rayDirection_local = XMVector3Normalize(XMVector3TransformNormal(rayDirection, objectMat_Inverse));
|
||||
|
||||
Vertex _tmpvert;
|
||||
for (size_t i = 0; i < mesh->vertices[VPROP_POS].size(); ++i)
|
||||
Mesh::Vertex_FULL _tmpvert;
|
||||
for (size_t i = 0; i < mesh->vertices_POS.size(); ++i)
|
||||
{
|
||||
if (object->isArmatureDeformed() && !object->mesh->armature->boneCollection.empty())
|
||||
{
|
||||
@@ -5727,7 +5725,7 @@ void wiRenderer::RayIntersectMeshes(const RAY& ray, const CulledList& culledObje
|
||||
}
|
||||
else
|
||||
{
|
||||
_vertices[i] = XMLoadFloat4(&mesh->vertices[VPROP_POS][i]);
|
||||
_vertices[i] = XMLoadFloat4(&mesh->vertices_POS[i].pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5748,7 +5746,7 @@ void wiRenderer::RayIntersectMeshes(const RAY& ray, const CulledList& culledObje
|
||||
XMStoreFloat3(&picked.position, pos);
|
||||
XMStoreFloat3(&picked.normal, nor);
|
||||
picked.distance = wiMath::Distance(pos, rayOrigin);
|
||||
picked.subsetIndex = (int)mesh->vertices[VPROP_TEX][i0].z;
|
||||
picked.subsetIndex = (int)mesh->vertices_TEX[i0].tex.z;
|
||||
points.push_back(picked);
|
||||
}
|
||||
}
|
||||
@@ -5919,7 +5917,7 @@ void wiRenderer::SynchronizeWithPhysicsEngine(float dt)
|
||||
for (std::map<int, float>::iterator it = mesh->vertexGroups[gvg].vertices.begin(); it != mesh->vertexGroups[gvg].vertices.end(); ++it)
|
||||
{
|
||||
int vi = (*it).first;
|
||||
Vertex tvert = TransformVertex(mesh, vi, worldMat);
|
||||
Mesh::Vertex_FULL tvert = TransformVertex(mesh, vi, worldMat);
|
||||
mesh->goalPositions[j] = XMFLOAT3(tvert.pos.x, tvert.pos.y, tvert.pos.z);
|
||||
mesh->goalNormals[j] = XMFLOAT3(tvert.nor.x, tvert.nor.y, tvert.nor.z);
|
||||
++j;
|
||||
@@ -6001,10 +5999,10 @@ void wiRenderer::CreateImpostor(Mesh* mesh)
|
||||
mesh->UpdateRenderableInstances(1, threadID);
|
||||
|
||||
GPUBuffer* vbs[] = {
|
||||
(mesh->streamoutBuffers[VPROP_POS].IsValid() ? &mesh->streamoutBuffers[VPROP_POS] : &mesh->vertexBuffers[VPROP_POS]),
|
||||
(mesh->streamoutBuffers[VPROP_NOR].IsValid() ? &mesh->streamoutBuffers[VPROP_NOR] : &mesh->vertexBuffers[VPROP_NOR]),
|
||||
&mesh->vertexBuffers[VPROP_TEX],
|
||||
(mesh->streamoutBuffers[VPROP_PRE].IsValid() ? &mesh->streamoutBuffers[VPROP_PRE] : &mesh->vertexBuffers[VPROP_POS]),
|
||||
(mesh->streamoutBuffer_POS.IsValid() ? &mesh->streamoutBuffer_POS : &mesh->vertexBuffer_POS),
|
||||
(mesh->streamoutBuffer_NOR.IsValid() ? &mesh->streamoutBuffer_NOR : &mesh->vertexBuffer_NOR),
|
||||
&mesh->vertexBuffer_TEX,
|
||||
(mesh->streamoutBuffer_PRE.IsValid() ? &mesh->streamoutBuffer_PRE : &mesh->vertexBuffer_POS),
|
||||
&mesh->instanceBuffer
|
||||
};
|
||||
UINT strides[] = {
|
||||
|
||||
@@ -401,7 +401,7 @@ public:
|
||||
static void ReloadShaders(const std::string& path = "");
|
||||
static void BindPersistentState(GRAPHICSTHREAD threadID);
|
||||
|
||||
static Vertex TransformVertex(const Mesh* mesh, int vertexI, const XMMATRIX& mat = XMMatrixIdentity());
|
||||
static Mesh::Vertex_FULL TransformVertex(const Mesh* mesh, int vertexI, const XMMATRIX& mat = XMMatrixIdentity());
|
||||
|
||||
struct FrameCulling
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 13;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 5;
|
||||
const int revision = 6;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Reference in New Issue
Block a user