Beispiel #1
0
 public void RenderGrass()
 {
     if (TheClient.MainWorldView.FBOid == FBOID.FORWARD_SOLID)
     {
         TheClient.Engine.Shaders3D.s_forw_grass = TheClient.Engine.Shaders3D.s_forw_grass.Bind();
         GL.Uniform1(6, (float)TheClient.GlobalTickTimeLocal);
         GL.Uniform4(12, new Vector4(ClientUtilities.Convert(TheClient.MainWorldView.FogCol), TheClient.MainWorldView.FogAlpha));
         float fogDist = 1.0f / TheClient.FogMaxDist();
         fogDist *= fogDist;
         GL.Uniform1(13, fogDist);
         //GL.Uniform2(14, new Vector2(TheClient.CVars.r_znear.ValueF, TheClient.ZFar()));
         GL.UniformMatrix4(1, false, ref TheClient.MainWorldView.PrimaryMatrix);
     }
     else if (TheClient.MainWorldView.FBOid == FBOID.MAIN)
     {
         TheClient.Engine.Shaders3D.s_fbo_grass = TheClient.Engine.Shaders3D.s_fbo_grass.Bind();
         GL.UniformMatrix4(1, false, ref TheClient.MainWorldView.PrimaryMatrix);
     }
     else if (TheClient.MainWorldView.FBOid == FBOID.SHADOWS && TheClient.MainWorldView.TranspShadows)
     {
         TheClient.Engine.Shaders3D.s_shadow_grass = TheClient.Engine.Shaders3D.s_shadow_grass.Bind();
     }
     else
     {
         return;
     }
     GL.ActiveTexture(TextureUnit.Texture3);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture2);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture1);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture0);
     GL.BindTexture(TextureTarget.Texture2DArray, TheClient.GrassTextureID);
     GL.Uniform1(6, (float)GlobalTickTimeLocal);
     GL.Uniform3(7, ClientUtilities.Convert(ActualWind));
     GL.Uniform1(8, TheClient.CVars.r_plantdistance.ValueF * TheClient.CVars.r_plantdistance.ValueF);
     TheClient.Rendering.SetColor(GetSunAdjust(), TheClient.MainWorldView);
     foreach (Chunk chunk in chToRender)
     {
         if (chunk.Plant_VAO != -1)
         {
             Matrix4d mat = Matrix4d.CreateTranslation(ClientUtilities.ConvertD(chunk.WorldPosition.ToLocation() * Chunk.CHUNK_SIZE));
             TheClient.MainWorldView.SetMatrix(2, mat);
             GL.BindVertexArray(chunk.Plant_VAO);
             GL.DrawElements(PrimitiveType.Points, chunk.Plant_C, DrawElementsType.UnsignedInt, IntPtr.Zero);
         }
     }
     TheClient.isVox = true;
     TheClient.SetEnts();
 }