Skip to content
Snippets Groups Projects
Commit 6ee09817 authored by D-AIRY's avatar D-AIRY
Browse files

Merge branch 'branchX' into xParticles

parents 2904a4c3 7212c4b3
No related branches found
No related tags found
1 merge request!22xParticles
Showing
with 1154 additions and 47 deletions
# Visual Studio generated .editorconfig file with C++ settings.
root = true
[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
# Visual C++ Code Style settings
cpp_generate_documentation_comments = xml
# Visual C++ Formatting settings
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = true
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = leftmost_column
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = false
cpp_indent_preserve_comments = false
cpp_new_line_before_open_brace_namespace = ignore
cpp_new_line_before_open_brace_type = ignore
cpp_new_line_before_open_brace_function = new_line
cpp_new_line_before_open_brace_block = ignore
cpp_new_line_before_open_brace_lambda = ignore
cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = true
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = false
cpp_space_after_keywords_in_control_flow_statements = false
cpp_space_within_control_flow_statement_parentheses = false
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = false
cpp_space_before_block_open_brace = false
cpp_space_between_empty_braces = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = false
cpp_space_preserve_in_initializer_list = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = false
cpp_space_before_constructor_colon = false
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = ignore
cpp_space_around_ternary_operator = insert
cpp_wrap_preserve_blocks = never
[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
# Visual C++ Code Style settings
cpp_generate_documentation_comments = xml
# Visual C++ Formatting settings
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = true
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = leftmost_column
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = false
cpp_indent_preserve_comments = false
cpp_new_line_before_open_brace_namespace = ignore
cpp_new_line_before_open_brace_type = ignore
cpp_new_line_before_open_brace_function = new_line
cpp_new_line_before_open_brace_block = ignore
cpp_new_line_before_open_brace_lambda = ignore
cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = true
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = false
cpp_space_after_keywords_in_control_flow_statements = false
cpp_space_within_control_flow_statement_parentheses = false
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = false
cpp_space_before_block_open_brace = false
cpp_space_between_empty_braces = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = false
cpp_space_preserve_in_initializer_list = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = false
cpp_space_before_constructor_colon = false
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = ignore
cpp_space_around_ternary_operator = insert
cpp_wrap_preserve_blocks = never
......@@ -192,6 +192,8 @@ GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
.vs/
*.phpt
libs/
libs64/
......
[dev_invisible]
shader = Transparent
tex.txBase = dev_invisible.dds
flag.editorial = 1
......@@ -19,6 +19,8 @@ VSO_SceneCommon main(VSI_Animation IN)
OUT.vPosition = mul(OUT.vPosition, g_mW);
OUT.vPosition = mul(OUT.vPosition, g_mVP);
OUT.vNormal = mul(OUT.vNormal, (float3x3)g_mW);
OUT.vTangent = mul(OUT.vTangent, (float3x3)g_mW);
OUT.vBinormal = mul(OUT.vBinormal, (float3x3)g_mW);
OUT.vTexUV = IN.vTexUV;
OUT.vPos = OUT.vPosition;
......
......@@ -47,13 +47,13 @@ VSO_SceneCommon main(VSI_Geometry IN
OUT.vNormal = RotateVec(qRot, IN.vNormal);
OUT.vTangent = RotateVec(qRot, IN.vTangent);
OUT.vBinormal = RotateVec(qRot, IN.vBinormal);
OUT.uInstanceId.x = uInstanceId;
// OUT.vNormal = IN.vNormal;
#else
OUT.vPosition = mul(float4(IN.vPosition, 1.0f), g_mW);
OUT.vNormal = /*normalize(*/mul(IN.vNormal, (float3x3)g_mW)/*)*/;
OUT.vTangent = /*normalize(*/mul(IN.vTangent, (float3x3)g_mW)/*)*/;
OUT.vBinormal = /*normalize(*/mul(IN.vBinormal, (float3x3)g_mW)/*)*/;
#endif
......
......@@ -80,7 +80,10 @@ cbuffer CSkyBoxLight: register(b7)
};
#endif
cbuffer CObjectColors: register(b8)
{
float4 g_avColors[128];
};
......
......@@ -48,11 +48,20 @@ XMaterial MainIllimination(PSI_XMaterial IN)
{
XMaterial OUT = XMATERIAL_LOAD_DEFAULTS();
#ifdef HAS_EMISSION
float4 fColor = (float4)0;
#ifdef HAS_ALPHATEST
fColor = g_txBase.Sample(g_sScene, IN.vTexUV);
clip(fColor.a - g_xMaterialConstants.pbr_alphatest_threshold);
// clip(fColor.a - 0.03);
#endif
#ifdef HAS_EMISSIVE_MAP
float4 fColor = g_txEmissive.Sample(g_sScene, IN.vTexUV);
fColor = g_txEmissive.Sample(g_sScene, IN.vTexUV);
#else
float4 fColor = g_txBase.Sample(g_sScene, IN.vTexUV);
#ifndef HAS_ALPHATEST
fColor = g_txBase.Sample(g_sScene, IN.vTexUV);
#endif
#endif
OUT.vEmissiveColor = fColor.xyz * fColor.w * g_xMaterialConstants.em_multiplier;
......
/*
hdr_bloom
*/
#include <struct.h>
#include <const.h>
//##########################################################################
SamplerState g_sLinearClamp: register(s0);
SamplerState g_sPointClamp: register(s1);
Texture2D g_txScene: register(t0); // full screen texture
Texture2D g_txLuminance: register(t1); // luminance texture 1x1 px
//##########################################################################
float CalcLuminance(float3 color)
{
return(dot(color, float3(0.2126f, 0.7152f, 0.0722f)));
}
float4 main(VSO_PP IN):SV_TARGET
{
float fLuminance = g_txLuminance.Sample(g_sPointClamp, IN.vTexUV).x;
float4 vColor = g_txScene.Sample(g_sPointClamp, IN.vTexUV);
vColor += g_txScene.Sample(g_sPointClamp, IN.vTexUV + float2(g_vNearFarInvWinSize.z, 0.0f));
vColor += g_txScene.Sample(g_sPointClamp, IN.vTexUV + g_vNearFarInvWinSize.zw);
vColor += g_txScene.Sample(g_sPointClamp, IN.vTexUV + float2(0.0f, g_vNearFarInvWinSize.w));
vColor *= 0.25f;
// if(CalcLuminance(vColor.xyz) > 1.0f)
// if(CalcLuminance(vColor.xyz) > fLuminance * 2.0f)
{
return(vColor);
}
return(0.0f);
}
......@@ -20,6 +20,15 @@ void main(uint3 vGroupID: SV_GroupID, uint3 vGroupThreadID: SV_GroupThreadID)
vVal.z = g_txInput[vSampleID + uint2(0, 1)];
vVal.w = g_txInput[vSampleID + uint2(1, 1)];
#ifdef APPLY_MASK
float2 vCenter = float2(THREAD_GROUP_DIM - 0.5f, THREAD_GROUP_DIM - 0.5f);
float fMaxRadius = length(vCenter);
float fRadius = length(float2(vSampleID) - float2(THREAD_GROUP_DIM - 0.5f, THREAD_GROUP_DIM - 0.5f));
float fWeight = smoothstep(0.0f, 1.0f, 1.0f - (fRadius / fMaxRadius)) * 0.009740113406211618f;
vVal *= fWeight;
#endif
g_vShared[uThreadID] = vVal;
GroupMemoryBarrierWithGroupSync();
......@@ -34,7 +43,11 @@ void main(uint3 vGroupID: SV_GroupID, uint3 vGroupThreadID: SV_GroupThreadID)
if(uThreadID == 0)
{
#ifdef APPLY_MASK
g_txOutput[vGroupID.xy] = dot(g_vShared[0], 0.25f);
#else
g_txOutput[vGroupID.xy] = dot(g_vShared[0], 0.25f) / (float)(TOTAL_THREADS);
#endif
// g_txOutput[vGroupID.xy] = -10.0f;
}
}
......@@ -8,9 +8,11 @@ hdr_tonemapping
//##########################################################################
SamplerState g_sPointClamp: register(s0);
SamplerState g_sLinearClamp: register(s1);
Texture2D g_txScene: register(t0);
Texture2D g_txLuminance: register(t1);
Texture2D g_txLuminance2: register(t2);
Texture2D g_txBloom: register(t3);
//##########################################################################
......@@ -65,19 +67,16 @@ float4 main(VSO_PP IN):SV_TARGET
{
float4 vColor = g_txScene.Sample(g_sPointClamp, IN.vTexUV);
float fLuminance = g_txLuminance.Load(uint3(0, 0, 0)).x;
float fLuminance2 = exp(g_txLuminance2.Load(uint3(0, 0, 0)).x);
// float fLuminance2 = exp(g_txLuminance2.Load(uint3(0, 0, 0)).x);
float4 vBloomColor = g_txBloom.Sample(g_sLinearClamp, IN.vTexUV);
float fExposure = 0;
vColor.xyz = ToneMap(vColor.xyz, fLuminance, 0, fExposure);
// return(vBloomColor);
/* if(IN.vTexUV.x > 0.9 && IN.vTexUV.y > 0.9)
{
vColor.xyz = fLuminance;
}
if(IN.vTexUV.x > 0.9 && IN.vTexUV.y > 0.8 && IN.vTexUV.y < 0.9)
{
vColor.xyz = fLuminance2;
} */
float fExposure = 0;
vColor.xyz = ToneMap(vColor.xyz * 0.95f + vBloomColor.xyz * 0.05f, fLuminance, 0, fExposure);
// vColor.xyz = ToneMap(vColor.xyz, fLuminance, 0, fExposure);
// vColor.xyz += vBloomColor.xyz * (1.0 - CalcLuminance(vColor.xyz));
// vColor.xyz = vColor.xyz * 0.9f + vBloomColor.xyz * 0.1f;
return(vColor);
}
......@@ -11,11 +11,15 @@ gbuffer.ps
//##########################################################################
PSO_Gbuffer main(PSI_XMaterial IN)
PSO_Gbuffer main(PSI_XMaterial IN, bool isFrontFace:SV_IsFrontFace)
{
// ClipFar(IN.vPos.z, g_vNearFarLayers.y);
IN.vNormal = normalize(IN.vNormal);
if(!isFrontFace){
IN.vNormal *= -1.0f;
}
#ifndef WANT_WRITE_DEPTH
float fDepth = 1.0f - (IN.vPos.z / g_vNearFar.x);
#endif
......
......@@ -11,11 +11,15 @@ gbuffer.ps
//##########################################################################
float4 main(PSI_XMaterial IN):COLOR0
float4 main(PSI_XMaterial IN, bool isFrontFace:SV_IsFrontFace):COLOR0
{
// ClipFar(IN.vPos.z, g_vNearFarLayers.y);
IN.vNormal = normalize(IN.vNormal);
if(!isFrontFace){
IN.vNormal *= -1.0f;
}
XMaterial mtrl = XMATERIAL_MAIN(IN);
return(float4(mtrl.vEmissiveColor, 1.0));
......
......@@ -13,11 +13,15 @@ gbuffer.ps
//##########################################################################
PSO_RSMbuffer main(PSI_XMaterial IN)
PSO_RSMbuffer main(PSI_XMaterial IN, bool isFrontFace:SV_IsFrontFace)
{
// ClipFar(IN.vPos.z, g_vNearFarLayers.y);
IN.vNormal = normalize(IN.vNormal);
if(!isFrontFace){
IN.vNormal *= -1.0f;
}
PSO_RSMbuffer OUT;
#ifdef IS_CUBEMAP
// IN.vPos /= IN.vPos.w;
......
......@@ -21,7 +21,7 @@ cbuffer CDataClipPlanes: register(b6)
//##########################################################################
float4 main(PSI_XMaterial IN):COLOR0
float4 main(PSI_XMaterial IN, bool isFrontFace:SV_IsFrontFace):COLOR0
{
float3 vPos = IN.vPos.xyz / IN.vPos.w;
[unroll]for(uint i = 0; i < 4; ++i)
......@@ -35,6 +35,10 @@ float4 main(PSI_XMaterial IN):COLOR0
// ClipFar(IN.vPos.z, g_vNearFarLayers.y);
IN.vNormal = normalize(IN.vNormal);
if(!isFrontFace){
IN.vNormal *= -1.0f;
}
XMaterial mtrl = XMATERIAL_MAIN(IN);
float4 fWorldPos = mul(IN.vPos, g_mInvVP);
......
This diff is collapsed.
......@@ -8,39 +8,43 @@ ppe_gauss_blur.ps
//##########################################################################
half2 g_vSizeMap;
half g_fCoefBlur;
cbuffer b8: register(b8)
{
float2 g_vSizeMapInv;
float g_fCoefBlur;
};
//##########################################################################
sampler2D g_sTexture:register(s0);
SamplerState g_sLinearClamp: register(s0);
Texture2D g_txDiffuse: register(t0);
//##########################################################################
half4 main(VSO_PP IN) : COLOR0
float4 main(VSO_PP IN):SV_TARGET
{
#ifdef _H_
half2 vPixelOffset = half2(0.0,1.0/g_vSizeMap.y)*g_fCoefBlur;
float2 vPixelOffset = float2(0.0f, g_vSizeMapInv.y) * g_fCoefBlur;
#else
half2 vPixelOffset = half2(1.0/g_vSizeMap.x,0.f)*g_fCoefBlur;
float2 vPixelOffset = float2(g_vSizeMapInv.x, 0.0f) * g_fCoefBlur;
#endif
half2 vOffset = vPixelOffset;
float2 vOffset = vPixelOffset;
half4 vColor = tex2D(g_sTexture, IN.vTexUV) * 0.134598;
vColor += (tex2D(g_sTexture, IN.vTexUV + vOffset) + tex2D(g_sTexture, IN.vTexUV - vOffset)) * 0.127325;
float4 vColor = g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV) * 0.134598;
vColor += (g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV + vOffset) + g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV - vOffset)) * 0.127325;
vOffset += vPixelOffset;
vColor += (tex2D(g_sTexture, IN.vTexUV + vOffset) + tex2D(g_sTexture, IN.vTexUV - vOffset)) * 0.107778;
vColor += (g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV + vOffset) + g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV - vOffset)) * 0.107778;
vOffset += vPixelOffset;
vColor += (tex2D(g_sTexture, IN.vTexUV + vOffset) + tex2D(g_sTexture, IN.vTexUV - vOffset)) * 0.081638;
vColor += (g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV + vOffset) + g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV - vOffset)) * 0.081638;
vOffset += vPixelOffset;
vColor += (tex2D(g_sTexture, IN.vTexUV + vOffset) + tex2D(g_sTexture, IN.vTexUV - vOffset)) * 0.055335;
vColor += (g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV + vOffset) + g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV - vOffset)) * 0.055335;
vOffset += vPixelOffset;
vColor += (tex2D(g_sTexture, IN.vTexUV + vOffset) + tex2D(g_sTexture, IN.vTexUV - vOffset)) * 0.033562;
vColor += (g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV + vOffset) + g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV - vOffset)) * 0.033562;
vOffset += vPixelOffset;
vColor += (tex2D(g_sTexture, IN.vTexUV + vOffset) + tex2D(g_sTexture, IN.vTexUV - vOffset)) * 0.018216;
vColor += (g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV + vOffset) + g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV - vOffset)) * 0.018216;
vOffset += vPixelOffset;
vColor += (tex2D(g_sTexture, IN.vTexUV + vOffset) + tex2D(g_sTexture, IN.vTexUV - vOffset)) * 0.008847;
vColor += (g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV + vOffset) + g_txDiffuse.Sample(g_sLinearClamp, IN.vTexUV - vOffset)) * 0.008847;
vOffset += vPixelOffset;
return vColor;
......
......@@ -40,11 +40,12 @@ static int g_iNumSam = 8;
#endif
//##########################################################################
float4 main(VSO_ResPos IN):COLOR0
{
float fDepth = g_txDepth.Sample(g_sPointClamp, IN.vTexUV).r;
float3 vRndVec = normalize(2.0 * g_txNoise.Sample(g_sLinearWrap, IN.vTexUV * 16.0).rgb - 1.0);
// float3 vRndVec = normalize(2.0 * g_txNoise.Sample(g_sLinearWrap, IN.vTexUV * 0.03125 / g_vNearFarInvWinSize.zw).bgr - 1.0);
// float3 vRndVec = normalize(2.0 * g_txNoise.Sample(g_sLinearWrap, IN.vTexUV * 0.03125 / g_vNearFarInvWinSize.zw).bgr - 1.0);
float3 vRndVec = normalize(2.0 * g_txNoise.Sample(g_sLinearWrap, IN.vTexUV * 0.25 / g_vNearFarInvWinSize.zw).bgr - 1.0);
if(fDepth >= 1.0)
{
......@@ -54,40 +55,36 @@ float4 main(VSO_ResPos IN):COLOR0
float3 vPosition = float3(g_vObserverPosCam.xyz + IN.vWorldRay * fDepth);
float3 vNormal = normalize(NormalDecode(g_txNormals.Sample(g_sPointClamp, IN.vTexUV).xyz).xyz);
float3 vTangent = normalize(vRndVec - vNormal * dot(vRndVec, vNormal));
float3 vBitangent = cross(vNormal, vTangent);
float3x3 mTBN = float3x3(vTangent, vBitangent, vNormal);
// return float4(vNormal /** 0.5 + 0.5*/, 1);
float fOcclusion = 0.0;
[unroll]for(int i = 0; i < g_iNumSam; ++i)
{
float3 vRay = reflect(g_aRndVectors[i].xyz, vRndVec);
float3 vHemiRay = vRay * sign(dot(vRay, vNormal));
float3 vHemiRay = mul(g_aRndVectors[i].xyz, mTBN);
float4 vNewPos = float4(vPosition + vHemiRay * g_vParams.x, 1);
vNewPos = mul(vNewPos, g_mObserverVP);
float fNewDepth = 1.0f - (vNewPos.z / g_vObserverNearFar.x);
vNewPos /= vNewPos.w;
vNewPos.x = vNewPos.x * 0.5 + 0.5;
vNewPos.y = vNewPos.y * -0.5 + 0.5;
float newdepth = g_txDepth.Sample(g_sPointClamp, vNewPos.xy).r;
if(newdepth >= 1.0)
{
fOcclusion += 1.0;
}
float fDifference = (newdepth - fDepth) * g_vObserverNearFar.y;
float fSampleDepth = g_txDepth.Sample(g_sPointClamp, vNewPos.xy).r;
float fDistanceCheck = min(g_vParams.z, g_vParams.x / abs(fDifference));
if(abs(fDifference) < g_vParams.y)
{
fOcclusion += g_vParams.z;
}
else
{
fOcclusion += 1.0 - step(fDifference, g_vParams.w / g_vObserverNearFar.y) * fDistanceCheck;
}
float rangeCheck = smoothstep(0.0, 1.0, g_vParams.x / abs((fSampleDepth - fDepth) * g_vObserverNearFar.y));
fOcclusion += (fSampleDepth >= fNewDepth ? 0.0 : rangeCheck);
}
fOcclusion = clamp(saturate(fOcclusion / g_iNumSam), 0.2, 1.0);
fOcclusion = lerp(1.0, fOcclusion, 0.6);
fOcclusion = pow(fOcclusion, 2);
fOcclusion = lerp(1.0, fOcclusion, saturate((fDepth * g_vObserverNearFar.y) / PP_SSAO_DIST_EMERSION));
fOcclusion = 1.0 - saturate(fOcclusion / g_iNumSam);
// fOcclusion = lerp(1.0, fOcclusion, 0.6);
// fOcclusion = pow(fOcclusion, 2);
// fOcclusion = lerp(1.0, fOcclusion, saturate((fDepth * g_vObserverNearFar.y) / PP_SSAO_DIST_EMERSION));
return(float4(fOcclusion, fOcclusion, fOcclusion, 1));
}
#include <struct.h>
#include <mtrl.h>
#include <const.h>
//##########################################################################
Texture2D g_txAO: register(t0);
SamplerState g_sPointClamp: register(s0);
float4 main(VSO_PP IN):COLOR0
{
float2 vTexelSize = g_vNearFarInvWinSize.zw;
float vAOSample = 0.0f;
[unroll]
for(int x = -2; x < 2; ++x)
{
[unroll]
for(int y = -2; y < 2; ++y)
{
float2 vOffset = float2(float(x), float(y)) * vTexelSize;
vAOSample += g_txAO.Sample(g_sPointClamp, IN.vTexUV + vOffset).r;
}
}
vAOSample /= (4.0f * 4.0f);
return(float4(vAOSample.xxx, 1.0f));
}
......@@ -33,6 +33,8 @@ VSO_SceneCommon SkinBoneTransform(uint iBone, float weight, VSI_Animation v)
float4 q = g_BufferBoneWorld[iBone + 1];
Output.vPosition = float4((SkinRotateVec(q, v.vPosition) + bpos.xyz) * weight, 1.0);
Output.vNormal = SkinRotateVec(q, v.vNormal) * weight;
Output.vTangent = SkinRotateVec(q, v.vTangent) * weight;
Output.vBinormal = SkinRotateVec(q, v.vBinormal) * weight;
return(Output);
}
......@@ -49,6 +51,8 @@ VSO_SceneCommon SkinAllTransform(VSI_Animation v)
o = SkinBoneTransform(iBone, fWeight, v);
Output.vPosition += o.vPosition;
Output.vNormal += o.vNormal;
Output.vTangent += o.vTangent;
Output.vBinormal += o.vBinormal;
//Bone1
iBone = v.vBones.y;
......@@ -56,6 +60,8 @@ VSO_SceneCommon SkinAllTransform(VSI_Animation v)
o = SkinBoneTransform(iBone, fWeight, v);
Output.vPosition += o.vPosition;
Output.vNormal += o.vNormal;
Output.vTangent += o.vTangent;
Output.vBinormal += o.vBinormal;
//Bone2
iBone = v.vBones.z;
......@@ -63,13 +69,18 @@ VSO_SceneCommon SkinAllTransform(VSI_Animation v)
o = SkinBoneTransform(iBone, fWeight, v);
Output.vPosition += o.vPosition;
Output.vNormal += o.vNormal;
Output.vTangent += o.vTangent;
Output.vBinormal += o.vBinormal;
//Bone3
iBone = v.vBones.w;
fWeight = v.vWeights.w;
// fWeight = v.vWeights.w;
fWeight = 1.0 - (v.vWeights.x + v.vWeights.y + v.vWeights.z);
o = SkinBoneTransform(iBone, fWeight, v);
Output.vPosition += o.vPosition;
Output.vNormal += o.vNormal;
Output.vTangent += o.vTangent;
Output.vBinormal += o.vBinormal;
Output.vPosition.w = 1.0;
......
......@@ -129,6 +129,7 @@ struct VSO_SceneCommon
float4 vPos :TEXCOORD2;
float3 vTangent :TEXCOORD3;
float3 vBinormal :TEXCOORD4;
uint4 uInstanceId :BLENDINDICES0;
};
struct GSO_SceneShadows
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment