質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Unity3D

Unity3Dは、ゲームや対話式の3Dアプリケーション、トレーニングシュミレーション、そして医学的・建築学的な技術を可視化する、商業用の開発プラットフォームです。

Q&A

解決済

1回答

2008閲覧

Graphics.DrawProceduralで旧形式のエラーのとり方がわからない

kudo201810

総合スコア30

Unity3D

Unity3Dは、ゲームや対話式の3Dアプリケーション、トレーニングシュミレーション、そして医学的・建築学的な技術を可視化する、商業用の開発プラットフォームです。

0グッド

0クリップ

投稿2020/09/17 08:12

以下のサイトで公開されているコードですが、
バージョン:Unity 2019.2.11f1 (64-bit)
だとGraphics.DrawProceduralの行で、旧形式でコンパイルエラーが出ます。

Unity:Geometry Shader を使って100万キューブ/立方体/Cubeを描画する!

上記サイトよりコピーしたコードが以下

using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; public class GeometryShaderCube : MonoBehaviour { public Shader shader; List<Vector3> points; Material material; ComputeBuffer buffer; /// <summary> /// 初期化 /// </summary> void OnEnable() { material = new Material(shader); // 100 x 100 x 100 = 1,000,000 cube int start = -50; int end = 100 + start; points = new List<Vector3>(); for (int x = start; x < end; x++) { for (int y = start; y < end; y++) { for (int z = start; z < end; z++) { points.Add(new Vector3(x, y, z)); } } } buffer = new ComputeBuffer(points.Count, Marshal.SizeOf(typeof(Vector3)), ComputeBufferType.Default); buffer.SetData(points); material.SetFloat("rotate_x", this.transform.rotation.x); material.SetFloat("rotate_y", this.transform.rotation.y); material.SetFloat("rotate_z", this.transform.rotation.z); material.SetBuffer("points", buffer); } void OnDisable() { points.Clear(); buffer.Release(); } /// <summary> /// レンダリング /// </summary> void OnRenderObject() { material.SetFloat("rotate_x", this.transform.rotation.x); material.SetFloat("rotate_y", this.transform.rotation.y); material.SetFloat("rotate_z", this.transform.rotation.z); // レンダリングを開始 material.SetPass(0); // 1万個のオブジェクトをレンダリング Graphics.DrawProcedural(MeshTopology.Points, points.Count); } }

以下のスクリプトリファレンスをみると

https://docs.unity3d.com/ja/current/ScriptReference/Graphics.DrawProcedural.html

public static void DrawProcedural (Material material, Bounds bounds, MeshTopology topology, int vertexCount, int instanceCount, Camera camera, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows, int layer);

と項目が増えており、特に

Bounds bounds

が何をいれていいのかが上記のコードの場合わかりませんでした。

上記のコードを書き換える場合、どのように書き換えたら、動きますでしょうか。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

Graphics.DrawProceduralNow(MeshTopology.Points, points.Count);

へ変更したら解決しました。以下のサイトが参考になりました。

NVIDIA FleX for Unity (1.0 BETA)をインポートするとエラーが出て使えない問題を解決した話
https://qiita.com/aapython/items/9f741b55c04c6fdd0533

https://docs.unity3d.com/2019.1/Documentation/ScriptReference/Graphics.DrawProceduralNow.html

投稿2020/09/20 09:22

kudo201810

総合スコア30

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問