- 博客(0)
- 资源 (4)
- 收藏
- 关注
Introduction_to_3D_Game_Programming_with_Directx_12.zip
最新龙书,含各章节目录,学习D3D12神器
LICENSE DISCLAIMER OF LIABILITY AND LIMITED WARRANTY
By purchasing or using this book (the "Work), you agree that this license grants
permission to use the contents contained herein, but does not give you the right of
ownership to any of the textual content in the book or ownership to any of the information
or products contained in it. This license does not permit uploading of the Work onto the
Internet or on a network (of any kind) without the written consent of the Publisher.
Duplication or dissemination of any text, code, simulations, images, etc. contained herein
is limited to and subject to licensing terms for the respective products, and permission
must be obtained from the publisher or the owner of the content. etc. in order to
reproduce or network any portion of the textual material (in any media) that is contained
in the work
MERCURY LEARNING AND INFORMATION(“ MLP or“ the publisher”) and anyone
involved in the creation, writing, or production of the companion disc, accompanying
algorithms, code, or computer programs("the software ) and any accompanying Web site
or software of the Work, cannot and do not warrant the performance or results that might
be obtained by using the contents of the Work. The author, developers, and the Publisher
have used their best efforts to insure the accuracy and functionality of the textual material
and/or programs contained in this package; we, however, make no warranty of any kind,
express or implied, regarding the performance of these contents or programs. The Work is
sold"as is without warranty (except for defective materials used in manufacturing the
book or due to faulty workmanship)
The author, developers, and the publisher of any accompanying content, and anyone
involved in the composition, production, and manufacturing of this work will not be liable
for damages of any
kind arising out of the use of (or the inability to use) the algorithms
2021-08-10
Visual Assist X 2270 最新原版+完美破解补丁 不弹窗
VS2010 - VS2017 C++编程助手
支持Unreal Engine4
visual assist x 2270 最新原版+完美破解补丁,亲测可用,不弹窗
2018-07-16
头发各向异性渲染
头发各向异性渲染Shader
这个是04年的一个ppt,主要介绍了头发的渲染,其追到源头还是要看这个原理。
各向异性的主要计算公式:
主要代码如下:
切线混合扰动部分(这部分也可以用T+k*N,来对切线进行扰动):
float3x3 tangentTransform = float3x3(i.tangentDir, i.bitangentDir, i.normalDir);
float3 _T_var = UnpackNormal(tex2D(_Tangent, TRANSFORM_TEX(i.uv0, _Tangent)));
float3 temp = lerp(_TangentParam.xyz, _T_var, _BlenfTangent);
float3 T = normalize(mul(float3(temp.xy,0), tangentTransform));
主要是通过改变切线的xy值来造成头发高光部分的多样性。
高光部分,按公式计算即可:
float StrandSpecular(float3 T, float3 V, float3 L, float exponent)
{
float3 H = normalize(L + V);
float dotTH = dot(T, H);
float sinTH = sqrt(1 - dotTH*dotTH);
float dirAtten = smoothstep(-1, 0, dotTH);
return dirAtten*pow(sinTH, exponent);
}
注意,为了模拟的更贴近真实性,应用两层高光,第一层高光代表直射光直接反射出去,第二层代表次表面散射现象具体看代码。
最终渲染部分:
float4 HairLighting(float3 T, float3 N, float3 L, float3 V, float2 uv, float3 lightColor)
{
float diffuse = saturate(lerp(0.25, 1.0, dot(N, L)))*lightColor;
float3 indirectDiffuse = float3(0, 0, 0);
indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light
float3 H = normalize(L + V);
float LdotH = saturate(dot(L, H));
float3 specular = _Specular*StrandSpecular(T, V, L, exp2(lerp(1, 11, _Gloss)));
//float specMask = tex2D(_SpecMask, TRANSFORM_TEX(uv, _SpecMask));
specular += /*specMask*/_SubColor*StrandSpecular(T, V, L, exp2(lerp(1, 11, _ScatterFactor)));
float4 final;
float4 base = tex2D(_MainTex, TRANSFORM_TEX(uv, _MainTex));
float3 diffuseColor = (_Color.rgb*base.rgb);
//float ao = tex2D(_AO, TRANSFORM_TEX(uv, _AO)).g;
final.rgb = (diffuse + indirectDiffuse)*diffuseColor + specular*lightColor* FresnelTerm(_Specular, LdotH);
//final.rgb *= ao;
final.a = base.a;
clip(final.a - _CutOff);
return final;
}
这里我注释掉了AO和高光遮罩,需要的同学可以加上。
最后一点为了不让头发的边经过clip之后太硬,需要进行两个通道的belnd。
第二个pass使用以下指令:
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
注意第二个通道无需再进行clip操作。
至此,头发渲染完毕。
2018-07-04
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人