2renard renard2renard
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 新しいUnityHDRPでレイマーチングする ## 先行研究 - [Unity HDRPのLitシェーダーを改造してレイマーチングする(GBuffer編)](https://nanka.hateblo.jp/entry/2019/08/27/004905) ## 環境 - Unity2022.3.8f1 - HDRP 14.0.8 ## 解析 kanetaさんと同じく、GBufferを書き換える方針 書き換えているファイル ``` #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl" ``` - new/oldどちらも "GBuffer" Passに一つだけある - よって"GBuffer" Passを書き換えればよい ``` #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" ``` - これはnew:6/old:5 - new - "ScenePickingPass" - "SceneSelectionPass" - "ShadowCaster" - "DepthOnly" - "TransparentDepthPrepass" - "TransparentDepthPostpass" - old - "SceneSelectionPass" - "ShadowCaster" - "DepthOnly" - "TransparentDepthPrepass" - "TransparentDepthPostpass" 変更点は "ShadowCaster" Passだけ "DepthOnly" Passは消えてる > なぜこのような変更を加えたかというと、デプステクスチャのコピーのタイミングに関係があります。 らしい - よって "ShadowCaster" Passを変えればよい ``` #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassMotionVectors.hlsl" ``` - これはどっちも"MotionVectors" Passしかない - よってこれを書き換えるよ ## 実装 ひとつづつ書き換えるよ ShaderPassGBuffer.hlsl -> GBufferPass.hlsl 見る感じFrag変わってなさそうなんで、そのまんま書き換える :kan: ShaderPassDepthOnly.hlsl -> ShadowCasterPass.hlsl なんかこれだけめちゃ名前変わってるから完全に別もんになってる説ある 引数とか見るに、おなじっぽい 新しい方、ちょくちょくマクロ分岐あるけどだいたい同じ 大体outputDepth,depthColorに書きこんでるだけなので、同じようにした 良いのかは知らん ShaderPassMotionVectors.hlsl -> MotionVectorsPass.hlsl これも他と同じように`#define _DEPTHOFFSET_ON`足してデプス書き換えるだけ なんかいろいろ変わってて意味わからん なんとか書き換えられた気がする ## 問題 ### なんかしらのエラー ``` Shader error in 'HDRP/NewRaymarching': 'GetDecalSurfaceData': cannot convert from 'float' to 'struct FragInputs' at Assets/RaymarchingHDRP/Shaders/New/Common/RaymarchingUtility.hlsl(169) (on d3d11) ``` RaymarchingUtility.hlslのToHDRPSurfaceAndBuiltinData関数に問題があるらしい この関数はそもそもGetSurfaceAndBuiltinDataのRaymarching版なので、そちらを見ながら書き換える この関数はLitData.hlslに定義されている 中身のエラー箇所と一致するとこを見比べてみる ``` // old L232 #if HAVE_DECALS if (_EnableDecals) { DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, alpha); ApplyDecalToSurfaceData(decalSurfaceData, surfaceData); } #endif ``` ``` // new L274 #if HAVE_DECALS if (_EnableDecals) { // Both uses and modifies 'surfaceData.normalWS'. DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, input, alpha); ApplyDecalToSurfaceData(decalSurfaceData, input.tangentToWorld[2], surfaceData); } #endif ``` そもそも何か新しいマクロ分岐の正しい必要な気がするが、とりま古い方のRaymarchingUtilityの関数だけ修正する - `GetDecalSurfaceData`と`ApplyDecalToSurfaceData`の引数がどっちもちがうね(新しい方は多い) - 引数を合わせる - ok ### 顔を突っ込むと消える 以下のPassだけが明示的にCull Offになってる - "SceneSelectionPass" <- これなに - "GBuffer" - "META" - "ShadowCaster" - "MotionVectors" > https://tips.hecomi.com/entry/2020/09/29/222335 > SceneSelectionPass. その名の通り、エディタの Scene ビューで選択するときのアウトライン表示用のパスです。 > Meta パスはライトマップや GI 向けに情報を提供するパスで通常のレンダリングの間には利用されません。今回はこちらは省略します。 そこらへんはBuildinPipelineと変わんないらしい よって変更を加えたパス - "GBuffer" - "ShadowCaster" - "MotionVectors" をCull offすれば良さそう ok ### 影が出ない ![image](https://hackmd.io/_uploads/ryiG_W3Va.png) [RenderingDebugger](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/Render-Pipeline-Debug-Window.html)でShadowMapを見たが、影が無いことにされてる ShadowCasterが死んでると思われる - Decalが問題になってるかどうか確認 - オフにした -> 別になんも変わらん - MotionVectorは普通に出て躁なのが謎 ![image](https://hackmd.io/_uploads/SJVa3Zn4a.png) - Depthも、本体は出てそう ![image](https://hackmd.io/_uploads/rklXTZhVp.png) - なぜ影が出ないのか... - ShadowCaster消しても同じに見える なぜ - "ShadowCaster"Passに`#define VARYINGS_NEED_POSITION_WS`を追記したら影出た ワロタ ### 影がSphereになる ![スクリーンショット 2023-11-23 084135 (小)](https://hackmd.io/_uploads/By5RWfn4p.png) ![スクリーンショット 2023-11-23 084403 (小)](https://hackmd.io/_uploads/HyEPzf24a.png) - 画像の通り、SSS(Screen Space Shadow)をonにすると発生する - ScreenSpaceといってもDepthBufferでやってるわけじゃなく、レイトレーシングのワークフローの領分だと思う - https://docs.unity3d.com/ja/Packages/com.unity.render-pipelines.high-definition@10.5/manual/Ray-Traced-Shadows.html - 多分"GBufferDXR"とか、なんちゃらDXR系のPassを実装しないとレイトレ系は機能しないと思われ - よって無理 今後見え方がおかしい場合、大体レイトレが問題かもしれない レイマーチングオブジェクトが一部の場合ONにしてもバレないかもだけど - レイトレじゃないScreenSpace系は行けるかも ### Decalが透ける ![スクリーンショット 2023-11-23 085114 (小)](https://hackmd.io/_uploads/HkYHEzn4a.png) - 予期してたけどしょうがない ![image](https://hackmd.io/_uploads/BkgKaQGhVT.png) - オフにするか、透けるのに目をつぶろう - マジでレンダーパイプラインの形式が変わってるのでスクリプト書き換えたくない ## できたかも - MengerEmitの見た目が同じか確認 - [x] 顔を突っ込むと消える - [x] 影が出ない - SampleSceneに置いて確認 - [x] 影がSphereの形になってる - [x] Decalが透ける - 重い - 三回レイマーチングしてるし、それはそう - MotionVector要る? できました <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">HDRPに勝利 <a href="https://t.co/0OfdZ5o9up">pic.twitter.com/0OfdZ5o9up</a></p>&mdash; Renard_VRC (@Renard_VRC) <a href="https://twitter.com/Renard_VRC/status/1727479655203295420?ref_src=twsrc%5Etfw">November 23, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully