Closed Rinloid closed 3 years ago
Plus: 'line-49' of B is in vanilla vertex shaders.
what about when render dragon?
* **A** Strangely, plants are waving in indoors where the wind does not come in. But this issue will be solved using 'uv1.y' as a way to detect indoors.
That is actually a very good idea. Thank you for your suggestion.
* **B** This issue occurs because 'gl_Position' are coordinates of the screen, not correct coordinates of the world. It will be solved to shift their codes to line-49 and rewrite 'gl_Position' to 'worldPos'.
I'm afraid I don't really understand. The line 49 of the vanilla shader is here, right? And is the code you think problematic is this? Then I think there are no difference in these cases because both essentially does gl_Position = PROJ * (WORLDVIEW * worldPos);
(P.S. If it's convenient to you, you can also use Japanese here, as I'm in fact a native Japanese speaker.)
* **C** As we know. this issue occurs because 'POSITION' is the current chunk origin in [0.0, 16.0]. It will we solved to rewrite 'POS3 posw = POSITION.xyz;' to 'POS3 posw = abs(POSITION.xyz - 8.0);' which means to make a range of 'POSITION' from [0.0, 16.0] to [-8.0, 8.0].
Uhm I think that would only change the position where the discontinuity occurs, but I'll try your solution anyway.
Ah I see, the abs()
is the key to eliminate the discontinuity. Thanks, your fix did resolve the issue!
A and C have been fixed in 38232d5bba2522f71cc866c6f312933c9b6e84a3. I did the same for the water perturbance in 46a903a642bbff750dc564392d3375681b29b239.
As for B, I still think it's because my shader perturbs not only the Y coordinate but also X and Z. Since the game doesn't tell us whether a vertex of water body is adjacent to something non-water, we have no means to accommodate the perturbance depending on the shape of the terrain. I believe it's therefore not fixable.
日本語で書きますね。
Bについてですが、申し訳ありません。Natural Mtsticの波のコードをよく見ていませんでした。それが単にgl_Position
に数値を足していただけなら(植物を揺らすコードと同じように)、私がBで示した解決策を使えば修正できるはずです。ESBE 2Gなどの一部のシェーダーも、それを使うことですでにこの問題を修正しています。
現状、Natural Mystic の波には二つの問題があります。
御指摘の問題 B はこの 1 の方で合っていますか?これが起こる理由は、他のシェーダーと違って Natural Mystic では水ブロックの y 座標だけでなく x 座標と z 座標も合わせて動かしている (Gerstner Wave を使っている) 為で、座標系の問題ではないので、現状どうにもならないと思うのです。
問題 2 の方は波を揺らすための座標として POSITION ではなく、そこに CHUNK_ORIGIN_AND_SCALE の変換を適用した後の worldPos を使っている為です。今確認したところ ESBE 2G では POSITION を使っていますね。それと同じ事を Natural Mystic でやろうとするとチャンク境界で波が不連続となることをどうしても避けられないのです。
はい。その問題は1で合っています。ああ、なるほど...。Gerstner Wave を使っていたのならこの問題はおそらく修正不可能ですね...。ありがとうございます。
問題2も、そもそもゲームから渡され波などの描写に使える座標が worldPos と POSITION くらいしか無いので、そちらもシェーダーに関するアップデートが来ない限り作成者はどちらか一方を選ばなければならないという状況ですよね。floor(CHUNK_ORIGIN_AND_SCALE / 16.0) * 16.0 + POSITION.xyz
などではカメラの移動によってカクついてしまいますが、少しマシになります。試してみてください。
また、Natural Mystic に2つほどの課題を見つけたので、そちらは新しい Issue を立ててそこで指摘させていただきますね。ありがとうございました。
試しました。確かにマシになりますね。ただチャンク境界を越える時に不連続になるのがどうしても気になるので、設定項目として追加するに留めてデフォルトでは従来通りの動作とする事にしました。ありがとうございます。
I noticed 3 issues with vertex shaders, and I came up with their solutions.
Issues
Causes and solutions
A Strangely, plants are waving in indoors where the wind does not come in. But this issue will be solved using 'uv1.y' as a way to detect indoors.
B This issue occurs because 'gl_Position' are coordinates of the screen, not correct coordinates of the world. It will be solved to shift their codes to line-49 and rewrite 'gl_Position' to 'worldPos'.
C As we know. this issue occurs because 'POSITION' is the current chunk origin in [0.0, 16.0]. It will we solved to rewrite 'POS3 posw = POSITION.xyz;' to 'POS3 posw = abs(POSITION.xyz - 8.0);' which means to make a range of 'POSITION' from [0.0, 16.0] to [-8.0, 8.0].