refactored and optimized main vertex streams;
fixed envmap rendering bug;
This commit is contained in:
@@ -8,7 +8,7 @@ VSOut main(Input_Object_ALL input)
|
||||
|
||||
float4x4 WORLD = MakeWorldMatrixFromInstance(input.instance);
|
||||
Out.pos = mul(float4(input.pos.xyz, 1), WORLD);
|
||||
Out.nor = normalize(mul(normalize(input.nor.xyz), (float3x3)WORLD));
|
||||
Out.nor = normalize(mul(normalize(input.nor.xyz * 2 - 1), (float3x3)WORLD));
|
||||
Out.tex = input.tex.xy;
|
||||
Out.instanceColor = input.instance.color_dither.rgb;
|
||||
Out.ao = input.nor.w;
|
||||
|
||||
@@ -22,7 +22,7 @@ PixelInputType main(Input_Object_ALL input)
|
||||
|
||||
Out.clip = dot(pos, g_xClipPlane);
|
||||
|
||||
float3 normal = mul(input.nor.xyz, (float3x3)WORLD);
|
||||
float3 normal = mul(input.nor.xyz * 2 - 1, (float3x3)WORLD);
|
||||
affectWind(pos.xyz, input.pos.w, g_xFrame_Time);
|
||||
affectWind(posPrev.xyz, input.pos.w, g_xFrame_TimePrev);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ HullInputType main(Input_Object_ALL input)
|
||||
posPrev = mul(posPrev, WORLDPREV);
|
||||
|
||||
|
||||
float3 normal = mul(normalize(input.nor.xyz), (float3x3)WORLD);
|
||||
float3 normal = mul(normalize(input.nor.xyz * 2 - 1), (float3x3)WORLD);
|
||||
affectWind(pos.xyz, input.pos.w, g_xFrame_Time);
|
||||
affectWind(posPrev.xyz,input.pos.w, g_xFrame_TimePrev);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ HullInputType main(Input_Object_ALL input)
|
||||
pos = mul(pos, WORLD);
|
||||
affectWind(pos.xyz, input.pos.w, g_xFrame_Time);
|
||||
|
||||
float3 normal = mul(normalize(input.nor.xyz), (float3x3)WORLD);
|
||||
float3 normal = mul(normalize(input.nor.xyz * 2 - 1), (float3x3)WORLD);
|
||||
|
||||
Out.pos = pos.xyz;
|
||||
Out.tex = input.tex.xyz;
|
||||
|
||||
@@ -15,7 +15,7 @@ VSOut main(Input_Object_ALL input, uint instanceID : SV_INSTANCEID)
|
||||
float4x4 WORLD = MakeWorldMatrixFromInstance(input.instance);
|
||||
|
||||
Out.pos = mul(float4(input.pos.xyz, 1), WORLD);
|
||||
Out.nor = normalize(mul(input.nor.xyz, (float3x3)WORLD));
|
||||
Out.nor = normalize(mul(input.nor.xyz * 2 - 1, (float3x3)WORLD));
|
||||
Out.tex = input.tex.xy;
|
||||
Out.instanceColor = input.instance.color_dither.rgb;
|
||||
|
||||
|
||||
@@ -41,15 +41,15 @@ inline void Skinning(inout float4 pos, inout float4 nor, in float4 inBon, in flo
|
||||
|
||||
bool w = any(inWei);
|
||||
pos.xyz = w ? p.xyz : pos.xyz;
|
||||
nor.xyz = w ? n : nor.xyz;
|
||||
nor.xyz = w ? normalize(n) : nor.xyz;
|
||||
}
|
||||
|
||||
|
||||
[numthreads(SKINNING_COMPUTE_THREADCOUNT, 1, 1)]
|
||||
void main( uint3 DTid : SV_DispatchThreadID )
|
||||
void main(uint3 DTid : SV_DispatchThreadID)
|
||||
{
|
||||
const uint stride_POS = 16;
|
||||
const uint stride_NOR = 16;
|
||||
const uint stride_POS = 8;
|
||||
const uint stride_NOR = 4;
|
||||
const uint stride_BON_IND = 4;
|
||||
const uint stride_BON_WEI = 4;
|
||||
|
||||
@@ -57,33 +57,70 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||
const uint fetchAddress_NOR = DTid.x * stride_NOR;
|
||||
const uint fetchAddress_BON = DTid.x * (stride_BON_IND + stride_BON_WEI);
|
||||
|
||||
uint4 pos_u = vertexBuffer_POS.Load4(fetchAddress_POS);
|
||||
uint4 nor_u = vertexBuffer_NOR.Load4(fetchAddress_NOR);
|
||||
uint2 pos_u = vertexBuffer_POS.Load2(fetchAddress_POS);
|
||||
uint nor_u = vertexBuffer_NOR.Load(fetchAddress_NOR);
|
||||
uint2 ind_wei_u = vertexBuffer_BON.Load2(fetchAddress_BON);
|
||||
|
||||
float4 pos = asfloat(pos_u);
|
||||
float4 nor = asfloat(nor_u);
|
||||
// Manual type-conversion for pos:
|
||||
float4 pos = 0;
|
||||
{
|
||||
pos.x = f16tof32((pos_u.x & 0x0000FFFF) >> 0);
|
||||
pos.y = f16tof32((pos_u.x & 0xFFFF0000) >> 16);
|
||||
pos.z = f16tof32((pos_u.y & 0x0000FFFF) >> 0);
|
||||
pos.w = f16tof32((pos_u.y & 0xFFFF0000) >> 16);
|
||||
}
|
||||
|
||||
// Unpack bone props:
|
||||
|
||||
// Manual type-conversion for normal:
|
||||
float4 nor = 0;
|
||||
{
|
||||
nor.x = (float)((nor_u >> 0) & 0x000000FF) / 255.0f * 2.0f - 1.0f;
|
||||
nor.y = (float)((nor_u >> 8) & 0x000000FF) / 255.0f * 2.0f - 1.0f;
|
||||
nor.z = (float)((nor_u >> 16) & 0x000000FF) / 255.0f * 2.0f - 1.0f;
|
||||
}
|
||||
|
||||
|
||||
// Manual type-conversion for bone props:
|
||||
float4 ind = 0;
|
||||
float4 wei = 0;
|
||||
{
|
||||
ind.x = (float)((ind_wei_u.x >> 0) & 0x000000FF);
|
||||
ind.y = (float)((ind_wei_u.x >> 8) & 0x000000FF);
|
||||
ind.z = (float)((ind_wei_u.x >> 16) & 0x000000FF);
|
||||
ind.w = (float)((ind_wei_u.x >> 24) & 0x000000FF);
|
||||
|
||||
ind.x = (float)((ind_wei_u.x >> 0) & 0x000000FF);
|
||||
ind.y = (float)((ind_wei_u.x >> 8) & 0x000000FF);
|
||||
ind.z = (float)((ind_wei_u.x >> 16) & 0x000000FF);
|
||||
ind.w = (float)((ind_wei_u.x >> 24) & 0x000000FF);
|
||||
wei.x = (float)((ind_wei_u.y >> 0) & 0x000000FF) / 255.0f;
|
||||
wei.y = (float)((ind_wei_u.y >> 8) & 0x000000FF) / 255.0f;
|
||||
wei.z = (float)((ind_wei_u.y >> 16) & 0x000000FF) / 255.0f;
|
||||
wei.w = (float)((ind_wei_u.y >> 24) & 0x000000FF) / 255.0f;
|
||||
}
|
||||
|
||||
wei.x = (float)((ind_wei_u.y >> 0) & 0x000000FF) / 255.0f;
|
||||
wei.y = (float)((ind_wei_u.y >> 8) & 0x000000FF) / 255.0f;
|
||||
wei.z = (float)((ind_wei_u.y >> 16) & 0x000000FF) / 255.0f;
|
||||
wei.w = (float)((ind_wei_u.y >> 24) & 0x000000FF) / 255.0f;
|
||||
|
||||
// Perform skinning:
|
||||
Skinning(pos, nor, ind, wei);
|
||||
|
||||
pos_u = asuint(pos);
|
||||
nor_u = asuint(nor);
|
||||
|
||||
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);
|
||||
|
||||
// Manual type-conversion for pos:
|
||||
pos_u = 0;
|
||||
{
|
||||
pos_u.x |= f32tof16(pos.x) << 0;
|
||||
pos_u.x |= f32tof16(pos.y) << 16;
|
||||
pos_u.y |= f32tof16(pos.z) << 0;
|
||||
pos_u.y |= f32tof16(pos.w) << 16;
|
||||
}
|
||||
|
||||
|
||||
// Manual type-conversion for normal:
|
||||
nor_u = 0;
|
||||
{
|
||||
nor_u |= (uint)((nor.x * 0.5f + 0.5f) * 255.0f) << 0;
|
||||
nor_u |= (uint)((nor.y * 0.5f + 0.5f) * 255.0f) << 8;
|
||||
nor_u |= (uint)((nor.z * 0.5f + 0.5f) * 255.0f) << 16;
|
||||
}
|
||||
|
||||
|
||||
streamoutBuffer_PRE.Store2(fetchAddress_POS, streamoutBuffer_POS.Load2(fetchAddress_POS)); // copy prev frame current pos to current frame prev pos
|
||||
streamoutBuffer_POS.Store2(fetchAddress_POS, pos_u);
|
||||
streamoutBuffer_NOR.Store(fetchAddress_NOR, nor_u);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ PixelInputType main(Input_Object_ALL input)
|
||||
Out.pos = Out.pos2D = mul(pos, g_xCamera_VP);
|
||||
Out.pos3D = pos.xyz;
|
||||
Out.tex = input.tex.xy;
|
||||
Out.nor = mul(input.nor.xyz, (float3x3)WORLD);
|
||||
Out.nor = mul(input.nor.xyz * 2 - 1, (float3x3)WORLD);
|
||||
Out.nor = normalize(Out.nor);
|
||||
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_VP).xy;
|
||||
|
||||
|
||||
@@ -592,10 +592,8 @@ void wiBULLET::connectVerticesToSoftBody(Mesh* const mesh, int objectI){
|
||||
int indexP = mesh->physicalmapGP[i];
|
||||
float weight = mesh->vertexGroups[gvg].vertices[indexP];
|
||||
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();
|
||||
mesh->vertices_Transformed_POS[i].pos = XMHALF4(nodes[indexP].m_x.getX(), nodes[indexP].m_x.getY(), nodes[indexP].m_x.getZ(), (float)mesh->vertices_POS[i].pos.w);
|
||||
mesh->vertices_Transformed_NOR[i].FromFLOAT(XMFLOAT3(-nodes[indexP].m_n.getX(), -nodes[indexP].m_n.getY(), -nodes[indexP].m_n.getZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -704,7 +702,10 @@ void wiBULLET::registerObject(Object* object){
|
||||
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;
|
||||
pos_stream[i].x = object->mesh->vertices_POS[i].pos.x;
|
||||
pos_stream[i].y = object->mesh->vertices_POS[i].pos.y;
|
||||
pos_stream[i].z = object->mesh->vertices_POS[i].pos.z;
|
||||
pos_stream[i].w = object->mesh->vertices_POS[i].pos.w;
|
||||
}
|
||||
|
||||
addConvexHull(
|
||||
@@ -719,7 +720,10 @@ void wiBULLET::registerObject(Object* object){
|
||||
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;
|
||||
pos_stream[i].x = object->mesh->vertices_POS[i].pos.x;
|
||||
pos_stream[i].y = object->mesh->vertices_POS[i].pos.y;
|
||||
pos_stream[i].z = object->mesh->vertices_POS[i].pos.z;
|
||||
pos_stream[i].w = object->mesh->vertices_POS[i].pos.w;
|
||||
}
|
||||
|
||||
addTriangleMesh(
|
||||
|
||||
@@ -79,7 +79,8 @@ void wiDepthTarget::InitializeCube(int size, bool independentFaces)
|
||||
|
||||
void wiDepthTarget::Clear(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::GetDevice()->ClearDepthStencil(GetTexture(), CLEAR_DEPTH | CLEAR_STENCIL, 0.0f, 0, threadID);
|
||||
float depthClear = GetDesc().MiscFlags & RESOURCE_MISC_TEXTURECUBE ? 1.0f : 0.0f;
|
||||
wiRenderer::GetDevice()->ClearDepthStencil(GetTexture(), CLEAR_DEPTH | CLEAR_STENCIL, depthClear, 0, threadID);
|
||||
resolvedMSAAUptodate = false;
|
||||
}
|
||||
void wiDepthTarget::CopyFrom(const wiDepthTarget& from, GRAPHICSTHREAD threadID)
|
||||
|
||||
@@ -144,16 +144,16 @@ void wiEmittedParticle::addPoint(const XMMATRIX& t4, const XMMATRIX& t3)
|
||||
XMFLOAT3 pos;
|
||||
XMFLOAT3 vel;
|
||||
XMVECTOR& vbar=XMVectorBaryCentric(
|
||||
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)
|
||||
XMLoadHalf4(&object->mesh->vertices_POS[object->mesh->indices[gen[0]]].pos)
|
||||
, XMLoadHalf4(&object->mesh->vertices_POS[object->mesh->indices[gen[1]]].pos)
|
||||
, XMLoadHalf4(&object->mesh->vertices_POS[object->mesh->indices[gen[2]]].pos)
|
||||
, f
|
||||
, g
|
||||
);
|
||||
XMVECTOR& nbar=XMVectorBaryCentric(
|
||||
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)
|
||||
XMLoadFloat4(&object->mesh->vertices_NOR[object->mesh->indices[gen[0]]].GetNor_FULL())
|
||||
, XMLoadFloat4(&object->mesh->vertices_NOR[object->mesh->indices[gen[1]]].GetNor_FULL())
|
||||
, XMLoadFloat4(&object->mesh->vertices_NOR[object->mesh->indices[gen[2]]].GetNor_FULL())
|
||||
, f
|
||||
, g
|
||||
);
|
||||
|
||||
@@ -302,6 +302,7 @@ enum DSSTYPES
|
||||
DSSTYPE_STENCILREAD_MATCH,
|
||||
DSSTYPE_DEPTHREADEQUAL,
|
||||
DSSTYPE_HAIRALPHACOMPOSITION,
|
||||
DSSTYPE_ENVMAP,
|
||||
DSSTYPE_LAST
|
||||
};
|
||||
// blend states
|
||||
|
||||
@@ -2316,6 +2316,13 @@ void Mesh::CreateVertexArrays()
|
||||
vertices_BON.resize(vertices_FULL.size());
|
||||
for (size_t i = 0; i < vertices_FULL.size(); ++i)
|
||||
{
|
||||
// Normalize normals:
|
||||
float alpha = vertices_FULL[i].nor.w;
|
||||
XMVECTOR nor = XMLoadFloat4(&vertices_FULL[i].nor);
|
||||
nor = XMVector3Normalize(nor);
|
||||
XMStoreFloat4(&vertices_FULL[i].nor, nor);
|
||||
vertices_FULL[i].nor.w = alpha;
|
||||
|
||||
// Normalize bone weights:
|
||||
XMFLOAT4& wei = vertices_FULL[i].wei;
|
||||
float len = wei.x + wei.y + wei.z + wei.w;
|
||||
@@ -2327,11 +2334,11 @@ void Mesh::CreateVertexArrays()
|
||||
wei.w /= len;
|
||||
}
|
||||
|
||||
// Split and convert props:
|
||||
vertices_POS[i].pos = vertices_FULL[i].pos;
|
||||
vertices_NOR[i].nor = vertices_FULL[i].nor;
|
||||
vertices_TEX[i].tex = vertices_FULL[i].tex;
|
||||
vertices_BON[i] = Vertex_BON(vertices_FULL[i].ind, vertices_FULL[i].wei);
|
||||
// Split and type conversion:
|
||||
vertices_POS[i] = Vertex_POS(vertices_FULL[i]);
|
||||
vertices_NOR[i] = Vertex_NOR(vertices_FULL[i]);
|
||||
vertices_TEX[i] = Vertex_TEX(vertices_FULL[i]);
|
||||
vertices_BON[i] = Vertex_BON(vertices_FULL[i]);
|
||||
}
|
||||
|
||||
// Save original vertices. This will be input for CPU skinning / soft bodies
|
||||
|
||||
+63
-15
@@ -237,8 +237,6 @@ struct VertexRef{
|
||||
};
|
||||
struct VertexGroup{
|
||||
std::string name;
|
||||
//std::vector<VertexRef> vertices;
|
||||
//index,weight
|
||||
std::map<int,float> vertices;
|
||||
VertexGroup(){name="";}
|
||||
VertexGroup(const std::string& n){name=n;}
|
||||
@@ -287,15 +285,66 @@ public:
|
||||
};
|
||||
struct Vertex_POS
|
||||
{
|
||||
XMFLOAT4 pos;
|
||||
XMHALF4 pos;
|
||||
|
||||
Vertex_POS() :pos(XMHALF4(0.0f, 0.0f, 0.0f, 0.0f)) {}
|
||||
Vertex_POS(const Vertex_FULL& vert)
|
||||
{
|
||||
pos = XMHALF4(vert.pos.x, vert.pos.y, vert.pos.z, vert.pos.w);
|
||||
}
|
||||
|
||||
static const wiGraphicsTypes::FORMAT FORMAT = wiGraphicsTypes::FORMAT::FORMAT_R16G16B16A16_FLOAT;
|
||||
};
|
||||
struct Vertex_NOR
|
||||
{
|
||||
XMFLOAT4 nor;
|
||||
uint32_t nor;
|
||||
|
||||
Vertex_NOR() :nor(0) {}
|
||||
Vertex_NOR(const Vertex_FULL& vert)
|
||||
{
|
||||
nor = 0;
|
||||
|
||||
nor |= (uint8_t)((vert.nor.x * 0.5f + 0.5f) * 255.0f) << 0;
|
||||
nor |= (uint8_t)((vert.nor.y * 0.5f + 0.5f) * 255.0f) << 8;
|
||||
nor |= (uint8_t)((vert.nor.z * 0.5f + 0.5f) * 255.0f) << 16;
|
||||
nor |= (uint8_t)(vert.nor.w * 255.0f) << 24; // ao (0-1)
|
||||
}
|
||||
inline void FromFLOAT(const XMFLOAT3& value)
|
||||
{
|
||||
uint8_t alpha = (nor >> 24) & 0x000000FF;
|
||||
|
||||
nor = 0;
|
||||
|
||||
nor |= (uint8_t)((value.x * 0.5f + 0.5f) * 255.0f) << 0;
|
||||
nor |= (uint8_t)((value.y * 0.5f + 0.5f) * 255.0f) << 8;
|
||||
nor |= (uint8_t)((value.z * 0.5f + 0.5f) * 255.0f) << 16;
|
||||
nor |= alpha << 24;
|
||||
}
|
||||
inline XMFLOAT4 GetNor_FULL() const
|
||||
{
|
||||
XMFLOAT4 nor_FULL(0, 0, 0, 0);
|
||||
|
||||
nor_FULL.x = (float)((nor >> 0) & 0x000000FF) / 255.0f * 2.0f - 1.0f;
|
||||
nor_FULL.y = (float)((nor >> 8) & 0x000000FF) / 255.0f * 2.0f - 1.0f;
|
||||
nor_FULL.z = (float)((nor >> 16) & 0x000000FF) / 255.0f * 2.0f - 1.0f;
|
||||
nor_FULL.w = (float)((nor >> 24) & 0x000000FF) / 255.0f;
|
||||
|
||||
return nor_FULL;
|
||||
}
|
||||
|
||||
static const wiGraphicsTypes::FORMAT FORMAT = wiGraphicsTypes::FORMAT::FORMAT_R8G8B8A8_UNORM;
|
||||
};
|
||||
struct Vertex_TEX
|
||||
{
|
||||
XMFLOAT4 tex;
|
||||
XMHALF4 tex;
|
||||
|
||||
Vertex_TEX() :tex(XMHALF4(0.0f, 0.0f, 0.0f, 0.0f)) {}
|
||||
Vertex_TEX(const Vertex_FULL& vert)
|
||||
{
|
||||
tex = XMHALF4(vert.tex.x, vert.tex.y, vert.tex.z, vert.tex.w);
|
||||
}
|
||||
|
||||
static const wiGraphicsTypes::FORMAT FORMAT = wiGraphicsTypes::FORMAT::FORMAT_R16G16B16A16_FLOAT;
|
||||
};
|
||||
struct Vertex_BON
|
||||
{
|
||||
@@ -307,20 +356,20 @@ public:
|
||||
ind = 0;
|
||||
wei = 0;
|
||||
}
|
||||
Vertex_BON(const XMFLOAT4& ind_FULL, const XMFLOAT4& wei_FULL)
|
||||
Vertex_BON(const Vertex_FULL& vert)
|
||||
{
|
||||
ind = 0;
|
||||
wei = 0;
|
||||
|
||||
ind |= (uint8_t)ind_FULL.x << 0;
|
||||
ind |= (uint8_t)ind_FULL.y << 8;
|
||||
ind |= (uint8_t)ind_FULL.z << 16;
|
||||
ind |= (uint8_t)ind_FULL.w << 24;
|
||||
ind |= (uint8_t)vert.ind.x << 0;
|
||||
ind |= (uint8_t)vert.ind.y << 8;
|
||||
ind |= (uint8_t)vert.ind.z << 16;
|
||||
ind |= (uint8_t)vert.ind.w << 24;
|
||||
|
||||
wei |= (uint8_t)(wei_FULL.x * 255.0f) << 0;
|
||||
wei |= (uint8_t)(wei_FULL.y * 255.0f) << 8;
|
||||
wei |= (uint8_t)(wei_FULL.z * 255.0f) << 16;
|
||||
wei |= (uint8_t)(wei_FULL.w * 255.0f) << 24;
|
||||
wei |= (uint8_t)(vert.wei.x * 255.0f) << 0;
|
||||
wei |= (uint8_t)(vert.wei.y * 255.0f) << 8;
|
||||
wei |= (uint8_t)(vert.wei.z * 255.0f) << 16;
|
||||
wei |= (uint8_t)(vert.wei.w * 255.0f) << 24;
|
||||
}
|
||||
inline XMFLOAT4 GetInd_FULL() const
|
||||
{
|
||||
@@ -396,7 +445,6 @@ public:
|
||||
|
||||
wiRenderTarget impostorTarget;
|
||||
float impostorDistance;
|
||||
//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;
|
||||
|
||||
+46
-34
@@ -629,7 +629,7 @@ void wiRenderer::LoadShaders()
|
||||
{
|
||||
VertexLayoutDesc layout[] =
|
||||
{
|
||||
{ "POSITION", 0, FORMAT_R32G32B32A32_FLOAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "POSITION", 0, Mesh::Vertex_POS::FORMAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
};
|
||||
UINT numElements = ARRAYSIZE(layout);
|
||||
VertexShaderInfo* vsinfo = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectVS_debug.cso", wiResourceManager::VERTEXSHADER, layout, numElements));
|
||||
@@ -641,10 +641,10 @@ void wiRenderer::LoadShaders()
|
||||
{
|
||||
VertexLayoutDesc layout[] =
|
||||
{
|
||||
{ "POSITION", 0, FORMAT_R32G32B32A32_FLOAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "NORMAL", 0, FORMAT_R32G32B32A32_FLOAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, FORMAT_R32G32B32A32_FLOAT, 2, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 1, FORMAT_R32G32B32A32_FLOAT, 3, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "POSITION", 0, Mesh::Vertex_POS::FORMAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "NORMAL", 0, Mesh::Vertex_NOR::FORMAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, Mesh::Vertex_TEX::FORMAT, 2, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 1, Mesh::Vertex_POS::FORMAT, 3, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
|
||||
{ "MATI", 0, FORMAT_R32G32B32A32_FLOAT, 4, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
{ "MATI", 1, FORMAT_R32G32B32A32_FLOAT, 4, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
@@ -664,7 +664,7 @@ void wiRenderer::LoadShaders()
|
||||
{
|
||||
VertexLayoutDesc layout[] =
|
||||
{
|
||||
{ "POSITION", 0, FORMAT_R32G32B32A32_FLOAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "POSITION", 0, Mesh::Vertex_POS::FORMAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
|
||||
{ "MATI", 0, FORMAT_R32G32B32A32_FLOAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
{ "MATI", 1, FORMAT_R32G32B32A32_FLOAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
@@ -681,8 +681,8 @@ void wiRenderer::LoadShaders()
|
||||
{
|
||||
VertexLayoutDesc layout[] =
|
||||
{
|
||||
{ "POSITION", 0, FORMAT_R32G32B32A32_FLOAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, FORMAT_R32G32B32A32_FLOAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "POSITION", 0, Mesh::Vertex_POS::FORMAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, Mesh::Vertex_TEX::FORMAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
|
||||
{ "MATI", 0, FORMAT_R32G32B32A32_FLOAT, 2, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
{ "MATI", 1, FORMAT_R32G32B32A32_FLOAT, 2, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
@@ -699,7 +699,7 @@ void wiRenderer::LoadShaders()
|
||||
{
|
||||
VertexLayoutDesc layout[] =
|
||||
{
|
||||
{ "POSITION", 0, FORMAT_R32G32B32A32_FLOAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "POSITION", 0, Mesh::Vertex_POS::FORMAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
|
||||
{ "MATI", 0, FORMAT_R32G32B32A32_FLOAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
{ "MATI", 1, FORMAT_R32G32B32A32_FLOAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
@@ -716,8 +716,8 @@ void wiRenderer::LoadShaders()
|
||||
{
|
||||
VertexLayoutDesc layout[] =
|
||||
{
|
||||
{ "POSITION", 0, FORMAT_R32G32B32A32_FLOAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, FORMAT_R32G32B32A32_FLOAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "POSITION", 0, Mesh::Vertex_POS::FORMAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, Mesh::Vertex_TEX::FORMAT, 1, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
|
||||
{ "MATI", 0, FORMAT_R32G32B32A32_FLOAT, 2, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
{ "MATI", 1, FORMAT_R32G32B32A32_FLOAT, 2, APPEND_ALIGNED_ELEMENT, INPUT_PER_INSTANCE_DATA, 1 },
|
||||
@@ -1271,6 +1271,12 @@ void wiRenderer::SetUpStates()
|
||||
GetDevice()->CreateDepthStencilState(&dsd, depthStencils[DSSTYPE_HAIRALPHACOMPOSITION]);
|
||||
|
||||
|
||||
dsd.DepthEnable = true;
|
||||
dsd.DepthWriteMask = DEPTH_WRITE_MASK_ALL;
|
||||
dsd.DepthFunc = COMPARISON_LESS_EQUAL;
|
||||
GetDevice()->CreateDepthStencilState(&dsd, depthStencils[DSSTYPE_ENVMAP]);
|
||||
|
||||
|
||||
for (int i = 0; i < BSTYPE_LAST; ++i)
|
||||
{
|
||||
blendStates[i] = new BlendState;
|
||||
@@ -1483,8 +1489,8 @@ Light* wiRenderer::getLightByName(const std::string& name)
|
||||
Mesh::Vertex_FULL wiRenderer::TransformVertex(const Mesh* mesh, int vertexI, const XMMATRIX& mat)
|
||||
{
|
||||
XMMATRIX sump;
|
||||
XMVECTOR pos = XMLoadFloat4(&mesh->vertices_POS[vertexI].pos);
|
||||
XMVECTOR nor = XMLoadFloat4(&mesh->vertices_NOR[vertexI].nor);
|
||||
XMVECTOR pos = XMLoadHalf4(&mesh->vertices_POS[vertexI].pos);
|
||||
XMVECTOR nor = XMLoadFloat4(&mesh->vertices_NOR[vertexI].GetNor_FULL());
|
||||
|
||||
if (mesh->hasArmature() && !mesh->armature->boneCollection.empty())
|
||||
{
|
||||
@@ -1530,7 +1536,12 @@ Mesh::Vertex_FULL wiRenderer::TransformVertex(const Mesh* mesh, int vertexI, con
|
||||
|
||||
Mesh::Vertex_FULL retV(transformedP);
|
||||
retV.nor = XMFLOAT4(transformedN.x, transformedN.y, transformedN.z, retV.nor.w);
|
||||
retV.tex = mesh->vertices_TEX[vertexI].tex;
|
||||
retV.tex = XMFLOAT4(
|
||||
mesh->vertices_TEX[vertexI].tex.x,
|
||||
mesh->vertices_TEX[vertexI].tex.y,
|
||||
mesh->vertices_TEX[vertexI].tex.z,
|
||||
mesh->vertices_TEX[vertexI].tex.w
|
||||
);
|
||||
|
||||
return retV;
|
||||
}
|
||||
@@ -2660,7 +2671,7 @@ void wiRenderer::DrawDebugEmitters(Camera* camera, GRAPHICSTHREAD threadID)
|
||||
&x->object->mesh->vertexBuffer_POS,
|
||||
};
|
||||
const UINT strides[] = {
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
};
|
||||
GetDevice()->BindVertexBuffers(vbs, 0, ARRAYSIZE(vbs), strides, threadID);
|
||||
GetDevice()->BindIndexBuffer(&y.indexBuffer, y.GetIndexFormat(), threadID);
|
||||
@@ -3844,6 +3855,7 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
|
||||
DSSTYPES targetDepthStencilState = (shaderType == SHADERTYPE_TILEDFORWARD && renderTypeFlags & RENDERTYPE_OPAQUE) ? DSSTYPE_DEPTHREADEQUAL : DSSTYPE_DEFAULT;
|
||||
targetDepthStencilState = (shaderType == SHADERTYPE_SHADOWCUBE || shaderType == SHADERTYPE_SHADOW) ? DSSTYPE_SHADOW : targetDepthStencilState;
|
||||
targetDepthStencilState = shaderType == SHADERTYPE_ENVMAPCAPTURE ? DSSTYPE_ENVMAP : targetDepthStencilState;
|
||||
|
||||
UINT prevStencilRef = STENCILREF_DEFAULT;
|
||||
device->BindDepthStencilState(depthStencils[targetDepthStencilState], prevStencilRef, threadID);
|
||||
@@ -3977,8 +3989,8 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
&mesh->instanceBuffer
|
||||
};
|
||||
UINT strides[] = {
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Mesh::Vertex_TEX),
|
||||
sizeof(Instance)
|
||||
};
|
||||
device->BindVertexBuffers(vbs, 0, ARRAYSIZE(vbs), strides, threadID);
|
||||
@@ -3994,10 +4006,10 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
&mesh->instanceBufferPrev,
|
||||
};
|
||||
UINT strides[] = {
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Mesh::Vertex_NOR),
|
||||
sizeof(Mesh::Vertex_TEX),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Instance),
|
||||
sizeof(Instance),
|
||||
};
|
||||
@@ -4217,7 +4229,7 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
&mesh->instanceBuffer
|
||||
};
|
||||
UINT strides[] = {
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Instance)
|
||||
};
|
||||
device->BindVertexBuffers(vbs, 0, ARRAYSIZE(vbs), strides, threadID);
|
||||
@@ -4231,8 +4243,8 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
&mesh->instanceBuffer
|
||||
};
|
||||
UINT strides[] = {
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Mesh::Vertex_TEX),
|
||||
sizeof(Instance)
|
||||
};
|
||||
device->BindVertexBuffers(vbs, 0, ARRAYSIZE(vbs), strides, threadID);
|
||||
@@ -4249,10 +4261,10 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
&mesh->instanceBufferPrev,
|
||||
};
|
||||
UINT strides[] = {
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Mesh::Vertex_NOR),
|
||||
sizeof(Mesh::Vertex_TEX),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Instance),
|
||||
sizeof(InstancePrev),
|
||||
};
|
||||
@@ -4631,7 +4643,7 @@ void wiRenderer::RefreshEnvProbes(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
GetDevice()->BindPrimitiveTopology(TRIANGLELIST, threadID);
|
||||
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_SKY], threadID);
|
||||
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_DEPTHREAD], STENCILREF_SKY, threadID);
|
||||
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_ENVMAP], STENCILREF_SKY, threadID);
|
||||
GetDevice()->BindBlendState(blendStates[BSTYPE_OPAQUE], threadID);
|
||||
|
||||
GetDevice()->BindVS(vertexShaders[VSTYPE_ENVMAP_SKY], threadID);
|
||||
@@ -5731,7 +5743,7 @@ void wiRenderer::RayIntersectMeshes(const RAY& ray, const CulledList& culledObje
|
||||
}
|
||||
else
|
||||
{
|
||||
_vertices[i] = XMLoadFloat4(&mesh->vertices_POS[i].pos);
|
||||
_vertices[i] = XMLoadHalf4(&mesh->vertices_POS[i].pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6012,10 +6024,10 @@ void wiRenderer::CreateImpostor(Mesh* mesh)
|
||||
&mesh->instanceBuffer
|
||||
};
|
||||
UINT strides[] = {
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(XMFLOAT4),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Mesh::Vertex_NOR),
|
||||
sizeof(Mesh::Vertex_TEX),
|
||||
sizeof(Mesh::Vertex_POS),
|
||||
sizeof(Instance)
|
||||
};
|
||||
GetDevice()->BindVertexBuffers(vbs, 0, ARRAYSIZE(vbs), strides, threadID);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 13;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 7;
|
||||
const int revision = 8;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Reference in New Issue
Block a user