質問編集履歴

1

文章とタイトルを編集しました。

2020/11/20 10:39

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- GLSL でシェーディングを実装する方法が知りたい。
1
+ GLSL でシェーディングを実装する方法が知りたい。シェーダーファイルの書き方そのもの。
test CHANGED
@@ -11,3 +11,111 @@
11
11
 
12
12
 
13
13
  参考サイト: http://www.sic.shibaura-it.ac.jp/~yaoki/cg/CG2008-10.pdf
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ ```GLSL
22
+
23
+ /*****************************************************************************************************************
24
+
25
+ * ライティング  .vert
26
+
27
+ ******************************************************************************************************************/
28
+
29
+ #version 400
30
+
31
+
32
+
33
+
34
+
35
+ layout(location = 0) in vec4 position; //頂点座標
36
+
37
+ layout(location = 1) in vec2 in_texcoord; //テクスチャ座標
38
+
39
+ layout(location = 2) in vec3 in_normal; //法線
40
+
41
+
42
+
43
+ uniform mat4 worldMatrix; //ワールド行列
44
+
45
+ uniform mat4 viewMatrix; //ビュー行列
46
+
47
+
48
+
49
+ //フラグメントシェーダー行き
50
+
51
+
52
+
53
+ out vec2 out_texcoord;
54
+
55
+
56
+
57
+
58
+
59
+ void main()
60
+
61
+ {
62
+
63
+ vec4 pos = vec4(position.xyz,1.0);
64
+
65
+ out_texcoord = in_texcoord;
66
+
67
+
68
+
69
+ gl_Position = viewMatrix * worldMatrix * pos;
70
+
71
+ }
72
+
73
+ ```
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ ```GLSL
82
+
83
+ /*****************************************************************************************************************
84
+
85
+ * ライティング  .frag
86
+
87
+ ******************************************************************************************************************/
88
+
89
+
90
+
91
+ #version 400
92
+
93
+
94
+
95
+ //フラグメントから来た
96
+
97
+ in vec2 out_texcoord;
98
+
99
+
100
+
101
+ uniform sampler2D uTexture; //テクスチャ
102
+
103
+ out vec4 out_color; //出力
104
+
105
+
106
+
107
+
108
+
109
+ void main()
110
+
111
+ {
112
+
113
+ out_color = texture(uTexture,out_texcoord);
114
+
115
+ }
116
+
117
+
118
+
119
+
120
+
121
+ ```