Normal normals
This commit is contained in:
parent
95c70fe0b2
commit
5cc858ba1b
|
@ -108,7 +108,7 @@ namespace DanBias
|
||||||
data.capFrame += dt;
|
data.capFrame += dt;
|
||||||
if(data.capFrame > 0.03)
|
if(data.capFrame > 0.03)
|
||||||
{
|
{
|
||||||
switch( Update(dt) )
|
switch( Update(data.capFrame) )
|
||||||
{
|
{
|
||||||
case Result_continue: break;
|
case Result_continue: break;
|
||||||
case Result_quit: return DanBiasClientReturn_Success;
|
case Result_quit: return DanBiasClientReturn_Success;
|
||||||
|
@ -117,7 +117,7 @@ namespace DanBias
|
||||||
}
|
}
|
||||||
if(Render() != S_OK)
|
if(Render() != S_OK)
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
data.capFrame = 0;
|
data.capFrame -= 0.03;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.networkClient.IsConnected())
|
if(data.networkClient.IsConnected())
|
||||||
|
@ -143,7 +143,7 @@ namespace DanBias
|
||||||
p.texturePath = L"..\\Content\\Textures\\";
|
p.texturePath = L"..\\Content\\Textures\\";
|
||||||
p.Resolution = Oyster::Math::Float2( 1280.0f, 720.0f );
|
p.Resolution = Oyster::Math::Float2( 1280.0f, 720.0f );
|
||||||
//! @todo fix proper amb value
|
//! @todo fix proper amb value
|
||||||
p.AmbientValue = 1.0f;
|
p.AmbientValue = 1.3f;
|
||||||
|
|
||||||
if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, p) != Oyster::Graphics::API::Sucsess)
|
if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, p) != Oyster::Graphics::API::Sucsess)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
|
@ -20,5 +20,5 @@ bool C_Player::Init(ModelInitData modelInit)
|
||||||
void C_Player::playAnimation(std::wstring animation, bool loop)
|
void C_Player::playAnimation(std::wstring animation, bool loop)
|
||||||
{
|
{
|
||||||
if(model)
|
if(model)
|
||||||
Oyster::Graphics::API::PlayAnimation(model, L"movement", loop);
|
Oyster::Graphics::API::PlayAnimation(model, animation, loop);
|
||||||
}
|
}
|
|
@ -50,7 +50,12 @@ namespace Oyster
|
||||||
if(models[i].Visible)
|
if(models[i].Visible)
|
||||||
{
|
{
|
||||||
Definitions::PerModel pm;
|
Definitions::PerModel pm;
|
||||||
pm.WV = View * models[i].WorldMatrix.GetTranspose().GetInverse();
|
Math::Float3x3 normalTransform;
|
||||||
|
normalTransform = Math::Float3x3(models[i].WorldMatrix.v[0].xyz, models[i].WorldMatrix.v[1].xyz, models[i].WorldMatrix.v[2].xyz);
|
||||||
|
normalTransform.Transpose().Invert();
|
||||||
|
Math::Matrix m = Math::Matrix(Math::Vector4(normalTransform.v[0],0.0f), Math::Vector4(normalTransform.v[1],0.0f), Math::Vector4(normalTransform.v[2],0.0f), Math::Vector4(0.0f));
|
||||||
|
pm.WV = View * m;
|
||||||
|
//pm.WV = models[i].WorldMatrix.GetTranspose().GetInverse();
|
||||||
pm.WVP = Projection * View * models[i].WorldMatrix;
|
pm.WVP = Projection * View * models[i].WorldMatrix;
|
||||||
|
|
||||||
Model::ModelInfo* info = models[i].info;
|
Model::ModelInfo* info = models[i].info;
|
||||||
|
@ -159,10 +164,10 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
Definitions::BlurrData bd;
|
Definitions::BlurrData bd;
|
||||||
bd.BlurMask = Math::Float4(1,1,1,1);
|
bd.BlurMask = Math::Float4(1,1,1,1);
|
||||||
bd.StopX = Core::resolution.x/2;
|
bd.StopX = (UINT)Core::resolution.x/2;
|
||||||
bd.StopY = Core::resolution.y;
|
bd.StopY = (UINT)Core::resolution.y;
|
||||||
bd.StartX = 0;
|
bd.StartX = 0;
|
||||||
bd.StartY = Core::resolution.y/2;
|
bd.StartY = (UINT)Core::resolution.y/2;
|
||||||
|
|
||||||
void* data = Resources::Blur::Data.Map();
|
void* data = Resources::Blur::Data.Map();
|
||||||
memcpy(data,&bd,sizeof(Definitions::BlurrData));
|
memcpy(data,&bd,sizeof(Definitions::BlurrData));
|
||||||
|
@ -179,8 +184,8 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
Definitions::BlurrData bd;
|
Definitions::BlurrData bd;
|
||||||
bd.BlurMask = Math::Float4(0,0,0,1);
|
bd.BlurMask = Math::Float4(0,0,0,1);
|
||||||
bd.StopX = Core::resolution.x/2;
|
bd.StopX = (UINT)Core::resolution.x/2;
|
||||||
bd.StopY = Core::resolution.y/2;
|
bd.StopY = (UINT)Core::resolution.y/2;
|
||||||
bd.StartX = 0;
|
bd.StartX = 0;
|
||||||
bd.StartY = 0;
|
bd.StartY = 0;
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ float3x3 cotangent_frame( float3 N, float3 p, float2 uv )
|
||||||
float3 B = dp2perp * duv1.y + dp1perp * duv2.y;
|
float3 B = dp2perp * duv1.y + dp1perp * duv2.y;
|
||||||
|
|
||||||
// construct a scale-invariant frame
|
// construct a scale-invariant frame
|
||||||
float invmax = 1/sqrt( max( dot(T,T), dot(B,B) ) );
|
float invmax = rsqrt( max( dot(T,T), dot(B,B) ) );
|
||||||
return float3x3( T * invmax, B * invmax, N );
|
return transpose(float3x3( T * invmax, B * invmax, N ));
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 perturb_normal( float3 N, float3 V, float2 texcoord )
|
float3 perturb_normal( float3 N, float3 V, float2 texcoord )
|
||||||
|
@ -41,11 +41,20 @@ PixelOut main(VertexOut input)
|
||||||
{
|
{
|
||||||
PixelOut output;
|
PixelOut output;
|
||||||
output.DiffuseGlow = Diffuse.Sample(S1, input.UV) * float4(Color, 1);
|
output.DiffuseGlow = Diffuse.Sample(S1, input.UV) * float4(Color, 1);
|
||||||
float3 normal = normalize(input.normal);
|
|
||||||
|
|
||||||
normal = perturb_normal( normal, normalize(-input.ViewPos), input.UV );
|
//NORMALIZE
|
||||||
|
float3x3 CoTangentFrame = cotangent_frame(input.normal, normalize(input.ViewPos), input.UV);
|
||||||
|
|
||||||
//output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*255);
|
float3 map = Normal.Sample(S1,input.UV).xyz;
|
||||||
output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*0);
|
//map = normalize((map * 2) -1);
|
||||||
|
map = map * 255./127. - 128./127.;
|
||||||
|
//map = map * 255;
|
||||||
|
float3 normal = normalize(mul(CoTangentFrame, map));
|
||||||
|
//normal = perturb_normal( normal, normalize(-input.ViewPos), input.UV );
|
||||||
|
|
||||||
|
output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*255);
|
||||||
|
|
||||||
|
//output.NormalSpec = float4(input.normal, Normal.Sample(S1, input.UV).w * 0);
|
||||||
|
//output.NormalSpec = float4(map,0);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@ VertexOut main( VertexIn input )
|
||||||
|
|
||||||
input.pos = mul(boneTrans,float4(input.pos,1)).xyz * Animated + input.pos * int(1-Animated);
|
input.pos = mul(boneTrans,float4(input.pos,1)).xyz * Animated + input.pos * int(1-Animated);
|
||||||
|
|
||||||
input.normal = mul(boneTrans,float4(input.normal,1)).xyz * Animated + input.normal * int(1-Animated);
|
input.normal = mul(boneTrans,float4(input.normal,0)).xyz * Animated + input.normal * int(1-Animated);
|
||||||
|
|
||||||
output.pos = mul(WVP, float4(input.pos,1));
|
output.pos = mul(WVP, float4(input.pos,1));
|
||||||
output.ViewPos = mul(WV, float4(input.pos,1));
|
output.ViewPos = mul(WV, float4(input.pos,1));
|
||||||
|
|
|
@ -39,10 +39,16 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
|
||||||
DiffBase += DiffuseGlow[DTid.xy + uint2(0,1)];
|
DiffBase += DiffuseGlow[DTid.xy + uint2(0,1)];
|
||||||
DiffBase += DiffuseGlow[DTid.xy + uint2(1,1)];
|
DiffBase += DiffuseGlow[DTid.xy + uint2(1,1)];
|
||||||
DiffBase = DiffBase / 4;
|
DiffBase = DiffBase / 4;
|
||||||
|
|
||||||
|
float4 DepthBase = DepthTexture[DTid.xy];
|
||||||
|
DepthBase = DepthTexture[DTid.xy + uint2(1,0)];
|
||||||
|
DepthBase = DepthTexture[DTid.xy + uint2(0,1)];
|
||||||
|
DepthBase = DepthTexture[DTid.xy + uint2(1,1)];
|
||||||
|
DepthBase = DepthBase /4;
|
||||||
Ambient[DTid.xy/2] = float4(DiffBase.xyz, AmbValue);
|
Ambient[DTid.xy/2] = float4(DiffBase.xyz, AmbValue);
|
||||||
Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy];
|
Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy];
|
||||||
Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w,1);
|
Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w * 10 /* * (2-DepthBase) */,1);
|
||||||
Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz,1);
|
Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz * float3(1,1,-1),1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,24 +11,12 @@ cbuffer Size : register(b0)
|
||||||
float AmbFactor;
|
float AmbFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 SuperSample(float4 Glow, uint3 DTid)
|
|
||||||
{
|
|
||||||
// Line X
|
|
||||||
float2 index = (float2)(DTid.xy/2);
|
|
||||||
index += float2(0,Output.Length.y/2);
|
|
||||||
index = index / Output.Length;
|
|
||||||
Glow = Ambient.SampleLevel(S1, index,1);
|
|
||||||
Glow = Glow;
|
|
||||||
|
|
||||||
return Glow;
|
|
||||||
}
|
|
||||||
|
|
||||||
[numthreads(16, 16, 1)]
|
[numthreads(16, 16, 1)]
|
||||||
void main( uint3 DTid : SV_DispatchThreadID )
|
void main( uint3 DTid : SV_DispatchThreadID )
|
||||||
{
|
{
|
||||||
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
|
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
|
||||||
float4 Amb = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w*/, 0);
|
float3 Amb = Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w */;
|
||||||
float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
|
float3 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)].xyz;
|
||||||
|
|
||||||
float4 GUI;
|
float4 GUI;
|
||||||
uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0);
|
uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0);
|
||||||
|
@ -38,6 +26,6 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||||
PostLight = PostLight * (1 - GUI.w);
|
PostLight = PostLight * (1 - GUI.w);
|
||||||
Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1);
|
Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1);
|
||||||
|
|
||||||
//Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(0,Output.Length.y*0.5f)].xyz,1);
|
//Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(Output.Length*0.5f)].xyz,1);
|
||||||
//Output[DTid.xy] = Ambient[DTid.xy];
|
//Output[DTid.xy] = Ambient[DTid.xy];
|
||||||
}
|
}
|
Loading…
Reference in New Issue