Vb.net vbnet中的光与影Opentk
嗨,我已经创建了一个简单的项目来展示一些小qube,现在我尝试插入灯光,我尝试了一些在线的例子,但现在我只能“切换”每个方向的闪光灯或Z方向的一点灯光,我无法移动灯光的位置 这是我的代码:Vb.net vbnet中的光与影Opentk,vb.net,shader,opentk,light,Vb.net,Shader,Opentk,Light,嗨,我已经创建了一个简单的项目来展示一些小qube,现在我尝试插入灯光,我尝试了一些在线的例子,但现在我只能“切换”每个方向的闪光灯或Z方向的一点灯光,我无法移动灯光的位置 这是我的代码: GL.Clear(ClearBufferMask.ColorBufferBit) GL.Clear(ClearBufferMask.DepthBufferBit) Dim perspective As Matrix4 Dim xmin As Single = -200
GL.Clear(ClearBufferMask.ColorBufferBit)
GL.Clear(ClearBufferMask.DepthBufferBit)
Dim perspective As Matrix4
Dim xmin As Single = -200
Dim ymin As Single = -200
Dim xmax As Single = 300
Dim ymax As Single = 300
Dim size As Single = xmax - xmin
Dim rate As Single = GlControl1.Width / GlControl1.Height
ymax = ymin + (size / rate)
perspective = Matrix4.CreateOrthographicOffCenter(xmin, xmax, ymin, ymax, -1000, 1000)
'Perspective
GL.MatrixMode(MatrixMode.Projection) 'load the camera
GL.LoadIdentity()
GL.LoadMatrix(perspective)
GL.Viewport(0, 0, GlControl1.Width, GlControl1.Height)
GL.Enable(EnableCap.DepthTest)
GL.DepthFunc(DepthFunction.Less)
GL.Enable(EnableCap.ColorMaterial)
GL.Enable(EnableCap.Lighting)
GL.Enable(EnableCap.Light0)
Dim cl0() As Single = {NumericUpDown4.Value, NumericUpDown5.Value, NumericUpDown6.Value, NumericUpDown7.Value}
GL.Light(LightName.Light0, LightParameter.Position, cl0)
GL.Rotate(NumericUpDown3.Value, New Vector3(1, 0, 0)) 'asse X
GL.Rotate(NumericUpDown2.Value, New Vector3(0, 1, 0)) 'asse Y
GL.Rotate(NumericUpDown1.Value, New Vector3(0, 0, 1)) 'asse Z
For x = -100 To 100 Step 20
For y = -100 To 100 Step 20
For z = -100 To 100 Step 20
drawCube(x, y, z, 5)
Next
Next
Next
'Finally..................
GraphicsContext.CurrentContext.VSync = True ' to syncronize with the GPU ability
GlControl1.SwapBuffers() 'takes from GL and put to control
GlControl1.Invalidate()
我在cl0数组上仅获得了#3和#4值的变化,例如:
如果cl0数组是(0,0,1,0),我得到:
如果cl0数组是(0,0,0,1)或(0,0,1,1),我得到:
我也尝试了许多其他价值观,但没有任何改变。
如何设置灯光的X、Y、Z位置?
还有,如何开始阴影?效果很可能与灯光模型的效果有关。这项技术几十年来一直被弃用。现在,光照是根据模型中的每个碎片计算的。最有可能的效果与光照模型的大小有关。这项技术几十年来一直被弃用。如今,光照是按图像中的每个片段计算的。