ããŒã1.ãžãããŒ
ãã®ããŒãã§ã¯ãWitcher 3ïŒWild Huntã§çš²åŠ»ãã¬ã³ããªã³ã°ããããã»ã¹ãèŠãŠãããŸãã
é·ã®ã¬ã³ããªã³ã°ã¯ã
ã¬ã€ã³ã«ãŒãã³ãšãã§ã¯ããããå°ãé
ããŠå®è¡ãããŸããããã€ã¬ã¯ãã¬ã³ããªã³ã°ãã¹ã§ã¯åŒãç¶ãçºçããŸãã é·ã¯ãã®ãããªã§èŠãããšãã§ããŸãïŒ
ããã«æ¶ããŠããŸãã®ã§ã0.25ã®é床ã§åç»ãèŠãã®ãè¯ãã§ãããã
ãããã¯éæ¢ç»åã§ã¯ãªãããšãããããŸãã æéãçµã€ã«ã€ããŠãæããã¯ãããã«å€åããŸãã
ãã¥ã¢ã³ã¹ã®ã¬ã³ããªã³ã°ã®èŠ³ç¹ããã¯ãããšãã°ãåãç¶æ
ã®ããã·ã³ã°ïŒè¿œå ããã·ã³ã°ïŒãšæ·±åºŠïŒãã§ãã¯ãæå¹ã深床èšé²ã¯å®è¡ãããªãïŒãªã©ãé ãã«éšã®ã«ãŒãã³ãæãããšã«ã¯å€ãã®é¡äŒŒç¹ããããŸãã
é·ã®ãªãã·ãŒã³é·ã·ãŒã³çš²åŠ»ã®å¹ŸäœåŠã«é¢ããŠããŠã£ããã£ãŒ3ã¯æšã®ãããªã¡ãã·ã¥ã§ãã ãã®çš²åŠ»ã®äŸã¯ã次ã®ã¡ãã·ã¥ã§è¡šãããŸãã
UV座æšãšæ³ç·ãã¯ãã«ããããŸãã ãããã¯ãã¹ãŠãé ç¹ã·ã§ãŒããŒã¹ããŒãžã§åœ¹ç«ã¡ãŸãã
é ç¹ã·ã§ãŒããŒ
çµã¿ç«ãŠãããé ç¹ã·ã§ãŒããŒã³ãŒããèŠãŠã¿ãŸãããã
vs_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb1[9], immediateIndexed dcl_constantbuffer cb2[6], immediateIndexed dcl_input v0.xyz dcl_input v1.xy dcl_input v2.xyz dcl_input v4.xyzw dcl_input v5.xyzw dcl_input v6.xyzw dcl_input v7.xyzw dcl_output o0.xy dcl_output o1.xyzw dcl_output_siv o2.xyzw, position dcl_temps 3 0: mov o0.xy, v1.xyxx 1: mov o1.xyzw, v7.xyzw 2: mul r0.xyzw, v5.xyzw, cb1[0].yyyy 3: mad r0.xyzw, v4.xyzw, cb1[0].xxxx, r0.xyzw 4: mad r0.xyzw, v6.xyzw, cb1[0].zzzz, r0.xyzw 5: mad r0.xyzw, cb1[0].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r0.xyzw 6: mov r1.w, l(1.000000) 7: mad r1.xyz, v0.xyzx, cb2[4].xyzx, cb2[5].xyzx 8: dp4 r2.x, r1.xyzw, v4.xyzw 9: dp4 r2.y, r1.xyzw, v5.xyzw 10: dp4 r2.z, r1.xyzw, v6.xyzw 11: add r2.xyz, r2.xyzx, -cb1[8].xyzx 12: dp3 r1.w, r2.xyzx, r2.xyzx 13: rsq r1.w, r1.w 14: div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.w 15: mul r1.w, r1.w, l(0.000001) 16: mad r2.xyz, v2.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000) 17: mad r1.xyz, r2.xyzx, r1.wwww, r1.xyzx 18: mov r1.w, l(1.000000) 19: dp4 o2.x, r1.xyzw, r0.xyzw 20: mul r0.xyzw, v5.xyzw, cb1[1].yyyy 21: mad r0.xyzw, v4.xyzw, cb1[1].xxxx, r0.xyzw 22: mad r0.xyzw, v6.xyzw, cb1[1].zzzz, r0.xyzw 23: mad r0.xyzw, cb1[1].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r0.xyzw 24: dp4 o2.y, r1.xyzw, r0.xyzw 25: mul r0.xyzw, v5.xyzw, cb1[2].yyyy 26: mad r0.xyzw, v4.xyzw, cb1[2].xxxx, r0.xyzw 27: mad r0.xyzw, v6.xyzw, cb1[2].zzzz, r0.xyzw 28: mad r0.xyzw, cb1[2].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r0.xyzw 29: dp4 o2.z, r1.xyzw, r0.xyzw 30: mul r0.xyzw, v5.xyzw, cb1[3].yyyy 31: mad r0.xyzw, v4.xyzw, cb1[3].xxxx, r0.xyzw 32: mad r0.xyzw, v6.xyzw, cb1[3].zzzz, r0.xyzw 33: mad r0.xyzw, cb1[3].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r0.xyzw 34: dp4 o2.w, r1.xyzw, r0.xyzw 35: ret
é ç¹ã¬ã€ã³ã«ãŒãã³ã·ã§ãŒããŒã«ã¯å€ãã®é¡äŒŒç¹ããããããããã§ã¯ç¹°ãè¿ããŸããã 11ã18è¡ç®ã«ããéèŠãªéãã瀺ããŸãã
11: add r2.xyz, r2.xyzx, -cb1[8].xyzx 12: dp3 r1.w, r2.xyzx, r2.xyzx 13: rsq r1.w, r1.w 14: div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.w 15: mul r1.w, r1.w, l(0.000001) 16: mad r2.xyz, v2.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000) 17: mad r1.xyz, r2.xyzx, r1.wwww, r1.xyzx 18: mov r1.w, l(1.000000) 19: dp4 o2.x, r1.xyzw, r0.xyzw
ãŸããcb1 [8] .xyzã¯ã«ã¡ã©ã®äœçœ®ã§ãããr2.xyzã¯ã¯ãŒã«ã空éã®äœçœ®ã§ããã€ãŸããã©ã€ã³11ã¯ã«ã¡ã©ããã¯ãŒã«ãã®äœçœ®ãŸã§ã®ãã¯ãã«ãèšç®ããŸãã 次ã«ãè¡12ã15ã¯
é·ãïŒworldPos-cameraPosïŒ* 0.000001ãèšç®ã
ãŸããv2.xyzã¯ãçä¿¡ãžãªã¡ããªã®æ³ç·ãã¯ãã«ã§ãã è¡16ã¯ãéé[0-1]ããéé[-1; 1]ã«æ¡åŒµããŸãã
次ã«ãäžçã®æçµäœçœ®ãèšç®ãããŸãã
finalWorldPos = worldPos + lengthïŒworldPos-cameraPosïŒ* 0.000001 * normalVectorãã®æäœã®HLSLã³ãŒãã¹ããããã¯æ¬¡ã®ããã«ãªããŸãã
...
ãã®æäœã«ãããã¡ãã·ã¥ã®å°ããªãããŒã¹ãããçºçããŸãïŒæ³ç·ãã¯ãã«ã®æ¹åïŒã 0.000001ãä»ã®ããã€ãã®å€ã«çœ®ãæããŠå®éšããŸããã çµæã¯æ¬¡ã®ãšããã§ãã
0.0000020.0000050.000010.000025ãã¯ã»ã«ã·ã§ãŒããŒ
ããŠãé ç¹ã·ã§ãŒããŒãç解ããã®ã§ãä»åºŠã¯ãã¯ã»ã«ã·ã§ãŒããŒã®ã¢ã»ã³ãã©ãŒã³ãŒãã«åãæãããŸãïŒ
ps_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[1], immediateIndexed dcl_constantbuffer cb2[3], immediateIndexed dcl_constantbuffer cb4[5], immediateIndexed dcl_input_ps linear v0.x dcl_input_ps linear v1.w dcl_output o0.xyzw dcl_temps 1 0: mad r0.x, cb0[0].x, cb4[4].x, v0.x 1: add r0.y, r0.x, l(-1.000000) 2: round_ni r0.y, r0.y 3: ishr r0.z, r0.y, l(13) 4: xor r0.y, r0.y, r0.z 5: imul null, r0.z, r0.y, r0.y 6: imad r0.z, r0.z, l(0x0000ec4d), l(0.0000000000000000000000000000000000001) 7: imad r0.y, r0.y, r0.z, l(146956042240.000000) 8: and r0.y, r0.y, l(0x7fffffff) 9: round_ni r0.z, r0.x 10: frc r0.x, r0.x 11: add r0.x, -r0.x, l(1.000000) 12: ishr r0.w, r0.z, l(13) 13: xor r0.z, r0.z, r0.w 14: imul null, r0.w, r0.z, r0.z 15: imad r0.w, r0.w, l(0x0000ec4d), l(0.0000000000000000000000000000000000001) 16: imad r0.z, r0.z, r0.w, l(146956042240.000000) 17: and r0.z, r0.z, l(0x7fffffff) 18: itof r0.yz, r0.yyzy 19: mul r0.z, r0.z, l(0.000000001) 20: mad r0.y, r0.y, l(0.000000001), -r0.z 21: mul r0.w, r0.x, r0.x 22: mul r0.x, r0.x, r0.w 23: mul r0.w, r0.w, l(3.000000) 24: mad r0.x, r0.x, l(-2.000000), r0.w 25: mad r0.x, r0.x, r0.y, r0.z 26: add r0.y, -cb4[2].x, cb4[3].x 27: mad_sat r0.x, r0.x, r0.y, cb4[2].x 28: mul r0.x, r0.x, v1.w 29: mul r0.yzw, cb4[0].xxxx, cb4[1].xxyz 30: mul r0.xyzw, r0.xyzw, cb2[2].wxyz 31: mul o0.xyz, r0.xxxx, r0.yzwy 32: mov o0.w, r0.x 33: ret
æå ±ïŒã³ãŒãã¯ããã»ã©é·ããããŸããã
æªããã¥ãŒã¹ïŒ
3: ishr r0.z, r0.y, l(13) 4: xor r0.y, r0.y, r0.z 5: imul null, r0.z, r0.y, r0.y 6: imad r0.z, r0.z, l(0x0000ec4d), l(0.0000000000000000000000000000000000001) 7: imad r0.y, r0.y, r0.z, l(146956042240.000000) 8: and r0.y, r0.y, l(0x7fffffff)
...ããã¯äœã§ããïŒ
æ£çŽãªãšãããããããŠã£ããã£ãŒ3ã·ã§ãŒããŒã®ã¢ã»ã³ãã©ãŒã³ãŒãã®äžéšãèŠãã®ã¯ãããåããŠã§ã¯ãããŸããã ããããåããŠåœŒã«äŒã£ããšãããããã¯äžäœäœã ïŒããšæã£ãã
åæ§ã®ããšããä»ã®TW3ã·ã§ãŒããŒã«ãèŠãããŸãã ãã®ãã©ã°ã¡ã³ãã§ã®åéºã«ã€ããŠã¯èª¬æãããçãã¯
æŽæ°ãã€ãºã«ãããšã ãèšã
ãŸã ã
ã芧ã®ãšããããã¯ã»ã«ã·ã§ãŒããŒã§2ååŒã³åºãããŸãã ãã®Webãµã€ãã®ã¬ã€ãã䜿çšããŠãã¹ã ãŒãºãã€ãºãæ£ããå®è£
ãããŠããããšãç解ã§ããŸãã ããã«ã€ããŠã¯åŸã§èª¬æããŸãã
è¡0ãèŠãŠãã ãããããã§ã¯ã次ã®åŒã«åºã¥ããŠã¢ãã¡ãŒã·ã§ã³åããŠããŸãã
ã¢ãã¡ãŒã·ã§ã³=çµéæé* animationSpeed + TextureUV.xãããã®å€ã¯ãå°æ¥äžåŽã«äžžããããåŸïŒ
floor ïŒïŒåœä»€
round_ni ïŒãæŽæ°ãã€ãºã®å
¥åãã€ã³ãã«ãªããŸãã éåžžã2ã€ã®æŽæ°ã®ãã€ãºå€ãèšç®ããŠããããããã®éã®æçµçãªè£éå€ãèšç®ããŸãïŒè©³çŽ°ã«ã€ããŠã¯ãlibnoiseã®Webãµã€ããåç
§ããŠãã ããïŒã
ããŠãããã¯
æŽæ°ãã€ãºã§ãããåè¿°ã®ãã¹ãŠã®å€ïŒåãæšãŠïŒããã¹ãŠæµ®åå°æ°ç¹ã§ãïŒ
ããã«ã¯
ftoiã®æ瀺ããªãããšã«æ³šæããŠ
ãã ãã ã CD Projekt Redã®ããã°ã©ããŒã¯ã
ããã§HLSL
asintå
éšé¢æ°ã䜿çšãããšä»®å®ã
ãŸã ãããã¯ãã
reinterpret_cast ãæµ®åå°æ°ç¹å€ã®å€æãå®è¡ããæŽæ°ãã¿ãŒã³ãšããŠæ±ããŸãã
2ã€ã®å€ã®è£ééã¿ã¯ã10ã11è¡ç®ã§èšç®ãããŸãã
InterpolationWeight = 1.0-fracïŒã¢ãã¡ãŒã·ã§ã³ïŒ;ãã®ã¢ãããŒãã«ãããæéã®çµéãšãšãã«å€ãè£éã§ããŸãã
æ»ãããªãã€ãºãäœæããã«ã¯ããã®è£éé¢æ°ã
SCurveé¢æ°ã«
æž¡ããŸãã
float s_curve( float x ) { float x2 = x * x; float x3 = x2 * x;
Smoothstepé¢æ°[libnoise.sourceforge.net]ãã®æ©èœã¯ãã¹ã ãŒãºã¹ãããããšããŠç¥ãããŠããŸãã ãããã
ã¢ã»ã³ãã©ãŒã³ãŒããããããããã«ãããã¯HLSLã®å
éšã®
smoothstepé¢æ°ã§ã¯ãã
ãŸãã ã å
éšé¢æ°ã¯ãå€ãçã«ãªãããã«å¶éãé©çšããŸãã ãã ãã
interpolationWeightã®ç¯å²ã¯åžžã«[0-1]ã§ããããšãããã£ãŠããããããããã®ãã§ãã¯ã¯å®å
šã«ã¹ãããã§ããŸãã
æçµå€ãèšç®ãããšããããã€ãã®ä¹ç®æŒç®ã䜿çšãããŸãã æçµçãªã¢ã«ãã¡åºåããã€ãºå€ã«å¿ããŠã©ã®ããã«å€åãããã確èªããŠãã ããã ããã¯ãå®éã®ç掻ãšåãããã«ãã¬ã³ããªã³ã°ããã皲劻ã®äžéæ床ã«åœ±é¿ãããã䟿å©ã§ãã
ã¬ãã£ãã¯ã»ã«ã·ã§ãŒããŒïŒ
cbuffer cbPerFrame : register (b0) { float4 cb0_v0; float4 cb0_v1; float4 cb0_v2; float4 cb0_v3; } cbuffer cbPerFrame : register (b2) { float4 cb2_v0; float4 cb2_v1; float4 cb2_v2; float4 cb2_v3; } cbuffer cbPerFrame : register (b4) { float4 cb4_v0; float4 cb4_v1; float4 cb4_v2; float4 cb4_v3; float4 cb4_v4; } struct VS_OUTPUT { float2 Texcoords : Texcoord0; float4 InstanceLODParams : INSTANCE_LOD_PARAMS; float4 PositionH : SV_Position; };
ãŸãšãããš
ãã®ããŒãã§ã¯ãThe Witcher 3ã§çš²åŠ»ãã¬ã³ããªã³ã°ããæ¹æ³ã«ã€ããŠèª¬æããŸããã
ç§ã®ã·ã§ãŒããŒããåºãã¢ã»ã³ãã©ãŒã³ãŒããå
ã®ã³ãŒããšå®å
šã«äžèŽããããšãéåžžã«å¬ããæããŸãïŒ
ããŒã2.æããªç©ºã®ããªãã¯
ãã®éšåã¯ãåã®éšåãšãããã«ç°ãªããŸãã ãã®äžã§ãã¹ã«ã€ã·ã§ãŒããŒãŠã£ããã£ãŒ3ã®ããã€ãã®åŽé¢ã玹ä»ããããšæããŸãã
ãªãã·ã§ãŒããŒå
šäœã§ã¯ãªããæããªããªãã¯ããªã®ãïŒ ããŠãããã€ãã®çç±ããããŸãã ãŸããWitcher 3ã¹ã«ã€ã·ã§ãŒããŒã¯ããªãè€éãªç£ã§ãã 2015ããŒãžã§ã³ã®ãã¯ã»ã«ã·ã§ãŒããŒã«ã¯267è¡ã®ã¢ã»ã³ãã©ã³ãŒããå«ãŸããBlood and Wine DLCã®ã·ã§ãŒããŒã«ã¯385è¡ãå«ãŸããŠããŸãã
ããã«ã圌ãã¯å€ãã®å
¥åãåãåããŸãããããã¯å®å
šãªïŒãããŠèªã¿ãããïŒïŒHLSLã³ãŒãã®ãªããŒã¹ãšã³ãžãã¢ãªã³ã°ã«ã¯ããŸã圹ç«ã¡ãŸããã
ãããã£ãŠããããã®ã·ã§ãŒããŒããã®ããªãã¯ã®äžéšã®ã¿ã衚瀺ããããšã«ããŸããã äœãæ°ãããã®ãèŠã€ãããããã®èšäºãè£è¶³ããŸãã
2015ããŒãžã§ã³ãšDLCïŒ2016ïŒã®éãã¯éåžžã«é¡èã§ãã ç¹ã«ãæãšãã®ã¡ãã€ãã®èšç®ã®éãã倪éœãã¬ã³ããªã³ã°ããããã®ç°ãªãã¢ãããŒããå«ãŸããŠããŸã
ããã©ããã¢ã³ãã¯ã€ã³ã·ã§ãŒããŒã¯ãå€ã®å€©ã®å·ãèšç®ããŸãã
åºæ¬ããå§ããŠãæããªããªãã¯ã«ã€ããŠè©±ããŸãããã
åºæ¬
ã»ãšãã©ã®çŸä»£ã®ã²ãŒã ãšåæ§ã«ããŠã£ããã£ãŒ3ã¯ã¹ã«ã€ããŒã ã䜿çšããŠç©ºãã¢ãã«åããŸãã ãŠã£ããã£ãŒ3ïŒ2015ïŒã§ããã«äœ¿çšãããåçãèŠãŠãã ããã 泚ïŒãã®å Žåããã®ã¡ãã·ã¥ã®ããŠã³ãã£ã³ã°ããã¯ã¹ã¯[0,0,0]ãã[1,1,1]ïŒZã¯äžåãã®è»žïŒã®ç¯å²ã«ãããUVãã¹ã ãŒãºã«ååžããŠããŸãã åŸã§äœ¿çšããŸãã
ã¹ã«ã€ããŒã ã®èåŸã«ããèãæ¹ã¯ã
ã¹ã«ã€ããã¯ã¹ã®èãæ¹ã«äŒŒãŠããŸãïŒå¯äžã®éãã¯ã䜿çšãããã¡ãã·ã¥ã§ãïŒã é ç¹ã·ã§ãŒããŒã¹ããŒãžã§ã¯ã芳枬è
ã«å¯ŸããŠã¹ã«ã€ããŒã ãå€æããŸãïŒéåžžã¯ã«ã¡ã©ã®äœçœ®ã«å¿ããŠïŒãããã«ããã空ãå®éã«ã¯éåžžã«é ãã«ãããšããé¯èŠãçããŸãã
ãã®äžé£ã®èšäºã®åã®éšåãèªããšããThe Witcher 3ãã¯é深床ã䜿çšããŠããããšãããããŸããã€ãŸããé æ¹ã®å¹³é¢ã¯0.0fã§ãæãè¿ãå¹³é¢ã¯1.0fã§ãã ã¹ã«ã€ããŒã åºåãå®å
šã«é æ¹ã®å¹³é¢ã§å®è¡ããããã«ããã©ãŠãºãŠã£ã³ããŠã®ãã©ã¡ãŒã¿ãŒã§
MinDepthãMaxDepthãšåãå€ã«èšå®ããŸãã
åç
§ãŠã£ã³ããŠã®å€æäžã«
MinDepthããã³
MaxDepthãã£ãŒã«ããã©ã®ããã«äœ¿çšããããã«ã€ããŠã¯ããããã¯ãªãã¯ïŒdocs.microsoft.comïŒããŠãã ããã
é ç¹ã·ã§ãŒããŒ
é ç¹ã·ã§ãŒããŒããå§ããŸãããã ãŠã£ããã£ãŒ3ïŒ2015ïŒã§ã¯ãã¢ã»ã³ãã©ãŒã·ã§ãŒããŒã³ãŒãã¯æ¬¡ã®ãšããã§ãã
vs_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb1[4], immediateIndexed dcl_constantbuffer cb2[6], immediateIndexed dcl_input v0.xyz dcl_input v1.xy dcl_output o0.xy dcl_output o1.xyz dcl_output_siv o2.xyzw, position dcl_temps 2 0: mov o0.xy, v1.xyxx 1: mad r0.xyz, v0.xyzx, cb2[4].xyzx, cb2[5].xyzx 2: mov r0.w, l(1.000000) 3: dp4 o1.x, r0.xyzw, cb2[0].xyzw 4: dp4 o1.y, r0.xyzw, cb2[1].xyzw 5: dp4 o1.z, r0.xyzw, cb2[2].xyzw 6: mul r1.xyzw, cb1[0].yyyy, cb2[1].xyzw 7: mad r1.xyzw, cb2[0].xyzw, cb1[0].xxxx, r1.xyzw 8: mad r1.xyzw, cb2[2].xyzw, cb1[0].zzzz, r1.xyzw 9: mad r1.xyzw, cb1[0].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r1.xyzw 10: dp4 o2.x, r0.xyzw, r1.xyzw 11: mul r1.xyzw, cb1[1].yyyy, cb2[1].xyzw 12: mad r1.xyzw, cb2[0].xyzw, cb1[1].xxxx, r1.xyzw 13: mad r1.xyzw, cb2[2].xyzw, cb1[1].zzzz, r1.xyzw 14: mad r1.xyzw, cb1[1].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r1.xyzw 15: dp4 o2.y, r0.xyzw, r1.xyzw 16: mul r1.xyzw, cb1[2].yyyy, cb2[1].xyzw 17: mad r1.xyzw, cb2[0].xyzw, cb1[2].xxxx, r1.xyzw 18: mad r1.xyzw, cb2[2].xyzw, cb1[2].zzzz, r1.xyzw 19: mad r1.xyzw, cb1[2].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r1.xyzw 20: dp4 o2.z, r0.xyzw, r1.xyzw 21: mul r1.xyzw, cb1[3].yyyy, cb2[1].xyzw 22: mad r1.xyzw, cb2[0].xyzw, cb1[3].xxxx, r1.xyzw 23: mad r1.xyzw, cb2[2].xyzw, cb1[3].zzzz, r1.xyzw 24: mad r1.xyzw, cb1[3].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r1.xyzw 25: dp4 o2.w, r0.xyzw, r1.xyzw 26: ret
ãã®å Žåãé ç¹ã·ã§ãŒããŒã¯ãtexcoordsãšã¯ãŒã«ã空éå
ã®äœçœ®ã®ã¿ãåºåã«è»¢éããŸãã
Blood and Wineã§ã¯ ãæ£èŠåãããæ³ç·ãã¯ãã«ã衚瀺ããŸãã 2015幎çã¯ããã·ã³ãã«ãªã®ã§ãæ€èšããŸãã
cb2ãšããŠæå®ãããå®æ°ãããã¡ãèŠãŠãã ããïŒ
ããã«ãäžçã®ãããªãã¯ã¹ããããŸãïŒ100ã«ããåäžãªã¹ã±ãŒãªã³ã°ãšã«ã¡ã©ã®äœçœ®ã«çžå¯Ÿçãªè»¢éïŒã è€éãªããšã¯äœããããŸããã cb2_v4ãšcb2_v5ã¯ãé ç¹äœçœ®ãéé[0-1]ããéé[-1; 1]ã«å€æããããã«äœ¿çšãããã¹ã±ãŒã«/åå·®ä¿æ°ã§ãã ããããããã§ã¯ããããã®ä¿æ°ã¯Z軞ããå§çž®ãããŸãïŒäžæ¹åïŒã
ã·ãªãŒãºã®åã®ããŒãã§ã¯ãåæ§ã®é ç¹ã·ã§ãŒããŒããããŸããã äžè¬çãªã¢ã«ãŽãªãºã ã¯ãtexcoordsãããã«è»¢éããã¹ã±ãŒã«/åå·®ä¿æ°ãèæ
®ããŠ
äœçœ®ãèšç®ãã次ã«ã¯ãŒã«ã空éã§
PositionWãèšç®ãã
matWorldãš
matViewProjãä¹ç®ããŠã¯ãªããã³ã°ç©ºéã®æçµäœçœ®ãèšç®ããŸãã ã
ãããã£ãŠããã®é ç¹ã·ã§ãŒããŒã®HLSLã¯æ¬¡ã®ããã«ãªããŸãã
struct InputStruct { float3 param0 : POSITION; float2 param1 : TEXCOORD; float3 param2 : NORMAL; float4 param3 : TANGENT; }; struct OutputStruct { float2 param0 : TEXCOORD0; float3 param1 : TEXCOORD1; float4 param2 : SV_Position; }; OutputStruct EditedShaderVS(in InputStruct IN) { OutputStruct OUT = (OutputStruct)0;
ç§ã®ã·ã§ãŒããŒïŒå·ŠïŒãšãªãªãžãã«ïŒå³ïŒã®æ¯èŒïŒ
RenderDocã®åªããç¹æ§ã¯ãå
ã®ã·ã§ãŒããŒã®ä»£ããã«ç¬èªã®ã·ã§ãŒããŒã泚å
¥ã§ããããšã§ãããããã®å€æŽã¯ããã¬ãŒã ã®æåŸãŸã§ãã€ãã©ã€ã³ã«åœ±é¿ããŸãã HLSLã³ãŒããããããããã«ãæçµãžãªã¡ããªããºãŒã ããã³å€æããããã®ãªãã·ã§ã³ãããã€ãçšæãããŠããŸãã ããããè©ŠããŠãéåžžã«é¢çœãçµæãåŸãããšãã§ããŸãïŒ
é ç¹ã·ã§ãŒããŒã®æé©å
å
ã®é ç¹ã·ã§ãŒããŒã®åé¡ã«æ°ã¥ããŸãããïŒ è¡åãšè¡åã®é ç¹ä¹ç®ã¯å®å
šã«åé·ã§ãïŒ ãããå°ãªããšãããã€ãã®é ç¹ã·ã§ãŒããŒã§èŠã€ããŸããïŒããšãã°ãã·ã§ãŒããŒã§
é ãã®éšã®
ã«ãŒãã³ ïŒã
PositionWã«
matViewProjãããã«æããããšã§æé©åã§ããŸãïŒ
ãããã£ãŠããã®ã³ãŒããHLSLã«çœ®ãæããããšãã§ããŸãã
次ã®ããã«ïŒ
æé©åãããããŒãžã§ã³ã¯ã次ã®ã¢ã»ã³ããªã³ãŒããæäŸããŸãã
vs_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer CB1[4], immediateIndexed dcl_constantbuffer CB2[6], immediateIndexed dcl_input v0.xyz dcl_input v1.xy dcl_output o0.xy dcl_output o1.xyz dcl_output_siv o2.xyzw, position dcl_temps 2 0: mov o0.xy, v1.xyxx 1: mad r0.xyz, v0.xyzx, cb2[4].xyzx, cb2[5].xyzx 2: mov r0.w, l(1.000000) 3: dp4 r1.x, r0.xyzw, cb2[0].xyzw 4: dp4 r1.y, r0.xyzw, cb2[1].xyzw 5: dp4 r1.z, r0.xyzw, cb2[2].xyzw 6: mov o1.xyz, r1.xyzx 7: mov r1.w, l(1.000000) 8: dp4 o2.x, cb1[0].xyzw, r1.xyzw 9: dp4 o2.y, cb1[1].xyzw, r1.xyzw 10: dp4 o2.z, cb1[2].xyzw, r1.xyzw 11: dp4 o2.w, cb1[3].xyzw, r1.xyzw 12: ret
ã芧ã®ãšãããåœä»€ã®æ°ã26ãã12ã«æžãããŸãããããã¯éåžžã«å€§ããªå€æŽã§ãã ãã®åé¡ãã²ãŒã å
ã§ã©ãã»ã©åºç¯å²ã«åºãã£ãŠããã®ãããããŸããããç¥ã®ããã«CD Projekt Redã¯ãããããªãªãŒã¹ãããããããŸããã :)
ãããŠãç§ã¯åè«ã§ã¯ãããŸããã å
ã®RenderDocã®ä»£ããã«æé©åãããã·ã§ãŒããŒãæ¿å
¥ãããšããã®æé©åã¯èŠèŠçã«ã¯äœã«ã圱é¿ããªãããšãããããŸãã æ£çŽãªãšãããCD Projekt Redããããªãã¯ã¹ãšãããªãã¯ã¹ã®é ç¹ä¹ç®ãå®è¡ããããšã«ããçç±ãããããŸãã...
倪éœ
ãŠã£ããã£ãŒ3ïŒ2015ïŒã§ã¯ã倧æ°æ£ä¹±ãšå€ªéœã®èšç®ã¯2ã€ã®å¥åã®ã¬ã³ããªã³ã°åŒã³åºãã§æ§æãããŠããŸãã
ãŠã£ããã£ãŒ3ïŒ2015ïŒ-ãŸã§ãŠã£ããã£ãŒ3ïŒ2015ïŒ-空ãšãŠã£ããã£ãŒ3ïŒ2015ïŒ-with sky + Sun2015幎ããŒãžã§ã³ã®å€ªéœã®
ã¬ã³ããªã³ã°ã¯ã幟äœåŠããã³æ··å/深床ã®ç¶æ
ã®ç¹ã§
æã®
ã¬ã³ããªã³ã°ã«éåžžã«äŒŒãŠããŸãã
äžæ¹ã
ãè¡ãšã¯ã€ã³ãã§ã¯ ã倪éœã®
ãã空ã1ã€ã®ãã¹ã§ã¬ã³ããªã³ã°ãããŸãã
ãŠã£ããã£ãŒ3ïŒè¡ãšã¯ã€ã³ïŒ2016ïŒ-倩åœãžThe Witcher 3ïŒBlood and WineïŒ2016ïŒ-with Heaven and the Sun倪éœãã©ã®ããã«ã¬ã³ããªã³ã°ããŠãããã段éã§ã¯ãæ¥å
ã®ïŒæ£èŠåãããïŒæ¹åãå¿
èŠã§ãã ãã®ãã¯ãã«ãååŸããæãè«ççãªæ¹æ³ã¯ã
çé¢åº§æšã䜿çšããããšã§ãã å®éã2ã€ã®è§åºŠïŒã©ãžã¢ã³ïŒïŒã瀺ã2ã€ã®å€
Phiãš
thetaã®ã¿ãå¿
èŠã§ãã ããããåãåã£ãã®ã§ã
r = 1ã§ãããšä»®å®ããŠããããæžããããšãã§ããŸãã 次ã«ãY軞ãäžãåããã«ã«ã座æšã®å ŽåãHLSLã§æ¬¡ã®ã³ãŒããèšè¿°ã§ããŸãã
float3 vSunDir; vSunDir.x = sin(fTheta)*cos(fPhi); vSunDir.y = sin(fTheta)*sin(fPhi); vSunDir.z = cos(fTheta); vSunDir = normalize(vSunDir);
éåžžã倪éœå
ã®æ¹åã¯ã¢ããªã±ãŒã·ã§ã³ã§èšç®ããããã®åŸã®äœ¿çšã®ããã«å®æ°ãããã¡ãŒã«æž¡ãããŸãã
æ¥å
ã®æ¹åãåããŠããã¯ã»ã«ã·ã§ãŒããŒ
ãBlood and Wineãã®ã¢ã»ã³ãã©ãŒã³ãŒãã詳ãã調ã¹ãããšãã§ããŸã...
... 100: add r1.xyw, -r0.xyxz, cb12[0].xyxz 101: dp3 r2.x, r1.xywx, r1.xywx 102: rsq r2.x, r2.x 103: mul r1.xyw, r1.xyxw, r2.xxxx 104: mov_sat r2.xy, cb12[205].yxyy 105: dp3 r2.z, -r1.xywx, -r1.xywx 106: rsq r2.z, r2.z 107: mul r1.xyw, -r1.xyxw, r2.zzzz ...
ãããã£ãŠããŸãã
cb12 [0] .xyzã¯ã«ã¡ã©ã®äœçœ®ã§ããã
r0.xyzã«é ç¹äœçœ®ãæ ŒçŽããŸãïŒããã¯é ç¹ã·ã§ãŒããŒããã®åºåã§ãïŒã ãããã£ãŠãè¡100ã¯ãã¯ãã«
worldToCameraãèšç®ããŸãã ãããã105è¡ç®ãã107è¡ç®ãèŠãŠãã ããã ãããã
normalizeïŒ-worldToCameraïŒãšããŠèšè¿°ã§ããŸããã€ãŸããæ£èŠåããã
cameraToWorldãã¯ãã«ãèšç®ããŸãã
120: dp3_sat r1.x, cb12[203].yzwy, r1.xywx
次ã«ã
cameraToWorldãš
sunDirectionãã¯ãã«ã®ã¹ã«ã©ãŒç©ãèšç®ããŸãïŒ æ£èŠåããå¿
èŠãããããšã«æ³šæããŠãã ããã ãŸãããã®å®å
šãªè¡šçŸã飜åãããŠãéé[0-1]ã«å¶éããŸãã
ãããïŒ ãã®ã¹ã«ã©ãŒç©ã¯r1.xã«ä¿åãããŸãã 次ã«é©çšãããå ŽæãèŠãŠã¿ãŸããã...
152: log r1.x, r1.x 153: mul r1.x, r1.x, cb12[203].x 154: exp r1.x, r1.x 155: mul r1.x, r2.y, r1.x
äžäœäžäœã®ãlogãmulãexpãã¯çŽ¯ä¹ã§ãã ã芧ã®ãšãããã³ãµã€ã³ïŒæ£èŠåããããã¯ãã«ã®ã¹ã«ã©ãŒç©ïŒãããçšåºŠäžããŸãã çç±ãå°ãããããããŸããã ãã®ããã«ããŠã倪éœãæš¡ããã°ã©ããŒã·ã§ã³ãäœæã§ããŸãã ïŒãããŠãè¡155ã¯ãã®ã°ã©ããŒã·ã§ã³ã®äžéæ床ã«åœ±é¿ãããããããšãã°ã倪éœãå®å
šã«é ãããã«ãªã»ããããŸãïŒã 以äžã«äŸã瀺ããŸãã
ææ°= 54ææ°= 2400ãã®ã°ã©ããŒã·ã§ã³ã䜿çšããŠã
skyColorãš
sunColorãè£éããããã«äœ¿çšããŸãïŒ ã¢ãŒããã¡ã¯ããåé¿ããã«ã¯ã120è¡ç®ã®å€ã飜åãããå¿
èŠããããŸãã
ãã®ããªãã¯
ã¯æã®
å ãã·ãã¥ã¬ãŒãããããã«äœ¿çšã§ããããšã«æ³šæããŠãã ããïŒäœãææ°å€ã§ïŒã ãããè¡ãã«ã¯ã
moonDirectionãã¯ãã«ãå¿
èŠã§ããããã¯ãçé¢åº§æšã䜿çšããŠç°¡åã«èšç®ã§ããŸãã
æ¢è£œã®HLSLã³ãŒãã¯ã次ã®ã¹ããããã®ããã«èãããŸãã
float3 vCamToWorld = normalize( PosW â CameraPos ); float cosTheta = saturate( dot(vSunDir, vCamToWorld) ); float sunGradient = pow( cosTheta, sunExponent ); float3 color = lerp( skyColor, sunColor, sunGradient );
æã®åã
ãŠã£ããã£ãŒ3ã®æŽããå€ç©ºã埮é床æ®åœ±ãããšãæã¯éçã§ã¯ãªãã空ãå°ã暪åã£ãŠããããšãããããŸãã ç§ã¯ãããã»ãšãã©å¶ç¶ã«æ°ã¥ãããããã©ã®ããã«å®è£
ãããããç¥ããããšæããŸããã
ãŠã£ããã£ãŒ3ã®æã¯ããµã€ãº1024x1024x6ã®ç«æ¹äœããããšããŠè¡šç€ºããããšããäºå®ããå§ããŸãããã èããŠã¿ããšãããã¯éåžžã«äŸ¿å©ãªãœãªã¥ãŒã·ã§ã³ã§ããããã¥ãŒããã¯ãããã®ãµã³ããªã³ã°ã®æ¹åãç°¡åã«ã¹ãããã§ããããšãç解ã§ããŸãã
次ã®ã¢ã»ã³ããªã³ãŒããèŠãŠã¿ãŸãããã
159: add r1.xyz, -v1.xyzx, cb1[8].xyzx 160: dp3 r0.w, r1.xyzx, r1.xyzx 161: rsq r0.w, r0.w 162: mul r1.xyz, r0.wwww, r1.xyzx 163: mul r2.xyz, cb12[204].zwyz, l(0.000000, 0.000000, 1.000000, 0.000000) 164: mad r2.xyz, cb12[204].yzwy, l(0.000000, 1.000000, 0.000000, 0.000000), -r2.xyzx 165: mul r4.xyz, r2.xyzx, cb12[204].zwyz 166: mad r4.xyz, r2.zxyz, cb12[204].wyzw, -r4.xyzx 167: dp3 r4.x, r1.xyzx, r4.xyzx 168: dp2 r4.y, r1.xyxx, r2.yzyy 169: dp3 r4.z, r1.xyzx, cb12[204].yzwy 170: dp3 r0.w, r4.xyzx, r4.xyzx 171: rsq r0.w, r0.w 172: mul r2.xyz, r0.wwww, r4.xyzx 173: sample_indexable(texturecube)(float,float,float,float) r4.xyz, r2.xyzx, t0.xyzw, s0
æçµçãªãµã³ããªã³ã°ãã¯ãã«ïŒè¡173ïŒãèšç®ããã«ã¯ããŸããæ£èŠåããã
worldToCameraãã¯ãã«ïŒè¡159-162ïŒãèšç®ããŸãã
次ã«ã
moonDirectionã䜿çšããŠ2ã€ã®ãã¯ãã«ç©ïŒ
163-164ã165-166 ïŒãèšç®ããåŸã§3ã€ã®ã¹ã«ã©ãŒç©ãèšç®ããŠæçµçãªãµã³ããªã³ã°ãã¯ãã«ãååŸããŸãã HLSLã³ãŒãïŒ
float3 vWorldToCamera = normalize( g_CameraPos.xyz - Input.PositionW.xyz ); float3 vMoonDirection = cb12_v204.yzw; float3 vStarsSamplingDir = cross( vMoonDirection, float3(0, 0, 1) ); float3 vStarsSamplingDir2 = cross( vStarsSamplingDir, vMoonDirection ); float dirX = dot( vWorldToCamera, vStarsSamplingDir2 ); float dirY = dot( vWorldToCamera, vStarsSamplingDir ); float dirZ = dot( vWorldToCamera, vMoonDirection); float3 dirXYZ = normalize( float3(dirX, dirY, dirZ) ); float3 starsColor = texNightStars.Sample( samplerAnisoWrap, dirXYZ ).rgb;
èªåèªèº«ãžã®æ³šæïŒããã¯éåžžã«ããèšèšãããã³ãŒãã§ãããããã«è©³ãã調æ»ããå¿
èŠããããŸãã
èªè
ãžã®æ³šæïŒãã®æäœã«ã€ããŠè©³ããç¥ã£ãŠãããªããæããŠãã ããïŒ
ããããæ
ãã1ã€èå³æ·±ãããªãã¯ã¯ãæã®ã¡ãã€ãã§ãã ããšãã°ãæŽå€©ã§ããŽã£ã°ã©ãŒããããŸããå Žåãæãããããããšã«æ°ä»ãã§ãããã
ãããã©ã®ããã«å®è£
ãããŠããã®ãèå³ããããŸããã2015幎çãšãBlood and Wineãã®éãã¯éåžžã«å€§ããããšãå€æããŸãããç°¡åã«ããããã«ã2015ããŒãžã§ã³ãæ€èšããŸãããããã£ãŠãåã®ã»ã¯ã·ã§ã³ã®starsColorããµã³ããªã³ã°ããçŽåŸã«éå§ããŸãã 174: mul r0.w, v0.x, l(100.000000) 175: round_ni r1.w, r0.w 176: mad r2.w, v0.y, l(50.000000), cb0[0].x 177: round_ni r4.w, r2.w 178: bfrev r4.w, r4.w 179: iadd r5.x, r1.w, r4.w 180: ishr r5.y, r5.x, l(13) 181: xor r5.x, r5.x, r5.y 182: imul null, r5.y, r5.x, r5.x 183: imad r5.y, r5.y, l(0x0000ec4d), l(0.0000000000000000000000000000000000001) 184: imad r5.x, r5.x, r5.y, l(146956042240.000000) 185: and r5.x, r5.x, l(0x7fffffff) 186: itof r5.x, r5.x 187: mad r5.y, v0.x, l(100.000000), l(-1.000000) 188: round_ni r5.y, r5.y 189: iadd r4.w, r4.w, r5.y 190: ishr r5.z, r4.w, l(13) 191: xor r4.w, r4.w, r5.z 192: imul null, r5.z, r4.w, r4.w 193: imad r5.z, r5.z, l(0x0000ec4d), l(0.0000000000000000000000000000000000001) 194: imad r4.w, r4.w, r5.z, l(146956042240.000000) 195: and r4.w, r4.w, l(0x7fffffff) 196: itof r4.w, r4.w 197: add r5.z, r2.w, l(-1.000000) 198: round_ni r5.z, r5.z 199: bfrev r5.z, r5.z 200: iadd r1.w, r1.w, r5.z 201: ishr r5.w, r1.w, l(13) 202: xor r1.w, r1.w, r5.w 203: imul null, r5.w, r1.w, r1.w 204: imad r5.w, r5.w, l(0x0000ec4d), l(0.0000000000000000000000000000000000001) 205: imad r1.w, r1.w, r5.w, l(146956042240.000000) 206: and r1.w, r1.w, l(0x7fffffff) 207: itof r1.w, r1.w 208: mul r1.w, r1.w, l(0.000000001) 209: iadd r5.y, r5.z, r5.y 210: ishr r5.z, r5.y, l(13) 211: xor r5.y, r5.y, r5.z 212: imul null, r5.z, r5.y, r5.y 213: imad r5.z, r5.z, l(0x0000ec4d), l(0.0000000000000000000000000000000000001) 214: imad r5.y, r5.y, r5.z, l(146956042240.000000) 215: and r5.y, r5.y, l(0x7fffffff) 216: itof r5.y, r5.y 217: frc r0.w, r0.w 218: add r0.w, -r0.w, l(1.000000) 219: mul r5.z, r0.w, r0.w 220: mul r0.w, r0.w, r5.z 221: mul r5.xz, r5.xxzx, l(0.000000001, 0.000000, 3.000000, 0.000000) 222: mad r0.w, r0.w, l(-2.000000), r5.z 223: frc r2.w, r2.w 224: add r2.w, -r2.w, l(1.000000) 225: mul r5.z, r2.w, r2.w 226: mul r2.w, r2.w, r5.z 227: mul r5.z, r5.z, l(3.000000) 228: mad r2.w, r2.w, l(-2.000000), r5.z 229: mad r4.w, r4.w, l(0.000000001), -r5.x 230: mad r4.w, r0.w, r4.w, r5.x 231: mad r5.x, r5.y, l(0.000000001), -r1.w 232: mad r0.w, r0.w, r5.x, r1.w 233: add r0.w, -r4.w, r0.w 234: mad r0.w, r2.w, r0.w, r4.w 235: mad r2.xyz, r0.wwww, l(0.000500, 0.000500, 0.000500, 0.000000), r2.xyzx 236: sample_indexable(texturecube)(float,float,float,float) r2.xyz, r2.xyzx, t0.xyzw, s0 237: log r4.xyz, r4.xyzx 238: mul r4.xyz, r4.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000) 239: exp r4.xyz, r4.xyzx 240: log r2.xyz, r2.xyzx 241: mul r2.xyz, r2.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000) 242: exp r2.xyz, r2.xyzx 243: mul r2.xyz, r2.xyzx, r4.xyzx
ãã
ãã®ããªãé·ãã¢ã»ã³ããªã³ãŒãã®æåŸãèŠãŠã¿ãŸãããã173è¡ç®ã§starsColorããµã³ããªã³ã°ããåŸãäœããã®ãªãã»ããå€ãèšç®ããŸãããã®ãªãã»ããã¯ããµã³ããªã³ã°ã®æåã®æ¹åïŒr2.xyzãè¡235ïŒãæªããããã«äœ¿çšãããŸãã次ã«ãæã®3次ãããããµã³ããªã³ã°ããããã2ã€ã®å€ã®ã¬ã³ãè£æ£ãå®è¡ãïŒ237-242ïŒãä¹ç®ããŸãïŒ243ïŒãã·ã³ãã«ã§ããïŒãŸããããã§ããªãã
ãã®ãªãã»ããã«ã€ããŠå°ãèããŠã¿ãŸãããããã®å€ã¯ãã¹ã«ã€ããŒã å
šäœã§ç°ãªãå¿
èŠããããŸã-åçã«ç¹æ»
ããæã¯éåžžã«éçŸå®çã«èŠããŸãããªãã»ããã極åå€åããããæã
ã¯ãããã¡ïŒCB [0] .XïŒã«æ ŒçŽãããçµéæéå®æ°ãUVã¯ã¹ã«ã€ããŒã ïŒv0.xyïŒã«å»¶äŒžãããšããäºå®ã䜿çšããŠé©çšããŸãããããã®æãããishr / xor /ã«æ
£ããŠããªãå Žåã¯ã皲劻å¹æã«ã€ããŠã¯æŽæ°ãã€ãºã«ã€ããŠèªãã§ãã ãããã芧ã®ãšãããæŽæ°ãã€ãºã¯ããã§ã¯4åçºçããŠããŸãããé·ã«äœ¿çšããããã€ãºãšã¯ç°ãªããŸããçµæãããã«ã©ã³ãã ã«ããããã«ããã€ãºã®å
¥åæŽæ°ã¯åèšïŒiaddïŒãããŠãããã«ãã£ãŠããããå転ãããŸãïŒå
éšé¢æ°reversebits ; bfrevåœä»€ïŒãã ãããä»ã¯é
ããªããŸããæåããå§ããŸããããæŽæ°ãã€ãºã®4ã€ã®ãå埩ãããããŸããã¢ã»ã³ãã©ã³ãŒããåæããŸããã4ã€ã®å埩ãã¹ãŠã®èšç®ã¯æ¬¡ã®ããã«ãªããŸãã int getInt( float x ) { return asint( floor(x) ); } int getReverseInt( float x ) { return reversebits( getInt(x) ); }
4ã€ã®å埩ãã¹ãŠã®æçµåºåïŒããããèŠã€ããã«ã¯ãitofåœä»€ã«åŸããŸãïŒïŒå埩1-r5.xãå埩2-r4.wãå埩3-r1.wãå埩4-r5.yæåŸã®itofã®åŸïŒè¡216ïŒ ïŒç§ãã¡ãæã£ãŠããïŒ 217: frc r0.w, r0.w 218: add r0.w, -r0.w, l(1.000000) 219: mul r5.z, r0.w, r0.w 220: mul r0.w, r0.w, r5.z 221: mul r5.xz, r5.xxzx, l(0.000000001, 0.000000, 3.000000, 0.000000) 222: mad r0.w, r0.w, l(-2.000000), r5.z 223: frc r2.w, r2.w 224: add r2.w, -r2.w, l(1.000000) 225: mul r5.z, r2.w, r2.w 226: mul r2.w, r2.w, r5.z 227: mul r5.z, r5.z, l(3.000000) 228: mad r2.w, r2.w, l(-2.000000), r5.z
ãããã®ç·ã¯ãé·ã®å Žåãšåæ§ã«ãUVã®å°æ°éšã«åºã¥ããŠå€©ã³ãã®Sã«ãŒãã®å€ãèšç®ããŸãã ã ããïŒ
float s_curve( float x ) { float x2 = x * x; float x3 = x2 * x;
ãæ³åã®ãšããããããã®ä¿æ°ã¯ããã€ãºãã¹ã ãŒãºã«è£éãããµã³ããªã³ã°åº§æšã®æçµãªãã»ãããçæããããã«äœ¿çšãããŸãã 229: mad r4.w, r4.w, l(0.000000001), -r5.x 230: mad r4.w, r0.w, r4.w, r5.x float noise0 = lerp( fStarsNoise1, fStarsNoise2, weightX ); 231: mad r5.x, r5.y, l(0.000000001), -r1.w 232: mad r0.w, r0.w, r5.x, r1.w float noise1 = lerp( fStarsNoise3, fStarsNoise4, weightX ); 233: add r0.w, -r4.w, r0.w 234: mad r0.w, r2.w, r0.w, r4.w float offset = lerp( noise0, noise1, weightY ); 235: mad r2.xyz, r0.wwww, l(0.000500, 0.000500, 0.000500, 0.000000), r2.xyzx 236: sample_indexable(texturecube)(float,float,float,float) r2.xyz, r2.xyzx, t0.xyzw, s0 float3 starsPerturbedDir = dirXYZ + offset * 0.0005; float3 starsColorDisturbed = texNightStars.Sample( samplerAnisoWrap, starsPerturbedDir ).rgb;
èšç®ããããªãã»ããã®å°ããªèŠèŠåã¯æ¬¡ã®ãšããã§ããstarsColorDisturbedãèšç®ãããšãæãé£ããéšåãå®æããŸãããã£ãïŒ
次ã®ã¹ãããã§ã¯ãstarsColorãšstarsColorDisturbedã®äž¡æ¹ã«å¯ŸããŠã¬ã³ãè£æ£ãå®è¡ãããã®åŸä¹ç®ããŸãã starsColor = pow( starsColor, 2.2 ); starsColorDisturbed = pow( starsColorDisturbed, 2.2 ); float3 starsFinal = starsColor * starsColorDisturbed;
ã¹ã¿ãŒ-æåŸã®ä»äžã
æã
ã¯æã£ãŠããstarsFinalã r1.xyzã«ãã¹ã¿ãŒåŠçã®çµäºæã«ã次ã®ããšãçºçããŸãã 256: log r1.xyz, r1.xyzx 257: mul r1.xyz, r1.xyzx, l(2.500000, 2.500000, 2.500000, 0.000000) 258: exp r1.xyz, r1.xyzx 259: min r1.xyz, r1.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000) 260: add r0.w, -cb0[9].w, l(1.000000) 261: mul r1.xyz, r0.wwww, r1.xyzx 262: mul r1.xyz, r1.xyzx, l(10.000000, 10.000000, 10.000000, 0.000000)
ããã¯ãããããæãåãæã«æ¯ã¹ãŠã¯ããã«ç°¡åã§ãããããã£ãŠãstarsFinalã2.5ã®çŽ¯ä¹ã«äžããããšããå§ããŸããããã«ãããæã®å¯åºŠãå¶åŸ¡ã§ããŸããããªãè³¢ãã次ã«ãæã®æ倧è²ãfloat3ïŒ1ã1ã1ïŒã«çããããŸããcb0 [9] .wã¯ãæã®å
šäœçãªå¯èŠæ§ãå¶åŸ¡ããããã«äœ¿çšãããŸãããããã£ãŠãæ¥äžã¯ãã®å€ã1.0ïŒãŒãã«ããä¹ç®ãäžããïŒã§ãããå€éã¯0.0ã§ãããšäºæ³ã§ããŸããæçµçã«ãæã®å¯èŠæ§ã10å¢ãããŸããããã§çµããã§ããããŒã3.ãŠã£ããã£ãŒãã¬ã¢ïŒãªããžã§ã¯ããšèŒåºŠãããïŒ
åè¿°ã®ã»ãšãã©ãã¹ãŠã®ãšãã§ã¯ããšãã¯ããã¯ã¯ãå®éã«ã¯ãŠã£ããã£ãŒ3ãšã¯é¢ä¿ãããŸããã§ãããããŒã³è£æ£ãã±ã©ã¬ãå¹³åèŒåºŠã®èšç®ãªã©ã¯ãã»ãšãã©ãã¹ãŠã®çŸä»£ã®ã²ãŒã ã«ååšããŸããäžæ¯ã®åœ±é¿ããåºãŸã£ãŠââããŸããã ããããããé女ã®æ¬èœãã®ã¬ã³ããªã³ã°ã®ä»çµã¿ã詳ããèŠãŠã¿ãããšã«ããŸããããžã§ã©ã«ãã¯é女ã§ããããããã£ãŠåœŒã®ææ
ã¯æ®éã®äººããããã£ãšéãããã®çµæã圌ã¯ä»ã®äººãããå€ãã®ããšãèŠãããšãã§ãã圌ã®èª¿æ»ã«å€§ãã«åœ¹ç«ã¡ãŸãããŠã£ããã£ãŒã®æèœã®ã¡ã«ããºã ã«ããããã¬ã€ã€ãŒã¯ãã®ãããªçè·¡ãèŠèŠåããããšãã§ããŸããå¹æã®ãã¢ã¯æ¬¡ã®ãšããã§ãããããŠããäžã€ãããè¯ãç
§æã§ïŒã芧ã®ãšããã2çš®é¡ã®ãªããžã§ã¯ãããããŸããGeraltã察話ã§ãããªããžã§ã¯ãïŒé»è²ã®ã¢ãŠãã©ã€ã³ïŒãšã調æ»ã«é¢é£ãããã¬ãŒã¹ïŒèµ€ãã¢ãŠãã©ã€ã³ïŒã§ããGeraltãèµ€ããã¬ã€ã«ã調ã¹ãåŸãé»è²ã«ãªãããšããããŸãïŒæåã®ãããªïŒãç»é¢å
šäœãç°è²ã«å€ãããéçŒå¹æïŒ2çªç®ã®ãããªïŒãè¿œå ãããŠããããšã«æ³šæããŠãã ããããã®å¹æã¯éåžžã«è€éãªã®ã§ãç§ã¯åœŒã®ç 究ã3ã€ã®éšåã«åããããšã«ããŸãããæåã¯ãªããžã§ã¯ãã®éžæã«ã€ããŠã2çªç®ã¯èŒªéã®çæã«ã€ããŠã3çªç®ã¯ããããã¹ãŠã1ã€ã®å
šäœã«çµ±åããããšã«ã€ããŠèª¬æããŸãããªããžã§ã¯ãéžæ
å
ã»ã©èšã£ãããã«ããªããžã§ã¯ãã«ã¯2ã€ã®ã¿ã€ãããããããããåºå¥ããå¿
èŠããããŸãããŠã£ããã£ãŒ3ã§ã¯ãããã¯ã¹ãã³ã·ã«ãããã¡ãŒã䜿çšããŠå®è£
ãããŸããããã¬ãŒã¹ãïŒèµ€ïŒãšããŠããŒã¯ãããã¹ãã¡ãã·ã¥GBufferãçæãããšãããããã¯ãã¹ãã³ã·ã«= 8ã¡ã·ã§ã¬ã³ããªã³ã°ããããèå³æ·±ãããªããžã§ã¯ãã¯ã¹ãã³ã·ã«= 4ã§ã¬ã³ããªã³ã°ãããŠããããã«ãé»è²ã§ããŒã¯ããšãã°ã次ã®2ã€ã®ãã¯ã¹ãã£ãæãããã¬ãŒã ã®äŸã瀺ããŸãèŠãããŠã£ããã£ãŒæ¬èœãšå¯Ÿå¿ããã¹ãã³ã·ã«ãããã¡ãŒïŒã¹ãã³ã·ã«ãããã¡ãçæé
ã¹ãã³ã·ã«ãããã¡ã¯ãã²ãŒã ã§ã¡ãã·ã¥ã«ã¿ã°ãä»ããããã«ãã䜿çšãããŸããç¹å®ã®ã¡ãã·ã¥ã«ããŽãªã«ã¯åãIDãå²ãåœãŠãããŸããã¹ãã³ã·ã«ãã¹ããæåããå Žåã¯ReplaceæŒç®åã§Alwaysé¢æ°ã䜿çšãããã以å€ã®å Žåã¯KeepæŒç®åã§åžžã«äœ¿çšãããšããèãæ¹ã§ããD3D11ã䜿çšããŠå®è£
ããæ¹æ³ã¯æ¬¡ã®ãšããã§ãã D3D11_DEPTH_STENCIL_DESC depthstencilState;
ãããã¡ã«æžã蟌ãŸããã¹ãã³ã·ã«å€ã¯ãAPIåŒã³åºãã§StencilRefãšããŠæž¡ãããŸãã
ã¬ã³ããªã³ã°ã®æãã
ãã®ç¯ã§ã¯ãå®è£
ã®èŠ³ç¹ãããR11G11B10_FLOAT圢åŒã®ãã«ã¹ã¯ãªãŒã³ãã¯ã¹ãã£ã1ã€ãããèå³æ·±ããªããžã§ã¯ããšãã¬ãŒã¹ããã£ãã«RãšGã«æ ŒçŽãããŸãããªãæããã®ç¹ã§ãããå¿
èŠãªã®ã§ããïŒGeraltã®æ¬èœã®ååŸã¯éãããŠããããããªããžã§ã¯ãããã¬ãŒã€ãŒã«ååè¿ãå Žåã«ã®ã¿ãªããžã§ã¯ããã¢ãŠãã©ã€ã³ãååŸããŸãããã®åŽé¢ãå®éã«èŠãŠãã ããïŒèŒåºŠãã¯ã¹ãã£ãã¯ãªãŒãã³ã°ããé»ã§å¡ãã€ã¶ãããšããå§ããŸãã次ã«ã2ã€ã®å
šç»é¢æç»åŒã³åºããè¡ãããŸãã1ã€ç®ã¯ããã¬ãŒã¹ãçšã2ã€ç®ã¯èå³æ·±ããªããžã§ã¯ãçšã§ãïŒæåã®æç»åŒã³åºãã¯ãã¬ãŒã¹ã«å¯ŸããŠè¡ãããŸã-ç·ã®ãã£ãã«ïŒ2çªç®ã®åŒã³åºãã¯ãèå³æ·±ããªããžã§ã¯ãïŒèµ€ããã£ãã«ïŒã«å¯ŸããŠè¡ãããŸããããŠãããããã©ã®ãã¯ã»ã«ãèæ
®ããããã©ã®ããã«æ±ºå®ããã®ã§ããããïŒã¹ãã³ã·ã«ãããã¡ã䜿çšããå¿
èŠããããŸãããããã®åŒã³åºãã®ããããã«ã€ããŠãã¹ãã³ã·ã«ãã¹ããå®è¡ããã以åã«ã8ãïŒæåã®æç»åŒã³åºãïŒãŸãã¯ã4ããšããŠããŒã¯ããããã¯ã»ã«ã®ã¿ãåãå
¥ããããŸãããã¬ãŒã¹çšã®ã¹ãã³ã·ã«ãã¹ãã®èŠèŠåïŒ...ããã³èå³æ·±ããªããžã§ã¯ãã®å ŽåïŒãã®å Žåããã¹ãã¯ã©ã®ããã«å®è¡ãããŸããïŒã¹ãã³ã·ã«ãã¹ãã®åºæ¬ã¯è¯ãæçš¿ã§èŠã€ããããšãã§ããŸããäžè¬ã«ãã¹ãã³ã·ã«ãã¹ãåŒã®åœ¢åŒã¯æ¬¡ã®ãšããã§ãã if (StencilRef & StencilReadMask OP StencilValue & StencilReadMask) accept pixel else discard pixel
ããã§ïŒ
StencilRef -å€ãAPIãåŒã³åºãã«æž¡ããStencilReadMask㯠-ã¹ãã³ã·ã«ãèªã¿åãã«äœ¿çšãããå€ïŒããã¯å·ŠåŽã«ãå³åŽã«ååšããŠããããšã«æ³šæïŒããã¹ã¯ãOP -æ¯èŒæŒç®åã¯ãAPIãä»ããŠæå®ãããStencilValue -å€ã¯ãçŸåšã®ãããã¡ã®ã¹ãã³ã·ã«åŠçããããã¯ã»ã«ããã€ããªANDã䜿çšããŠãªãã©ã³ããèšç®ããããšãç解ããããšãéèŠã§ããåºæ¬ãç解ãããããããã®æç»åŒã³åºãã§ãããã®ãã©ã¡ãŒã¿ãŒãã©ã®ããã«äœ¿çšãããããèŠãŠã¿ãŸãããããã¬ãŒã¹ã®ã¹ãã³ã·ã«æ¡ä»¶èå³æ·±ããªããžã§ã¯ãã®ã¹ãã³ã·ã«ç¶æ
ãïŒ
ã芧ã®ãšãããå¯äžã®éãã¯ReadMaskã§ããããããã§ãã¯ããŠã¿ãŸãããïŒã¹ãã³ã·ã«ãã¹ãåŒã§ãããã®å€ã代å
¥ããŸãã Let StencilReadMask = 0x08 and StencilRef = 0: For a pixel with stencil = 8: 0 & 0x08 < 8 & 0x08 0 < 8 TRUE For a pixel with stencil = 4: 0 & 0x08 < 4 & 0x08 0 < 0 FALSE
è³¢ãã
ã芧ã®ãšããããã®å Žåãã¹ãã³ã·ã«å€ãæ¯èŒããã®ã§ã¯ãªããã¹ãã³ã·ã«ãããã¡ãŒã®ç¹å®ã®ããããèšå®ãããŠãããã©ããã確èªããŸããã¹ãã³ã·ã«ãããã¡ã®åãã¯ã»ã«ã¯uint8圢åŒã§ãããããå€ã®ééã¯[0-255]ã§ãã泚ïŒãã¹ãŠã®DrawIndexedïŒ36ïŒåŒã³åºãã¯ããã¬ãŒã¹ãšããŠã®ãããããªã³ãã®ã¬ã³ããªã³ã°ã«é¢é£ããããããã®ç¹å®ã®ãã¬ãŒã ã§ã¯ãèŒåºŠãããã¯æ¬¡ã®æçµåœ¢åŒã«ãªããŸããããããã¹ãã³ã·ã«ãã¹ãã®åã«ãã¯ã»ã«ã·ã§ãŒããŒããããŸãã28738ãš28748ã¯äž¡æ¹ãšãåããã¯ã»ã«ã·ã§ãŒããŒã䜿çšããŸãã ps_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[2], immediateIndexed dcl_constantbuffer cb3[8], immediateIndexed dcl_constantbuffer cb12[214], immediateIndexed dcl_sampler s15, mode_default dcl_resource_texture2d (float,float,float,float) t15 dcl_input_ps_siv v0.xy, position dcl_output o0.xyzw dcl_output o1.xyzw dcl_output o2.xyzw dcl_output o3.xyzw dcl_temps 2 0: mul r0.xy, v0.xyxx, cb0[1].zwzz 1: sample_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t15.xyzw, s15 2: mul r1.xyzw, v0.yyyy, cb12[211].xyzw 3: mad r1.xyzw, cb12[210].xyzw, v0.xxxx, r1.xyzw 4: mad r0.xyzw, cb12[212].xyzw, r0.xxxx, r1.xyzw 5: add r0.xyzw, r0.xyzw, cb12[213].xyzw 6: div r0.xyz, r0.xyzx, r0.wwww 7: add r0.xyz, r0.xyzx, -cb3[7].xyzx 8: dp3 r0.x, r0.xyzx, r0.xyzx 9: sqrt r0.x, r0.x 10: mul r0.y, r0.x, l(0.120000) 11: log r1.x, abs(cb3[6].y) 12: mul r1.xy, r1.xxxx, l(2.800000, 0.800000, 0.000000, 0.000000) 13: exp r1.xy, r1.xyxx 14: mad r0.zw, r1.xxxy, l(0.000000, 0.000000, 120.000000, 120.000000), l(0.000000, 0.000000, 1.000000, 1.000000) 15: lt r1.x, l(0.030000), cb3[6].y 16: movc r0.xy, r1.xxxx, r0.yzyy, r0.xwxx 17: div r0.x, r0.x, r0.y 18: log r0.x, r0.x 19: mul r0.x, r0.x, l(1.600000) 20: exp r0.x, r0.x 21: add r0.x, -r0.x, l(1.000000) 22: max r0.x, r0.x, l(0) 23: mul o0.xyz, r0.xxxx, cb3[0].xyzx 24: mov o0.w, cb3[0].w 25: mov o1.xyzw, cb3[1].xyzw 26: mov o2.xyzw, cb3[2].xyzw 27: mov o3.xyzw, cb3[3].xyzw 28: ret
ãã®ãã¯ã»ã«ã·ã§ãŒããŒã¯1ã€ã®ã¬ã³ããŒã¿ãŒã²ããã®ã¿ã«æžã蟌ãããã24ã27è¡ç®ã¯åé·ã§ããããã§æåã«çºçããã®ã¯ãæ·±ãã®ãµã³ããªã³ã°ïŒå€å¶éä»ãã®ãã€ã³ããµã³ãã©ãŒã䜿çšïŒã1è¡ç®ã§ãããã®å€ã¯ãç¹æ®ãªãããªãã¯ã¹ãä¹ç®ãããã®åŸã«é è¿åå²ãè¡ãããšã§äžçã®äœçœ®ãåäœæããŸãïŒ2-6è¡ç®ïŒGeraltã®äœçœ®ãååŸããŸãïŒcb3 [7] .xyz-ããã¯ã«ã¡ã©ã®äœçœ®ã§ã¯ãªãããšã«æ³šæããŠãã ããïŒïŒãGeraltãããã®ç¹å®ã®ãã€ã³ããŸã§ã®è·é¢ãèšç®ããŸãïŒ7ã9è¡ç®ïŒããã®ã·ã§ãŒããŒã§ã¯ã次ã®å
¥åãéèŠã§ãã-cb3 [0] .rgb-åºåè²ã圢åŒã¯ãfloat3ïŒ0ã1ã0ïŒïŒãã¬ãŒã¹ïŒãŸãã¯float3ïŒ1ã0ã0ïŒïŒå¯Ÿè±¡ãªããžã§ã¯ãïŒã§ãã-cb3 [6] .y-è·é¢ã¹ã±ãŒãªã³ã°ä¿æ°ãæçµåºåã®ååŸãšèŒåºŠã«çŽæ¥åœ±é¿ããŸããåŸã§ãGeraltãšãªããžã§ã¯ãã®éã®è·é¢ã«å¿ããŠæãããèšç®ããããã®ããªãããªãããŒãªå
¬åŒããããŸãããã¹ãŠã®ä¿æ°ãå®éšçã«éžæãããŠãããšä»®å®ã§ããŸããæçµçãªåºåã¯ãcolor * strengthã§ããHLSLã³ãŒãã¯æ¬¡ã®ããã«ãªããŸãã struct FSInput { float4 param0 : SV_Position; }; struct FSOutput { float4 param0 : SV_Target0; float4 param1 : SV_Target1; float4 param2 : SV_Target2; float4 param3 : SV_Target3; }; float3 getWorldPos( float2 screenPos, float depth ) { float4 worldPos = float4(screenPos, depth, 1.0); worldPos = mul( worldPos, screenToWorld ); return worldPos.xyz / worldPos.w; } FSOutput EditedShaderPS(in FSInput IN) {
ãªãªãžãã«ïŒå·ŠïŒãšç§ã®ïŒå³ïŒã¢ã»ã³ãã©ãŒã·ã§ãŒããŒã³ãŒãã®å°ããªæ¯èŒãããã¯é女ã®æèœå¹æã®æåã®æ®µéã§ãããå®éãããã¯æãåçŽã§ããããŒã4.ãŠã£ããã£ãŒãã¬ã¢ïŒæŠèŠãããïŒ
ããäžåºŠãç§ãã¡ãæ¢çŽ¢ããŠããã·ãŒã³ãèŠãŠã¿ãŸããããé女ã®æ¬èœã®åœ±é¿ã®åæã®æåã®éšåã§ã¯ããæãããããããã©ã®ããã«çæããããã瀺ããŸãããR11G11B10_FLOAT圢åŒã®ãã«ã¹ã¯ãªãŒã³ãã¯ã¹ãã£ã1ã€ããã次ã®ããã«ãªããŸããç·è²ã®ãã£ãã«ã¯ããã¬ãŒã¹ããèµ€è²ã®ãã£ãã«ã¯Geraltã察話ã§ããèå³æ·±ããªããžã§ã¯ãã瀺ããŸãããã®ãã¯ã¹ãã£ãåãåã£ããã次ã®æ®µéã«é²ãããšãã§ããŸããããããã³ã³ã¿ãŒãããããšåŒã³ãŸããããã¯512x512 R16G16_FLOAT圢åŒã®ã¡ãã£ãšå€ãã£ããã¯ã¹ãã£ã§ããããã³ãã³ãã®ã¹ã¿ã€ã«ã§å®è£
ããããšãéèŠã§ããåã®ãã¬ãŒã ããã®çé«ç·ãããã¯ãçŸåšã®ãã¬ãŒã ã«æ°ããçé«ç·ããããçæããããã®å
¥åããŒã¿ã§ãïŒèŒåºŠããããšãšãã«ïŒããã³ãã³ãããã¡ãŒã¯ããŸããŸãªæ¹æ³ã§å®è£
ã§ããŸãããå人çã«ã¯æ¬¡ã®ïŒæ¬äŒŒã³ãŒãïŒãäžçªå¥œãã§ãã
å
¥åãåžžã«[m_outlineIndex]ã§ãåºåãåžžã«[ïŒM_outlineIndex]ã§ãããã®ã¢ãããŒãã¯ãè¿œå ã®ãã¹ããšãã§ã¯ãã®äœ¿çšã«æè»æ§ãæäŸããŸãããã¯ã»ã«ã·ã§ãŒããŒãèŠãŠã¿ãŸãããã ps_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb3[1], immediateIndexed dcl_sampler s0, mode_default dcl_sampler s1, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_resource_texture2d (float,float,float,float) t1 dcl_input_ps linear v2.xy dcl_output o0.xyzw dcl_temps 4 0: add r0.xyzw, v2.xyxy, v2.xyxy 1: round_ni r1.xy, r0.zwzz 2: frc r0.xyzw, r0.xyzw 3: add r1.zw, r1.xxxy, l(0.000000, 0.000000, -1.000000, -1.000000) 4: dp2 r1.z, r1.zwzz, r1.zwzz 5: add r1.z, -r1.z, l(1.000000) 6: max r2.w, r1.z, l(0) 7: dp2 r1.z, r1.xyxx, r1.xyxx 8: add r3.xyzw, r1.xyxy, l(-1.000000, -0.000000, -0.000000, -1.000000) 9: add r1.x, -r1.z, l(1.000000) 10: max r2.x, r1.x, l(0) 11: dp2 r1.x, r3.xyxx, r3.xyxx 12: dp2 r1.y, r3.zwzz, r3.zwzz 13: add r1.xy, -r1.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000) 14: max r2.yz, r1.xxyx, l(0, 0, 0, 0) 15: sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.zwzz, t1.xyzw, s1 16: dp4 r1.x, r1.xyzw, r2.xyzw 17: add r2.xyzw, r0.zwzw, l(0.003906, 0.000000, -0.003906, 0.000000) 18: add r0.xyzw, r0.xyzw, l(0.000000, 0.003906, 0.000000, -0.003906) 19: sample_indexable(texture2d)(float,float,float,float) r1.yz, r2.xyxx, t1.zxyw, s1 20: sample_indexable(texture2d)(float,float,float,float) r2.xy, r2.zwzz, t1.xyzw, s1 21: add r1.yz, r1.yyzy, -r2.xxyx 22: sample_indexable(texture2d)(float,float,float,float) r0.xy, r0.xyxx, t1.xyzw, s1 23: sample_indexable(texture2d)(float,float,float,float) r0.zw, r0.zwzz, t1.zwxy, s1 24: add r0.xy, -r0.zwzz, r0.xyxx 25: max r0.xy, abs(r0.xyxx), abs(r1.yzyy) 26: min r0.xy, r0.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000) 27: mul r0.xy, r0.xyxx, r1.xxxx 28: sample_indexable(texture2d)(float,float,float,float) r0.zw, v2.xyxx, t0.zwxy, s0 29: mad r0.w, r1.x, l(0.150000), r0.w 30: mad r0.x, r0.x, l(0.350000), r0.w 31: mad r0.x, r0.y, l(0.350000), r0.x 32: mul r0.yw, cb3[0].zzzw, l(0.000000, 300.000000, 0.000000, 300.000000) 33: mad r0.yw, v2.xxxy, l(0.000000, 150.000000, 0.000000, 150.000000), r0.yyyw 34: ftoi r0.yw, r0.yyyw 35: bfrev r0.w, r0.w 36: iadd r0.y, r0.w, r0.y 37: ishr r0.w, r0.y, l(13) 38: xor r0.y, r0.y, r0.w 39: imul null, r0.w, r0.y, r0.y 40: imad r0.w, r0.w, l(0x0000ec4d), l(0.0000000000000000000000000000000000001) 41: imad r0.y, r0.y, r0.w, l(146956042240.000000) 42: and r0.y, r0.y, l(0x7fffffff) 43: itof r0.y, r0.y 44: mad r0.y, r0.y, l(0.000000001), l(0.650000) 45: add_sat r1.xyzw, v2.xyxy, l(0.001953, 0.000000, -0.001953, 0.000000) 46: sample_indexable(texture2d)(float,float,float,float) r0.w, r1.xyxx, t0.yzwx, s0 47: sample_indexable(texture2d)(float,float,float,float) r1.x, r1.zwzz, t0.xyzw, s0 48: add r0.w, r0.w, r1.x 49: add_sat r1.xyzw, v2.xyxy, l(0.000000, 0.001953, 0.000000, -0.001953) 50: sample_indexable(texture2d)(float,float,float,float) r1.x, r1.xyxx, t0.xyzw, s0 51: sample_indexable(texture2d)(float,float,float,float) r1.y, r1.zwzz, t0.yxzw, s0 52: add r0.w, r0.w, r1.x 53: add r0.w, r1.y, r0.w 54: mad r0.w, r0.w, l(0.250000), -r0.z 55: mul r0.w, r0.y, r0.w 56: mul r0.y, r0.y, r0.z 57: mad r0.x, r0.w, l(0.900000), r0.x 58: mad r0.y, r0.y, l(-0.240000), r0.x 59: add r0.x, r0.y, r0.z 60: mov_sat r0.z, cb3[0].x 61: log r0.z, r0.z 62: mul r0.z, r0.z, l(100.000000) 63: exp r0.z, r0.z 64: mad r0.z, r0.z, l(0.160000), l(0.700000) 65: mul o0.xy, r0.zzzz, r0.xyxx 66: mov o0.zw, l(0, 0, 0, 0) 67: ret
ã芧ã®ãšãããåºåã³ã³ã¿ãŒãããã¯4ã€ã®çããæ£æ¹åœ¢ã«åå²ãããŠããããããæåã«èª¿æ»ããå¿
èŠããããã®ã§ãã 0: add r0.xyzw, v2.xyxy, v2.xyxy 1: round_ni r1.xy, r0.zwzz 2: frc r0.xyzw, r0.xyzw 3: add r1.zw, r1.xxxy, l(0.000000, 0.000000, -1.000000, -1.000000) 4: dp2 r1.z, r1.zwzz, r1.zwzz 5: add r1.z, -r1.z, l(1.000000) 6: max r2.w, r1.z, l(0) 7: dp2 r1.z, r1.xyxx, r1.xyxx 8: add r3.xyzw, r1.xyxy, l(-1.000000, -0.000000, -0.000000, -1.000000) 9: add r1.x, -r1.z, l(1.000000) 10: max r2.x, r1.x, l(0) 11: dp2 r1.x, r3.xyxx, r3.xyxx 12: dp2 r1.y, r3.zwzz, r3.zwzz 13: add r1.xy, -r1.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000) 14: max r2.yz, r1.xxyx, l(0, 0, 0, 0)
ãŸããããã¢ïŒTextureUV * 2.0ïŒãèšç®ããããšããå§ããŸããããã«ããã次ã®ããšãããããŸããåã
ã®æ£æ¹åœ¢ã決å®ããã«ã¯ãå°ããªé¢æ°ã䜿çšãããŸãã float getParams(float2 uv) { float d = dot(uv, uv); d = 1.0 - d; d = max( d, 0.0 ); return d; }
é¢æ°ã¯ãå
¥åfloat2ïŒ0.0ã0.0ïŒã«å¯ŸããŠ1.0ãè¿ãããšã«æ³šæããŠãã ããããã®ã±ãŒã¹ã¯å·Šäžé
ã§çºçããŸããå³äžé
ã§åãç¶æ³ãåŸãã«ã¯ãäžžã¿ã垯ã³ãtexcoordsããfloat2ïŒ1ã0ïŒãåŒããç·ã®æ£æ¹åœ¢ã®å Žåã¯float2ïŒ0ã1ïŒãåŒããé»è²ã®æ£æ¹åœ¢ã®å Žåã¯float2ïŒ1.0ã1.0ïŒãåŒããŸããã ããïŒ
float2 flooredTextureUV = floor( 2.0 * TextureUV ); ... float2 uv1 = flooredTextureUV; float2 uv2 = flooredTextureUV + float2(-1.0, -0.0); float2 uv3 = flooredTextureUV + float2( -0.0, -1.0); float2 uv4 = flooredTextureUV + float2(-1.0, -1.0); float4 mask; mask.x = getParams( uv1 ); mask.y = getParams( uv2 ); mask.z = getParams( uv3 ); mask.w = getParams( uv4 );
åãã¹ã¯ã³ã³ããŒãã³ãã¯0ãŸãã¯1ã§ããããã¯ã¹ãã£ã®1ã€ã®æ£æ¹åœ¢ãæ
åœããŸããããšãã°ãmask.rããã³mask.wïŒmask.rmask.wæã
ãåŸããã¹ã¯ãäžã®åããã¿ãŸãããããè¡15ã¯ãèŒåºŠãããããµã³ããªã³ã°ããŸãããã¹ãŠã®rgbaã³ã³ããŒãã³ãããµã³ããªã³ã°ããŸãããèŒåºŠãã¯ã¹ãã£ã¯R11G11B10_FLOAT圢åŒã§ããããšã«æ³šæããŠãã ããããã®ç¶æ³ã§ã¯ã.aã¯1.0fã§ãããšæ³å®ãããŠããŸãããã®æäœã«äœ¿çšãããTexcoordsã¯ãfracïŒTextureUV * 2.0ïŒãšããŠèšç®ã§ããŸãããããã£ãŠããã®æäœã®çµæã¯ãããšãã°æ¬¡ã®ããã«ãªããŸããé¡äŒŒãåç
§ããŠãã ããïŒæ¬¡ã®æ®µéã¯éåžžã«å·§åŠã§ã-4æåã®ã¹ã«ã©ãŒç©ïŒdp4ïŒãå®è¡ãããŸãã 16: dp4 r1.x, r1.xyzw, r2.xyzw
ãããã£ãŠãå·Šäžé
ã«ã¯èµ€ã®ãã£ãã«ïŒã€ãŸããèå³æ·±ããªããžã§ã¯ãã®ã¿ïŒãæ®ããå³äžã«ã¯ç·ã®ãã£ãã«ïŒãã¬ãŒã¹ã®ã¿ïŒãå³äžã«ã¯ãã¹ãŠãå«ãŸããŸãïŒèŒåºŠã³ã³ããŒãã³ã.wã«ã¯éæ¥çã«å€1.0ãå²ãåœãŠãããŠããããïŒãçŽ æŽãããã¢ã€ãã¢ãã¹ã«ã©ãŒç©ã®çµæã¯æ¬¡ã®ããã«ãªããŸãããã®masterFilterãåãåã£ããããªããžã§ã¯ãã®èŒªéãå®çŸ©ããæºåãã§ããŸãããèŠãç®ã»ã©é£ãããããŸããã
ãã®ã¢ã«ãŽãªãºã ã¯ãã·ã£ãŒããã¹ãååŸããããã«äœ¿çšããããã®ãšéåžžã«äŒŒãŠããŸã-å€ã®æ倧絶察差ãååŸããå¿
èŠããããŸããåŠçå
容ã¯æ¬¡ã®ãšããã§ããçŸåšåŠçäžã®ãã¯ã»ã«ã®æšªã«ãã4ã€ã®ãã¯ã»ã«ããµã³ããªã³ã°ãïŒéèŠïŒãã®å Žåããã¯ã»ã«ãµã€ãºã¯1.0 / 256.0ã§ãïŒïŒãèµ€ãšç·ã®ãã£ãã«ã®æ倧絶察差ãèšç®ããŸãã float fTexel = 1.0 / 256; float2 sampling1 = TextureUV + float2( fTexel, 0 ); float2 sampling2 = TextureUV + float2( -fTexel, 0 ); float2 sampling3 = TextureUV + float2( 0, fTexel ); float2 sampling4 = TextureUV + float2( 0, -fTexel ); float2 intensity_x0 = texIntensityMap.Sample( sampler1, sampling1 ).xy; float2 intensity_x1 = texIntensityMap.Sample( sampler1, sampling2 ).xy; float2 intensity_diff_x = intensity_x0 - intensity_x1; float2 intensity_y0 = texIntensityMap.Sample( sampler1, sampling3 ).xy; float2 intensity_y1 = texIntensityMap.Sample( sampler1, sampling4 ).xy; float2 intensity_diff_y = intensity_y0 - intensity_y1; float2 maxAbsDifference = max( abs(intensity_diff_x), abs(intensity_diff_y) ); maxAbsDifference = saturate(maxAbsDifference);
ããŠããã£ã«ã¿ãŒã«maxAbsDifferenceãæãããš...éåžžã«ã·ã³ãã«ã§å¹ççã茪éãåãåã£ãããåã®ãã¬ãŒã ãã茪éãããããµã³ããªã³ã°ããŸãã次ã«ãããŽãŒã¹ããå¹æãåŸãããã«ãçŸåšã®ãã¹ã§èšç®ããããã©ã¡ãŒã¿ãŒã®äžéšãšçé«ç·ãããã®å€ã䜿çšããŸããç§ãã¡ã®å€ãå人ã«æšæ¶ããŠãã ãã-æŽæ°ãã€ãºã圌ã¯ããã«ããŸããã¢ãã¡ãŒã·ã§ã³ãã©ã¡ãŒã¿ïŒcb3 [0] .zwïŒã¯å®æ°ãããã¡ããååŸãããæéãšãšãã«å€åããŸãã float2 outlines = masterFilter * maxAbsDifference;
泚ïŒé女ã®æèœãèªåã§å®è£
ãããå Žåã¯ãæŽæ°ãã€ãºãéé[-1; 1]ã«å¶éããããšããå§ãããŸãïŒãã®Webãµã€ãã§è¿°ã¹ãŠããŸãïŒãå
ã®TW3ã·ã§ãŒããŒã«ã¯å¶éã¯ãããŸããã§ãããããããªãã§ã¯ã²ã©ãã¢ãŒãã£ãã¡ã¯ããçºçããã¢ãŠãã©ã€ã³ãããå
šäœãäžå®å®ã§ããã次ã«ãèŒåºŠããããšåãæ¹æ³ã§çé«ç·ãããããµã³ããªã³ã°ãïŒä»åã¯ãã¯ã»ã«ã®ãµã€ãºã¯1.0 / 512.0ã§ãïŒã. xã³ã³ããŒãã³ãã®å¹³åå€ãèšç®ããŸãã
次ã«ãã¢ã»ã³ãã©ã³ãŒãã«ãã£ãŠå€æããŠããã®ç¹å®ã®ãã¯ã»ã«ã®å¹³åå€ãšå€ã®å·®ãèšç®ããããã®åŸæŽæ°ãã€ãºã«ããæªã¿ãå®è¡ãããŸãã
次ã®ã¹ãããã¯ããã€ãºã䜿çšããŠãå€ãã茪éãããã®å€ãæªããããšã§ããããã¯ãåºåãã¯ã¹ãã£ã«ãããã¯æãäžããã¡ã€ã³ã©ã€ã³ã§ãã次ã«ãä»ã®èšç®ãããããã®åŸãæåŸã«ãæžè¡°ããèšç®ãããŸãã
åäœäžã®ã¢ãŠãã©ã€ã³ãããã瀺ãçããããªã次ã«ç€ºããŸãããã«ãã¯ã»ã«ã·ã§ãŒããŒã«èå³ãããå Žåã¯ããã¡ãããå
¥æã§ããŸããã·ã§ãŒããŒã¯RenderDocãšäºææ§ããããŸããWitcher 3ã®å
ã®ã·ã§ãŒããŒãšã¢ã»ã³ãã©ãŒã³ãŒããåäžã§ããã«ãããããããRenderDocã®çé«ç·ãããã®æçµçãªå€èŠ³ãå€åããŠããã®ã¯èå³æ·±ãããšã§ãïŒæ£çŽãªãšãããå°ãé¢åã§ãïŒã泚ïŒæåŸã®ãã¹ïŒæ¬¡ã®éšåãåç
§ïŒã§ã¯ãçé«ç·ãããã®.rãã£ãã«ã®ã¿ã䜿çšãããŠããããšãããããŸããã§ã¯ããªã.gãã£ã³ãã«ãå¿
èŠãªã®ã§ããïŒããã¯1ã€ã®ãã¯ã¹ãã£å
ã®ããçš®ã®ããã³ãã³ããããã¡ãŒã ãšæããŸãã.rã«ã¯.gãã£ã³ãã«+æ°ããå€ãå«ãŸããŠããããšã«æ³šæããŠãã ãããããŒã5ïŒãŠã£ããã£ãŒãã¬ã¢ïŒãã£ãã·ã¥ã¢ã€ãšæçµçµæïŒ
ãã§ã«æã£ãŠãããã®ãç°¡åã«ãªã¹ãããŸããããæåã®éšåã§ã¯ããŠã£ããã£ãŒã®æ¬èœã«æ§ããããå¹æãè·é¢ã«å¿ããŠã©ã®çšåºŠé¡èã§ãããã瀺ããã«ã¹ã¯ãªãŒã³ã®èŒåºŠããããçæãããŸããã2çªç®ã®ããŒãã§ã¯ãã¢ãŠãã©ã€ã³ãããããã詳现ã«èª¿æ»ããŸãããããã¯ãå®æãããšãã§ã¯ãã®ã¢ãŠãã©ã€ã³ãšã¢ãã¡ãŒã·ã§ã³ãæ
åœããŸããæåŸã®æ®µéã«æ¥ãŸãããããããã¹ãŠãçµã¿åãããå¿
èŠããããŸãïŒæåŸã®ãã¹ã¯ãã«ã¹ã¯ãªãŒã³ã¯ã¯ããã§ããå
¥åããŒã¿ïŒã«ã©ãŒãããã¡ãŒãçé«ç·ããããããã³èŒåºŠããããå®å
ïŒ
åŸïŒ
ããäžåºŠããšãã§ã¯ããé©çšãããããªã衚瀺ããŸããã芧ã®ãšãããGeraltãèŠãããšãèãããšãã§ãããªããžã§ã¯ãã«èŒªéãé©çšããããšã«å ããŠãéçŒå¹æã¯ç»é¢å
šäœã«é©çšãããç»é¢å
šäœïŒç¹ã«è§ïŒã¯ç°è²ã«ãªããæ¬ç©ã®ã¢ã³ã¹ã¿ãŒãã³ã¿ãŒã®æèŠãäŒããŸããå®å
šã«çµã¿ç«ãŠããããã¯ã»ã«ã·ã§ãŒããŒã³ãŒãïŒ ps_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[3], immediateIndexed dcl_constantbuffer cb3[7], immediateIndexed dcl_sampler s0, mode_default dcl_sampler s2, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_resource_texture2d (float,float,float,float) t2 dcl_resource_texture2d (float,float,float,float) t3 dcl_input_ps_siv v0.xy, position dcl_output o0.xyzw dcl_temps 7 0: div r0.xy, v0.xyxx, cb0[2].xyxx 1: mad r0.zw, r0.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000) 2: mov r1.yz, abs(r0.zzwz) 3: div r0.z, cb0[2].x, cb0[2].y 4: mul r1.x, r0.z, r1.y 5: add r0.zw, r1.xxxz, -cb3[2].xxxy 6: mul_sat r0.zw, r0.zzzw, l(0.000000, 0.000000, 0.555556, 0.555556) 7: log r0.zw, r0.zzzw 8: mul r0.zw, r0.zzzw, l(0.000000, 0.000000, 2.500000, 2.500000) 9: exp r0.zw, r0.zzzw 10: dp2 r0.z, r0.zwzz, r0.zwzz 11: sqrt r0.z, r0.z 12: min r0.z, r0.z, l(1.000000) 13: add r0.z, -r0.z, l(1.000000) 14: mov_sat r0.w, cb3[6].x 15: add_sat r1.xy, -r0.xyxx, l(0.030000, 0.030000, 0.000000, 0.000000) 16: add r1.x, r1.y, r1.x 17: add_sat r0.xy, r0.xyxx, l(-0.970000, -0.970000, 0.000000, 0.000000) 18: add r0.x, r0.x, r1.x 19: add r0.x, r0.y, r0.x 20: mul r0.x, r0.x, l(20.000000) 21: min r0.x, r0.x, l(1.000000) 22: add r1.xy, v0.xyxx, v0.xyxx 23: div r1.xy, r1.xyxx, cb0[2].xyxx 24: add r1.xy, r1.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000) 25: dp2 r0.y, r1.xyxx, r1.xyxx 26: mul r1.xy, r0.yyyy, r1.xyxx 27: mul r0.y, r0.w, l(0.100000) 28: mul r1.xy, r0.yyyy, r1.xyxx 29: max r1.xy, r1.xyxx, l(-0.400000, -0.400000, 0.000000, 0.000000) 30: min r1.xy, r1.xyxx, l(0.400000, 0.400000, 0.000000, 0.000000) 31: mul r1.xy, r1.xyxx, cb3[1].xxxx 32: mul r1.zw, r1.xxxy, cb0[2].zzzw 33: mad r1.zw, v0.xxxy, cb0[1].zzzw, -r1.zzzw 34: sample_indexable(texture2d)(float,float,float,float) r2.xyz, r1.zwzz, t0.xyzw, s0 35: mul r3.xy, r1.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) 36: sample_indexable(texture2d)(float,float,float,float) r0.y, r3.xyxx, t2.yxzw, s2 37: mad r3.xy, r1.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000), l(0.500000, 0.000000, 0.000000, 0.000000) 38: sample_indexable(texture2d)(float,float,float,float) r2.w, r3.xyxx, t2.yzwx, s2 39: mul r2.w, r2.w, l(0.125000) 40: mul r3.x, cb0[0].x, l(0.100000) 41: add r0.x, -r0.x, l(1.000000) 42: mul r0.xy, r0.xyxx, l(0.030000, 0.125000, 0.000000, 0.000000) 43: mov r3.yzw, l(0, 0, 0, 0) 44: mov r4.x, r0.y 45: mov r4.y, r2.w 46: mov r4.z, l(0) 47: loop 48: ige r4.w, r4.z, l(8) 49: breakc_nz r4.w 50: itof r4.w, r4.z 51: mad r4.w, r4.w, l(0.785375), -r3.x 52: sincos r5.x, r6.x, r4.w 53: mov r6.y, r5.x 54: mul r5.xy, r0.xxxx, r6.xyxx 55: mad r5.zw, r5.xxxy, l(0.000000, 0.000000, 0.125000, 0.125000), r1.zzzw 56: mul r6.xy, r5.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) 57: sample_indexable(texture2d)(float,float,float,float) r4.w, r6.xyxx, t2.yzwx, s2 58: mad r4.x, r4.w, l(0.125000), r4.x 59: mad r5.zw, r5.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), l(0.000000, 0.000000, 0.500000, 0.000000) 60: sample_indexable(texture2d)(float,float,float,float) r4.w, r5.zwzz, t2.yzwx, s2 61: mad r4.y, r4.w, l(0.125000), r4.y 62: mad r5.xy, r5.xyxx, r1.xyxx, r1.zwzz 63: sample_indexable(texture2d)(float,float,float,float) r5.xyz, r5.xyxx, t0.xyzw, s0 64: mad r3.yzw, r5.xxyz, l(0.000000, 0.125000, 0.125000, 0.125000), r3.yyzw 65: iadd r4.z, r4.z, l(1) 66: endloop 67: sample_indexable(texture2d)(float,float,float,float) r0.xy, r1.zwzz, t3.xyzw, s0 68: mad_sat r0.xy, -r0.xyxx, l(0.800000, 0.750000, 0.000000, 0.000000), r4.xyxx 69: dp3 r1.x, r3.yzwy, l(0.300000, 0.300000, 0.300000, 0.000000) 70: add r1.yzw, -r1.xxxx, r3.yyzw 71: mad r1.xyz, r0.zzzz, r1.yzwy, r1.xxxx 72: mad r1.xyz, r1.xyzx, l(0.600000, 0.600000, 0.600000, 0.000000), -r2.xyzx 73: mad r1.xyz, r0.wwww, r1.xyzx, r2.xyzx 74: mul r0.yzw, r0.yyyy, cb3[4].xxyz 75: mul r2.xyz, r0.xxxx, cb3[5].xyzx 76: mad r0.xyz, r0.yzwy, l(1.200000, 1.200000, 1.200000, 0.000000), r2.xyzx 77: mov_sat r2.xyz, r0.xyzx 78: dp3_sat r0.x, r0.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000) 79: add r0.yzw, -r1.xxyz, r2.xxyz 80: mad o0.xyz, r0.xxxx, r0.yzwy, r1.xyzx 81: mov o0.w, l(1.000000) 82: ret
82è¡-ãããã£ãŠãããã¹ãããšããããããããŸãïŒãŸããå
¥åããŒã¿ãèŠãŠã¿ãŸãããã
å¹æã®å€§ããã®äž»ãªå€ã¯fisheyeAmountã§ããGeraltãæ¬èœã䜿ãå§ãããšãåŸã
ã«0.0ãã1.0ã«äžæãããšæããŸããæ®ãã®å€ã¯ã»ãšãã©å€ãããŸãããããŠãŒã¶ãŒããªãã·ã§ã³ã§éçŒå¹æãç¡å¹ã«ããå Žåããããã®äžéšãç°ãªããšæãããŸãïŒããã¯ãã§ãã¯ããŸããã§ããïŒãããã§æåã«èµ·ããããšã¯ãã·ã§ãŒããŒãã°ã¬ãŒã®è§åºŠã®åå ãšãªããã¹ã¯ãèšç®ããããšã§ãã 0: div r0.xy, v0.xyxx, cb0[2].xyxx 1: mad r0.zw, r0.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000) 2: mov r1.yz, abs(r0.zzwz) 3: div r0.z, cb0[2].x, cb0[2].y 4: mul r1.x, r0.z, r1.y 5: add r0.zw, r1.xxxz, -cb3[2].xxxy 6: mul_sat r0.zw, r0.zzzw, l(0.000000, 0.000000, 0.555556, 0.555556) 7: log r0.zw, r0.zzzw 8: mul r0.zw, r0.zzzw, l(0.000000, 0.000000, 2.500000, 2.500000) 9: exp r0.zw, r0.zzzw 10: dp2 r0.z, r0.zwzz, r0.zwzz 11: sqrt r0.z, r0.z 12: min r0.z, r0.z, l(1.000000) 13: add r0.z, -r0.z, l(1.000000)
HLSLã§ã¯ã次ã®ããã«èšè¿°ã§ããŸãã
ãŸããéé[-1; 1] UVãšãã®çµ¶å¯Ÿå€ã次ã«ãããªãããŒãªãã¹ã¯ã€ãŒãºãããããŸããå®æãããã¹ã¯ã¯æ¬¡ã®ãšããã§ããåŸã§ãã®ãã¹ã¯ã«æ»ããŸããããã§ãæ°è¡ã®ã³ãŒããæå³çã«ã¹ããããããºãŒã å¹æã®åå ãšãªãã³ãŒãã詳ãã調ã¹ãŸãã 22: add r1.xy, v0.xyxx, v0.xyxx 23: div r1.xy, r1.xyxx, cb0[2].xyxx 24: add r1.xy, r1.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000) 25: dp2 r0.y, r1.xyxx, r1.xyxx 26: mul r1.xy, r0.yyyy, r1.xyxx 27: mul r0.y, r0.w, l(0.100000) 28: mul r1.xy, r0.yyyy, r1.xyxx 29: max r1.xy, r1.xyxx, l(-0.400000, -0.400000, 0.000000, 0.000000) 30: min r1.xy, r1.xyxx, l(0.400000, 0.400000, 0.000000, 0.000000) 31: mul r1.xy, r1.xyxx, cb3[1].xxxx 32: mul r1.zw, r1.xxxy, cb0[2].zzzw 33: mad r1.zw, v0.xxxy, cb0[1].zzzw, -r1.zzzw
æåã«ãã2åãã®ãã¯ã¹ãã£åº§æšãèšç®ãããæžç®float2ïŒ1ã1ïŒãå®è¡ãããŸãã float2 uv4 = 2 * PosH.xy; uv4 /= cb0_v2.xy; uv4 -= float2(1.0, 1.0);
ãã®ãããªtexcoordã¯ã次ã®ããã«èŠèŠåã§ããŸãã次ã«ãã¹ã«ã©ãŒç©ãããïŒuv4ãuv4ïŒãèšç®ããããã¹ã¯ãåŸãããŸããäžèšã®texcoordsãä¹ç®ããããã«äœ¿çšãããŸããéèŠïŒå·Šäžé
ïŒé»ããã¯ã»ã«ïŒã®å€ã¯è² ã§ããR11G11B10_FLOAT圢åŒã®ç²ŸåºŠãå¶éãããŠããããããããã¯é»ïŒ0.0ïŒã§è¡šç€ºãããŸãã笊å·ãããããªããããè² ã®å€ãæ ŒçŽã§ããŸããã次ã«ãæžè¡°ä¿æ°ãèšç®ãããŸãïŒäžèšã§è¿°ã¹ãããã«ãfisheyeAmountã¯0.0ãã1.0ãŸã§å€åããŸãïŒã float attenuation = fisheyeAmount * 0.1; uv4 *= attenuation;
次ã«ãå¶éïŒæ倧/æå°ïŒãš1ã€ã®ä¹ç®ãå®è¡ãããŸãããã®ããã«ããŠããªãã»ãããèšç®ãããŸããã«ã©ãŒãã¯ã¹ãã£ã®ãµã³ããªã³ã°ã«äœ¿çšãããæçµçãªUVãèšç®ããã«ã¯ãåçŽã«æžç®ãå®è¡ããŸããfloat2 colorUV = mainUv-offset;å
¥åcolorUVã«ã©ãŒãã¯ã¹ãã£ããµã³ããªã³ã°ããããšã«ãããè§ã®è¿ãã«ãããã ç»åãåŸãããŸããã¢ãŠãã©ã€ã³
次ã®ã¹ãããã¯ãçé«ç·ãããããµã³ããªã³ã°ããŠçé«ç·ãèŠã€ããããšã§ããããã¯éåžžã«ç°¡åã§ãããŸããèå³æ·±ããªããžã§ã¯ãã®èŒªéããµã³ããªã³ã°ããããã¯ã¹ã³ãŒããèŠã€ãã次ã«ãã©ãã¯ã«å¯ŸããŠåãããšãè¡ããŸãã
çé«ç·ãããããã®èå³æ·±ããªããžã§ã¯ãçé«ç·ãããããã®ãã¬ãŒã¹çé«ç·ããããã.xãã£ãã«ã®ã¿ããµã³ããªã³ã°ããäžéšã®æ£æ¹åœ¢ã®ã¿ãèæ
®ããããšã«æ³šæãã䟡å€ããããŸããã ãŒãã¡ã³ã
ãã©ãã¯ã®ç§»åãå®è£
ããã«ã¯ãäžæ¯ã®å¹æãšã»ãŒåãããªãã¯ã䜿çšãããŸããåäœãµã€ãºã®åãè¿œå ãããèå³æ·±ããªããžã§ã¯ããšãã¬ãŒã¹ãããã³ã«ã©ãŒãã¯ã¹ãã£ã®ã¢ãŠãã©ã€ã³ãããã®8åããµã³ããªã³ã°ããŸããèŠã€ãã£ã茪éã8.0ã§å²ã£ãã ãã§ããããšã«æ³šæããŠãã ããããã¯ã¹ãã£åº§æš[0-1] 2ã®ç©ºéã«ããã®ã§ãåäžãã¯ã»ã«ãå²ãååŸ1ã®åãååšãããšã蚱容ã§ããªãã¢ãŒããã¡ã¯ããäœæãããŸããå
ã«é²ãåã«ããã®ååŸãã©ã®ããã«èšç®ããããã調ã¹ãŸãããããããè¡ãã«ã¯ãäžè¶³ããŠããè¡15ã21ã«æ»ãå¿
èŠããããŸãããã®ååŸã®èšç®ã«é¢ããå°ããªåé¡ã¯ããã®èšç®ãã·ã§ãŒããŒã®åšãã«æ£åšããŠããããšã§ãïŒãããããã³ã³ãã€ã©ãŒã«ããã·ã§ãŒããŒã®æé©åãåå ã§ãïŒããããã£ãŠãããã«æåã®éšåïŒ15-21ïŒãš2çªç®ã®éšåïŒ41-42ïŒããããŸãã 15: add_sat r1.xy, -r0.xyxx, l(0.030000, 0.030000, 0.000000, 0.000000) 16: add r1.x, r1.y, r1.x 17: add_sat r0.xy, r0.xyxx, l(-0.970000, -0.970000, 0.000000, 0.000000) 18: add r0.x, r0.x, r1.x 19: add r0.x, r0.y, r0.x 20: mul r0.x, r0.x, l(20.000000) 21: min r0.x, r0.x, l(1.000000) ... 41: add r0.x, -r0.x, l(1.000000) 42: mul r0.xy, r0.xyxx, l(0.030000, 0.125000, 0.000000, 0.000000)
ã芧ã®ãšãããåãµãŒãã§ã¹ã®æšªã«ãã[0.00-0.03]ã®ãã¯ã»ã«ã®ã¿ãèæ
®ãããããã®å€ãéèšãã20ãä¹ç®ããŠé£œåãããŸãã15ã21è¡ç®ä»¥éã¯æ¬¡ã®ããã«ãªããŸãããããŠã41è¡ç®ä»¥éã®æ¹æ³ã¯æ¬¡ã®ãšããã§ãã42è¡ç®ã§ã¯ãããã«0.03ãæããŠããŸãããã®å€ã¯ãç»é¢å
šäœã®åã®ååŸã§ããã芧ã®ãšãããç»é¢ã®ç«¯ã«è¿ã¥ããšååŸãå°ãããªããŸããããã§ã移åã®åå ãšãªãã¢ã»ã³ãã©ãŒã³ãŒãã確èªã§ããŸãã 40: mul r3.x, cb0[0].x, l(0.100000) 41: add r0.x, -r0.x, l(1.000000) 42: mul r0.xy, r0.xyxx, l(0.030000, 0.125000, 0.000000, 0.000000) 43: mov r3.yzw, l(0, 0, 0, 0) 44: mov r4.x, r0.y 45: mov r4.y, r2.w 46: mov r4.z, l(0) 47: loop 48: ige r4.w, r4.z, l(8) 49: breakc_nz r4.w 50: itof r4.w, r4.z 51: mad r4.w, r4.w, l(0.785375), -r3.x 52: sincos r5.x, r6.x, r4.w 53: mov r6.y, r5.x 54: mul r5.xy, r0.xxxx, r6.xyxx 55: mad r5.zw, r5.xxxy, l(0.000000, 0.000000, 0.125000, 0.125000), r1.zzzw 56: mul r6.xy, r5.zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) 57: sample_indexable(texture2d)(float,float,float,float) r4.w, r6.xyxx, t2.yzwx, s2 58: mad r4.x, r4.w, l(0.125000), r4.x 59: mad r5.zw, r5.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), l(0.000000, 0.000000, 0.500000, 0.000000) 60: sample_indexable(texture2d)(float,float,float,float) r4.w, r5.zwzz, t2.yzwx, s2 61: mad r4.y, r4.w, l(0.125000), r4.y 62: mad r5.xy, r5.xyxx, r1.xyxx, r1.zwzz 63: sample_indexable(texture2d)(float,float,float,float) r5.xyz, r5.xyxx, t0.xyzw, s0 64: mad r3.yzw, r5.xxyz, l(0.000000, 0.125000, 0.125000, 0.125000), r3.yyzw 65: iadd r4.z, r4.z, l(1) 66: endloop
ããã§å°ãåæ¢ããŸããããè¡40ã§ãæéä¿æ°ãååŸããŸãïŒjust çµéæé* 0.1ïŒã 43è¡ç®ã«ã¯ãã«ãŒãå
ã§ååŸããã«ã©ãŒãã¯ã¹ãã£çšã®ãããã¡ãŒããããŸããr0.xïŒè¡41-42ïŒã¯ãçŸåšããã£ãŠããããã«ãåã®ååŸã§ããr4.xïŒ44è¡ç®ïŒã¯å¯Ÿè±¡ãªããžã§ã¯ãã®ã¢ãŠãã©ã€ã³ãr4.yïŒ45è¡ç®ïŒã¯ãã©ãã¯ã®ã¢ãŠãã©ã€ã³ïŒä»¥åã¯8ã§å²ã£ãïŒïŒãr4.zïŒ46è¡ç®ïŒã¯ã«ãŒãã«ãŠã³ã¿ãŒã§ãããæ³åã®ãšãããã«ãŒãã«ã¯8ã€ã®å埩ããããŸããã©ãžã¢ã³åäœã®è§åºŠi * PI_4ãèšç®ããããšããå§ããŸããããã«ããã2 * PI-å®å
šãªåãåŸãããŸããè§åºŠã¯æéãšãšãã«æªãã§ãããŸããsincosã䜿çšããŠããµã³ããªã³ã°ãã€ã³ãïŒåäœåïŒã決å®ããä¹ç®ã䜿çšããŠååŸãå€æŽããŸãïŒè¡54ïŒããã®åŸããã¯ã»ã«ãåã§å²ã¿ã茪éãšè²ããµã³ããªã³ã°ããŸãããµã€ã¯ã«ã®åŸã茪éãšè²ã®å¹³åå€ïŒ8ã§å²ã£ãããïŒãååŸããŸãã float timeParam = time * 0.1;
ã«ã©ãŒãµã³ããªã³ã°ãã»ãŒåãæ¹æ³ã§å®è¡ãããŸãããããŒã¹ã®colorUVã«ãåäžãã®åãä¹ç®ãããªãã»ãããè¿œå ããŸããæãã
ãµã€ã¯ã«ã®åŸãèŒåºŠãããããµã³ããªã³ã°ããæçµçãªèŒåºŠå€ãå€æŽããŸãïŒèŒåºŠãããã¯èŒªéã«ã€ããŠäœãç¥ããªãããïŒïŒ 67: sample_indexable(texture2d)(float,float,float,float) r0.xy, r1.zwzz, t3.xyzw, s0 68: mad_sat r0.xy, -r0.xyxx, l(0.800000, 0.750000, 0.000000, 0.000000), r4.xyxx
HLSLã³ãŒãïŒ
ç°è²ã®ã³ãŒããŒãšãã¹ãŠã®æçµçãªçµ±äž
è§ã«è¿ãç°è²ã¯ãã¹ã«ã©ãŒç©ïŒã¢ã»ã³ãã©ãŒã©ã€ã³69ïŒã䜿çšããŠèšç®ãããŸãã
ãã®åŸã2ã€ã®è£éãç¶ããŸããæåã®äŸã§ã¯ãæåã«èª¬æãããã¹ã¯ã䜿çšããŠã°ã¬ãŒãšãåã®è²ããçµã¿åãããŠãããããè§ãã°ã¬ãŒã«ãªããŸããããã«ã0.6ã®ä¿æ°ããããæçµç»åã®åœ©åºŠãäœäžããŸãã2çªç®ã¯fisheyeAmountã䜿çšããŠæåã®è²ãšäžèšã®è²ãçµã¿åãããŸããããã¯ãç»é¢ãåŸã
ã«æããªãïŒ0.6åïŒãé
ãç°è²ã«ãªãããšãæå³ããŸãïŒç¬åµçã
HLSLïŒ
ããã§ããªããžã§ã¯ãã®èŒªéã®è¿œå ã«é²ãããšãã§ããŸããè²ïŒèµ€ãšé»è²ïŒã¯ãå®æ°ãããã¡ãŒããååŸãããŸãã
ãµãïŒãããããŽãŒã«ã§ãïŒæçµçãªè²ããããŸããé女ã®æ¬èœã®è²ããããŸãããã®ãããåçŽãªè¿œå ã¯é©åã§ã¯ãããŸããããŸããã¹ã«ã©ãŒç©ãèšç®ããŸãã 78: dp3_sat r0.x, r0.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000) float dot_senses_total = saturate( dot(senses_total, float3(1.0, 1.0, 1.0) ) );
次ã®ããã«ãªããŸãããããŠãæåŸã®ãããã®å€ã¯ãè²ãšïŒé£œåããïŒé女ã®æèœã®éãè£éããããã«äœ¿çšãããŸãïŒ 76: mad r0.xyz, r0.yzwy, l(1.200000, 1.200000, 1.200000, 0.000000), r2.xyzx 77: mov_sat r2.xyz, r0.xyzx 78: dp3_sat r0.x, r0.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000) 79: add r0.yzw, -r1.xxyz, r2.xxyz 80: mad o0.xyz, r0.xxxx, r0.yzwy, r1.xyzx 81: mov o0.w, l(1.000000) 82: ret float3 senses_total = 1.2 * senses_traces + senses_interesting;
ãããŠããã ãã§ããå®å
šãªã·ã§ãŒããŒã¯ãã¡ãããå
¥æã§ããŸããç§ïŒå·ŠïŒãšãªãªãžãã«ïŒå³ïŒã®ã·ã§ãŒããŒã®æ¯èŒïŒãã®èšäºãã楜ãã¿ãã ããïŒããŠã£ããã£ãŒæ¬èœãã®ä»çµã¿ã«ã¯å€ãã®çŽ æŽãããã¢ã€ãã¢ããããå®æããçµæã¯éåžžã«ä¿¡ããããŸãã[åæã®åã®éšåïŒæåãš2çªç®ã]