public override void Process(int width, int height, GLTextuer2D tex, GLTextuer2D output) { base.Process(width, height, tex, output); if (shader != null) { ResizeViewTo(tex, output, tex.Width, tex.Height, width, height); tex = output; IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit)); Vector3 min = Min; Vector3 max = Max; Vector3 mid = Mid; Vector2 value = Value; Vector2 tiling = new Vector2(TileX, TileY); shader.Use(); shader.SetUniform2("tiling", ref tiling); shader.SetUniform("MainTex", 0); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); tex.Bind(); shader.SetUniform3("maxValues", ref max); shader.SetUniform3("minValues", ref min); shader.SetUniform3("midValues", ref mid); shader.SetUniform2("value", ref value); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); //output.Bind(); //output.CopyFromFrameBuffer(width, height); //GLTextuer2D.Unbind(); Blit(output, width, height); } }
public override void Process(int width, int height, GLTextuer2D tex, GLTextuer2D output) { base.Process(width, height, tex, output); if (shader != null) { ResizeViewTo(tex, output, tex.Width, tex.Height, width, height); tex = output; IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit)); Matrix3 rot = Rotation; Matrix3 sc = Scale; Vector3 tr = Translation; Vector2 tiling = new Vector2(TileX, TileY); shader.Use(); shader.SetUniform2("tiling", ref tiling); shader.SetUniform("MainTex", 0); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); tex.Bind(); shader.SetUniformMatrix3("rotation", ref rot); shader.SetUniformMatrix3("scale", ref sc); shader.SetUniform3("translation", ref tr); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); //output.Bind(); //output.CopyFromFrameBuffer(width, height); //GLTextuer2D.Unbind(); Blit(output, width, height); } }
public virtual void DrawFull() { if (Mat != null && Mat.Shader != null) { IGLProgram shader = Mat.Shader; IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); if (Mat.Albedo != null) { Mat.Albedo.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture1); if (Mat.Metallic != null) { Mat.Metallic.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture2); if (Mat.Roughness != null) { Mat.Roughness.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture3); if (Mat.Occlusion != null) { Mat.Occlusion.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture4); if (Mat.Normal != null) { Mat.Normal.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture5); if (Mat.Height != null) { Mat.Height.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture6); PBRMaterial.BRDFLut.Bind(); IGL.Primary.ActiveTexture((int)TextureUnit.Texture7); if (IrradianceMap != null) { IrradianceMap.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture8); if (PrefilterMap != null) { PrefilterMap.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture9); if (Mat.Thickness != null) { Mat.Thickness.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture10); if (Mat.Emission != null) { Mat.Emission.Bind(); } //use shader shader.Use(); //set texture bind points shader.SetUniform("albedo", 0); shader.SetUniform("metallicMap", 1); shader.SetUniform("roughnessMap", 2); shader.SetUniform("occlusionMap", 3); shader.SetUniform("normalMap", 4); shader.SetUniform("heightMap", 5); shader.SetUniform("brdfLUT", 6); shader.SetUniform("irradianceMap", 7); shader.SetUniform("prefilterMap", 8); shader.SetUniform("thicknessMap", 9); shader.SetUniform("emissionMap", 10); Vector3 lpos = LightPosition; Vector3 lc = LightColor; Vector3 cam = CameraPosition; //set camera and light stuff shader.SetUniform3("cameraPosition", ref cam); shader.SetUniform3("lightPosition", ref lpos); shader.SetUniform3("lightColor", ref lc); shader.SetUniform("lightPower", LightPower); //setup MVP and N matrices Matrix4 proj = Projection; Matrix4 view = View; Matrix4 m = Model; Matrix4 norm = Matrix4.Invert(m); norm.Transpose(); shader.SetUniformMatrix4("projectionMatrix", ref proj); shader.SetUniformMatrix4("viewMatrix", ref view); shader.SetUniformMatrix4("modelMatrix", ref m); shader.SetUniformMatrix4("normalMatrix", ref norm); shader.SetUniform("far", Far); shader.SetUniform("near", Near); shader.SetUniform("heightScale", Mat.HeightScale); shader.SetUniform("refraction", Mat.IOR); ///SSS Related shader.SetUniform("SSS_Distortion", Mat.SSSDistortion); shader.SetUniform("SSS_Ambient", Mat.SSSAmbient); shader.SetUniform("SSS_Power", Mat.SSSPower); if (Mat.ClipHeight) { shader.SetUniform("occlusionClipBias", Mat.ClipHeightBias); } else { shader.SetUniform("occlusionClipBias", -1.0f); } shader.SetUniform("displace", Mat.UseDisplacement); Vector2 tiling = Tiling; shader.SetUniform2("tiling", ref tiling); ///draw vao.Bind(); if (Mat.UseDisplacement) { IGL.Primary.DrawElements((int)BeginMode.Patches, indicesCount, (int)DrawElementsType.UnsignedInt, 0); } else { IGL.Primary.DrawElements((int)BeginMode.Triangles, indicesCount, (int)DrawElementsType.UnsignedInt, 0); } GLVertexArray.Unbind(); GLTextuer2D.Unbind(); } }