質問編集履歴
2
追加スクリプト
test
CHANGED
File without changes
|
test
CHANGED
@@ -334,10 +334,148 @@
|
|
334
334
|
|
335
335
|
}
|
336
336
|
|
337
|
-
|
338
|
-
|
339
337
|
```
|
340
338
|
|
339
|
+
追加スクリプト
|
340
|
+
|
341
|
+
```C#
|
342
|
+
|
343
|
+
using System.Collections;
|
344
|
+
|
345
|
+
using System.Collections.Generic;
|
346
|
+
|
347
|
+
using UnityEngine;
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
public class PlacementShadow : MonoBehaviour
|
352
|
+
|
353
|
+
{
|
354
|
+
|
355
|
+
public Material material;
|
356
|
+
|
357
|
+
Mesh mesh;
|
358
|
+
|
359
|
+
List<Vector2> ObjectPositionList = new List<Vector2>();
|
360
|
+
|
361
|
+
// Start is called before the first frame update
|
362
|
+
|
363
|
+
void Start()
|
364
|
+
|
365
|
+
{
|
366
|
+
|
367
|
+
mesh = new Mesh();
|
368
|
+
|
369
|
+
mesh.vertices = new Vector3[]
|
370
|
+
|
371
|
+
{
|
372
|
+
|
373
|
+
new Vector3(0f,0f,0f),
|
374
|
+
|
375
|
+
new Vector3(0f,1f,0f),
|
376
|
+
|
377
|
+
new Vector3(1f,0f,0f),
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
new Vector3(0f,1f,1f),
|
382
|
+
|
383
|
+
new Vector3(1f,0f,1f),
|
384
|
+
|
385
|
+
new Vector3(1f,1f,1f),
|
386
|
+
|
387
|
+
};
|
388
|
+
|
389
|
+
mesh.uv = new Vector2[]
|
390
|
+
|
391
|
+
{
|
392
|
+
|
393
|
+
new Vector2(0f,0f),
|
394
|
+
|
395
|
+
new Vector2(0f,1f),
|
396
|
+
|
397
|
+
new Vector2(1f,0f),
|
398
|
+
|
399
|
+
new Vector2(0f,1f),
|
400
|
+
|
401
|
+
new Vector2(1f,0f),
|
402
|
+
|
403
|
+
new Vector2(1f,1f),
|
404
|
+
|
405
|
+
};
|
406
|
+
|
407
|
+
mesh.triangles = new int[]
|
408
|
+
|
409
|
+
{
|
410
|
+
|
411
|
+
0,1,2,
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
3,2,1,
|
416
|
+
|
417
|
+
2,3,4,
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
5,4,3,
|
422
|
+
|
423
|
+
};
|
424
|
+
|
425
|
+
mesh.RecalculateBounds();
|
426
|
+
|
427
|
+
mesh.RecalculateNormals();
|
428
|
+
|
429
|
+
}
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
// Update is called once per frame
|
434
|
+
|
435
|
+
void Update()
|
436
|
+
|
437
|
+
{
|
438
|
+
|
439
|
+
Placement();
|
440
|
+
|
441
|
+
for(int i = 0;i < ObjectPositionList.Count; i++)
|
442
|
+
|
443
|
+
{
|
444
|
+
|
445
|
+
Graphics.DrawMesh(mesh,Vector3.zero, Quaternion.identity, material, 0);
|
446
|
+
|
447
|
+
}
|
448
|
+
|
449
|
+
}
|
450
|
+
|
451
|
+
void Placement()
|
452
|
+
|
453
|
+
{
|
454
|
+
|
455
|
+
var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
456
|
+
|
457
|
+
var x = Mathf.FloorToInt(pos.x);
|
458
|
+
|
459
|
+
var y = Mathf.FloorToInt(pos.y);
|
460
|
+
|
461
|
+
var pos2 = new Vector2(x, y);
|
462
|
+
|
463
|
+
if (Input.GetMouseButton(0))
|
464
|
+
|
465
|
+
{
|
466
|
+
|
467
|
+
ObjectPositionList.Add(pos2);
|
468
|
+
|
469
|
+
}
|
470
|
+
|
471
|
+
}
|
472
|
+
|
473
|
+
}
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
```
|
478
|
+
|
341
479
|
|
342
480
|
|
343
481
|
### 試したこと
|
1
理想図の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -346,6 +346,8 @@
|
|
346
346
|
|
347
347
|
![イメージ説明](dd465646d6a536f713e65fec12027996.png)
|
348
348
|
|
349
|
+
![イメージ説明](6f6f9df7a3f563bc731083350483f168.png)
|
350
|
+
|
349
351
|
正方形に描画しているメッシュの3つの頂点を引き伸ばして、[ボリュームシャドウ](http://gameprogrammingunit.web.fc2.com/shadow/volume_simple.htm)のようにしたかったのですが、どうすればシェーダーで描画しているメッシュの頂点をいじれるのか、調べても分かりませんでした。
|
350
352
|
|
351
353
|
どのようにすればシェーダーでverticesを変更することができますか?
|