dithered transparency added, decal clipping corrections
This commit is contained in:
@@ -650,6 +650,7 @@
|
||||
<None Include="cube.hlsli" />
|
||||
<None Include="depthConvertHF.hlsli" />
|
||||
<None Include="dirLightHF.hlsli" />
|
||||
<None Include="ditherHF.hlsli" />
|
||||
<None Include="effectHF_PS.hlsli" />
|
||||
<None Include="effectHF_PSVS.hlsli" />
|
||||
<None Include="effectHF_VS.hlsli" />
|
||||
|
||||
@@ -1543,6 +1543,9 @@
|
||||
<None Include="windHF.hlsli">
|
||||
<Filter>shaders\headers</Filter>
|
||||
</None>
|
||||
<None Include="ditherHF.hlsli">
|
||||
<Filter>shaders\headers</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\readme.txt" />
|
||||
|
||||
@@ -45,7 +45,7 @@ PixelOutputType main(VertexToPixel PSIn)
|
||||
float3 projTex;
|
||||
projTex.x = projPos.x/projPos.w/2.0f +0.5f;
|
||||
projTex.y = -projPos.y/projPos.w/2.0f +0.5f;
|
||||
projTex.z = projPos.z/projPos.w/2.0f +0.5f;
|
||||
projTex.z = projPos.z/projPos.w;
|
||||
clip( ((saturate(projTex.x) == projTex.x) && (saturate(projTex.y) == projTex.y) && (saturate(projTex.z) == projTex.z))?1:-1 );
|
||||
|
||||
if(hasTexNor & 0x0000010){
|
||||
|
||||
@@ -18,9 +18,7 @@ cbuffer prop:register(b0){
|
||||
float4 main(VertextoPixel PSIn) : SV_TARGET
|
||||
{
|
||||
float4 color=0;
|
||||
float2 depthMapSize;
|
||||
xSceneDepthMap.GetDimensions(depthMapSize.x,depthMapSize.y);
|
||||
float depth = ( xSceneDepthMap.Load(int4(depthMapSize*PSIn.tex.xy,0,0)).r );
|
||||
float depth = ( xSceneDepthMap.Load(int4(PSIn.pos.xy,0,0)).r );
|
||||
|
||||
[branch]if(depth<zFarP){
|
||||
color = xTexture.SampleLevel(Sampler,PSIn.tex,0);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef DITHER_HF
|
||||
#define DITHER_HF
|
||||
|
||||
inline float ditherMask(in float2 pixel, in float param)
|
||||
{
|
||||
float2 dither = frac(pixel.xy * 0.5f);
|
||||
return step(param, abs(dither.x - dither.y));
|
||||
}
|
||||
|
||||
#endif //DITHER_HF
|
||||
@@ -9,7 +9,8 @@ struct PixelInputType
|
||||
float3 cam : CAMERAPOS;
|
||||
float4 ReflectionMapSamplingPos : TEXCOORD1;
|
||||
float3 vel : TEXCOORD2;
|
||||
float ao : AMBIENT_OCCLUSION;
|
||||
float ao : AMBIENT_OCCLUSION;
|
||||
float dither : DITHER;
|
||||
};
|
||||
|
||||
cbuffer matBuffer:register(b2){
|
||||
|
||||
@@ -13,4 +13,5 @@ struct Input{
|
||||
float4 wi0 : MATI0;
|
||||
float4 wi1 : MATI1;
|
||||
float4 wi2 : MATI2;
|
||||
float dither : DITHER;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "effectHF_PS.hlsli"
|
||||
#include "effectHF_PSVS.hlsli"
|
||||
#include "globalsHF.hlsli"
|
||||
|
||||
#include "ditherHF.hlsli"
|
||||
|
||||
PixelOutputType main(PixelInputType PSIn)
|
||||
{
|
||||
@@ -14,6 +14,12 @@ PixelOutputType main(PixelInputType PSIn)
|
||||
float depth = PSIn.pos.z/PSIn.pos.w;
|
||||
float3 eyevector = normalize(PSIn.cam - PSIn.pos3D);
|
||||
|
||||
float2 ScreenCoord;
|
||||
ScreenCoord.x = PSIn.pos2D.x / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
ScreenCoord.y = -PSIn.pos2D.y / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
|
||||
clip(ditherMask(PSIn.pos.xy, PSIn.dither) - 1);
|
||||
|
||||
PSIn.tex+=movingTex;
|
||||
[branch]if(hasTex) {
|
||||
baseColor = xTextureTex.Sample(texSampler,PSIn.tex);
|
||||
@@ -78,20 +84,9 @@ PixelOutputType main(PixelInputType PSIn)
|
||||
|
||||
}
|
||||
|
||||
/*if(xFx.y==1){
|
||||
float avg=0;
|
||||
avg+=baseColor.r; avg+=baseColor.g; avg+=baseColor.b; avg/=3.0f;
|
||||
baseColor=avg;
|
||||
}
|
||||
|
||||
if(xFx.z==1){
|
||||
baseColor.r=1-baseColor.r;
|
||||
baseColor.g=1-baseColor.g;
|
||||
baseColor.b=1-baseColor.b;
|
||||
}*/
|
||||
|
||||
bool unshaded = shadeless||colorMask.a;
|
||||
float properties = unshaded?RT_UNSHADED : toonshaded?RT_TOON : 0.0f;
|
||||
float properties = unshaded ? RT_UNSHADED : toonshaded ? RT_TOON : 0.0f;
|
||||
|
||||
|
||||
Out.col = float4((baseColor.rgb+colorMask.rgb)*(1+emit)*PSIn.ao,1);
|
||||
Out.nor = float4((normal.xyz),properties);
|
||||
|
||||
@@ -18,6 +18,8 @@ PixelInputType main(Input input)
|
||||
,float4(input.wi0.z,input.wi1.z,input.wi2.z,0)
|
||||
,float4(input.wi0.w,input.wi1.w,input.wi2.w,1)
|
||||
);
|
||||
|
||||
Out.dither = input.dither;
|
||||
|
||||
float4 pos = input.pos;
|
||||
float4 posPrev = input.pre;
|
||||
|
||||
@@ -923,6 +923,9 @@ void LoadWiObjects(const string& directory, const string& name, const string& id
|
||||
objects.back()->friction>>objects.back()->restitution>>objects.back()->damping>>objects.back()->physicsType>>
|
||||
objects.back()->kinematic;
|
||||
break;
|
||||
case 'T':
|
||||
file >> objects.back()->transparency;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -2311,7 +2314,7 @@ void Decal::Update(){
|
||||
XMVECTOR at = XMVectorAdd(eye,frontV);
|
||||
XMVECTOR up = XMVector3Transform( XMVectorSet(0,1,0,0),rotMat );
|
||||
XMStoreFloat4x4(&view, XMMatrixLookAtLH(eye,at,up));
|
||||
XMStoreFloat4x4(&projection, XMMatrixOrthographicLH(scale.x,scale.y,-scale.z,scale.z));
|
||||
XMStoreFloat4x4(&projection, XMMatrixOrthographicLH(scale.x, scale.y, -scale.z * 0.5f, scale.z * 0.5f));
|
||||
XMStoreFloat4x4(&world_rest, XMMatrixScalingFromVector(XMLoadFloat3(&scale))*rotMat*XMMatrixTranslationFromVector(eye));
|
||||
|
||||
bounds.createFromHalfWidth(XMFLOAT3(0,0,0),XMFLOAT3(scale.x,scale.y,scale.z));
|
||||
|
||||
+10
-12
@@ -70,30 +70,25 @@ struct Instance
|
||||
XMFLOAT4A mat0;
|
||||
XMFLOAT4A mat1;
|
||||
XMFLOAT4A mat2;
|
||||
float dither;
|
||||
|
||||
Instance(){
|
||||
Instance(float dither = 0.0f) :dither(dither){
|
||||
mat0 = XMFLOAT4A(1, 0, 0, 0);
|
||||
mat0 = XMFLOAT4A(0, 1, 0, 0);
|
||||
mat0 = XMFLOAT4A(0, 0, 1, 0);
|
||||
}
|
||||
Instance(const XMMATRIX& matIn){
|
||||
Create(matIn);
|
||||
Instance(const XMMATRIX& matIn, float dither = 0.0f){
|
||||
Create(matIn,dither);
|
||||
}
|
||||
void Create(const XMMATRIX& matIn)
|
||||
void Create(const XMMATRIX& matIn, float dither = 0.0f)
|
||||
{
|
||||
XMStoreFloat4A(&mat0, matIn.r[0]);
|
||||
XMStoreFloat4A(&mat1, matIn.r[1]);
|
||||
XMStoreFloat4A(&mat2, matIn.r[2]);
|
||||
this->dither = dither;
|
||||
}
|
||||
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return _aligned_malloc(size, 16);
|
||||
}
|
||||
void operator delete(void* p)
|
||||
{
|
||||
if (p) _aligned_free(p);
|
||||
}
|
||||
ALIGN_16
|
||||
};
|
||||
struct Material
|
||||
{
|
||||
@@ -485,6 +480,8 @@ struct Object : public Streamable, public Transform
|
||||
vector< wiEmittedParticle* > eParticleSystems;
|
||||
vector< wiHairParticle* > hwiParticleSystems;
|
||||
|
||||
float transparency;
|
||||
|
||||
|
||||
//PHYSICS
|
||||
bool rigidBody, kinematic;
|
||||
@@ -521,6 +518,7 @@ struct Object : public Streamable, public Transform
|
||||
mass = friction = restitution = damping = 1.0f;
|
||||
physicsType="ACTIVE";
|
||||
physicsObjectI=-1;
|
||||
transparency = 0.0f;
|
||||
}
|
||||
|
||||
void CleanUp(){
|
||||
|
||||
+21
-20
@@ -995,6 +995,7 @@ void wiRenderer::LoadBasicShaders()
|
||||
{ "MATI", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
|
||||
{ "MATI", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
|
||||
{ "MATI", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
|
||||
{ "DITHER", 0, DXGI_FORMAT_R32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
|
||||
};
|
||||
UINT numElements = ARRAYSIZE(layout);
|
||||
VertexShaderInfo* vsinfo = static_cast<VertexShaderInfo*>(wiResourceManager::add("shaders/effectVS10.cso", wiResourceManager::VERTEXSHADER, layout, numElements));
|
||||
@@ -2780,9 +2781,9 @@ void wiRenderer::DrawForShadowMap(ID3D11DeviceContext* context)
|
||||
for (CulledObjectList::iterator viter = visibleInstances.begin(); viter != visibleInstances.end(); ++viter){
|
||||
if ((*viter)->particleEmitter != Object::wiParticleEmitter::EMITTER_INVISIBLE){
|
||||
if (mesh->softBody || (*viter)->armatureDeform)
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixIdentity()), k, GRAPHICSTHREAD_SHADOWS);
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixIdentity(), (*viter)->transparency), k, GRAPHICSTHREAD_SHADOWS);
|
||||
else
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixTranspose(XMLoadFloat4x4(&(*viter)->world))), k, GRAPHICSTHREAD_SHADOWS);
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixTranspose(XMLoadFloat4x4(&(*viter)->world)), (*viter)->transparency), k, GRAPHICSTHREAD_SHADOWS);
|
||||
++k;
|
||||
}
|
||||
}
|
||||
@@ -2896,9 +2897,9 @@ void wiRenderer::DrawForShadowMap(ID3D11DeviceContext* context)
|
||||
for (CulledObjectList::iterator viter = visibleInstances.begin(); viter != visibleInstances.end(); ++viter){
|
||||
if ((*viter)->particleEmitter != Object::wiParticleEmitter::EMITTER_INVISIBLE){
|
||||
if (mesh->softBody || (*viter)->armatureDeform)
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixIdentity()), k, GRAPHICSTHREAD_SHADOWS);
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixIdentity(), (*viter)->transparency), k, GRAPHICSTHREAD_SHADOWS);
|
||||
else
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixTranspose(XMLoadFloat4x4(&(*viter)->world))), k, GRAPHICSTHREAD_SHADOWS);
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixTranspose(XMLoadFloat4x4(&(*viter)->world)), (*viter)->transparency), k, GRAPHICSTHREAD_SHADOWS);
|
||||
++k;
|
||||
}
|
||||
}
|
||||
@@ -3086,9 +3087,9 @@ void wiRenderer::DrawWorld(const XMMATRIX& newView, bool DX11Eff, int tessF, ID3
|
||||
for(CulledObjectList::iterator viter=visibleInstances.begin();viter!=visibleInstances.end();++viter){
|
||||
if((*viter)->particleEmitter!=Object::wiParticleEmitter::EMITTER_INVISIBLE){
|
||||
if (mesh->softBody || (*viter)->armatureDeform)
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixIdentity()),k,thread);
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixIdentity(),(*viter)->transparency),k,thread);
|
||||
else
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixTranspose(XMLoadFloat4x4(&(*viter)->world))), k, thread);
|
||||
mesh->AddRenderableInstance(Instance(XMMatrixTranspose(XMLoadFloat4x4(&(*viter)->world)), (*viter)->transparency), k, thread);
|
||||
++k;
|
||||
}
|
||||
}
|
||||
@@ -4074,18 +4075,18 @@ void wiRenderer::SychronizeWithPhysicsEngine()
|
||||
}
|
||||
|
||||
wiRenderer::MaterialCB::MaterialCB(const Material& mat,UINT materialIndex){
|
||||
difColor=XMFLOAT4(mat.diffuseColor.x,mat.diffuseColor.y,mat.diffuseColor.z,mat.alpha);
|
||||
hasRef=mat.refMap!=nullptr;
|
||||
hasNor=mat.normalMap!=nullptr;
|
||||
hasTex=mat.texture!=nullptr;
|
||||
hasSpe=mat.specularMap!=nullptr;
|
||||
specular=mat.specular;
|
||||
refractionIndex=mat.refraction_index;
|
||||
movingTex=mat.texOffset;
|
||||
metallic=mat.enviroReflection;
|
||||
shadeless=mat.shadeless;
|
||||
specular_power=mat.specular_power;
|
||||
toon=mat.toonshading;
|
||||
matIndex=materialIndex;
|
||||
emit=mat.emit;
|
||||
difColor = XMFLOAT4(mat.diffuseColor.x, mat.diffuseColor.y, mat.diffuseColor.z, mat.alpha);
|
||||
hasRef = mat.refMap != nullptr;
|
||||
hasNor = mat.normalMap != nullptr;
|
||||
hasTex = mat.texture != nullptr;
|
||||
hasSpe = mat.specularMap != nullptr;
|
||||
specular = mat.specular;
|
||||
refractionIndex = mat.refraction_index;
|
||||
movingTex = mat.texOffset;
|
||||
metallic = mat.enviroReflection;
|
||||
shadeless = mat.shadeless;
|
||||
specular_power = mat.specular_power;
|
||||
toon = mat.toonshading;
|
||||
matIndex = materialIndex;
|
||||
emit = mat.emit;
|
||||
}
|
||||
Reference in New Issue
Block a user