private static void SetShaderUniforms(Matrix4 mvpMatrix, float scaleX, float scaleY, float scaleZ, float centerX, float centerY, float centerZ, Shader shader) { shader.SetVector3("center", centerX, centerY, centerZ); shader.SetVector3("scale", scaleX, scaleY, scaleZ); shader.SetVector4("color", new Vector4(1, 0, 1, 1)); Matrix4 matrix = mvpMatrix; shader.SetMatrix4x4("mvpMatrix", ref matrix); }
public static void DrawQuadGradient(Vector3 topColor, Vector3 bottomColor, VertexArrayObject screenVao) { // draw RGB and alpha channels of texture to screen quad Shader shader = OpenTKSharedResources.shaders["Gradient"]; shader.UseProgram(); EnableAlphaBlendingWhiteBackground(); shader.SetVector3("topColor", topColor); shader.SetVector3("bottomColor", bottomColor); DrawScreenTriangle(shader, screenVao); }
public void SetShaderUniforms(Shader shader) { foreach (var uniform in intUniformsByName) { shader.SetInt(uniform.Key, uniform.Value); } foreach (var uniform in floatUniformsByName) { shader.SetFloat(uniform.Key, uniform.Value); } foreach (var uniform in vec2UniformsByName) { shader.SetVector2(uniform.Key, uniform.Value); } foreach (var uniform in vec3UniformsByName) { shader.SetVector3(uniform.Key, uniform.Value); } foreach (var uniform in vec4UniformsByName) { shader.SetVector4(uniform.Key, uniform.Value); } foreach (var uniform in mat4UniformsByName) { Matrix4 value = uniform.Value; shader.SetMatrix4x4(uniform.Key, ref value); } }
private void SetCenterUniform(float centerX, float centerY, float centerZ) { Shader shader = OpenTKSharedResources.shaders["SolidColor3D"]; shader.UseProgram(); shader.SetVector3("center", centerX, centerY, centerZ); }
private void SetScaleUniform() { Shader shader = OpenTKSharedResources.shaders["SolidColor3D"]; shader.UseProgram(); shader.SetVector3("scale", scaleX, scaleY, scaleZ); }
public static void DrawNudMaterialSphere(Shader shader, NUD.Material material, Mesh3D screenTriangle, Dictionary <NUD.DummyTextures, Texture> dummyTextures) { if (!shader.ProgramCreatedSuccessfully) { return; } shader.UseProgram(); // Use the same uniforms as the NUD shader. GenericMaterial genericMaterial = new GenericMaterial(); NudUniforms.SetMaterialPropertyUniforms(genericMaterial, material); genericMaterial.SetShaderUniforms(shader); NUD.SetStageLightingUniforms(shader, 0); ModelContainer.SetRenderSettingsUniforms(shader); nudSphereCamera.UpdateMatrices(); ModelContainer.SetLightingUniforms(shader, nudSphereCamera); ModelContainer.SetCameraMatrixUniforms(nudSphereCamera, shader); // Use default textures rather than textures from the NUT. NudUniforms.SetTextureUniformsNudMatSphere(shader, material, dummyTextures); // These values aren't needed in the shader currently. shader.SetVector3("cameraPosition", 0, 0, 0); shader.SetFloat("zBufferOffset", 0); shader.SetFloat("bloomThreshold", Runtime.bloomThreshold); bool isTransparent = (material.srcFactor > 0) || (material.dstFactor > 0) || (material.alphaFunction > 0) || (material.alphaTest > 0); shader.SetBoolToInt("isTransparent", isTransparent); // Set texture uniforms for the mesh attributes. shader.SetTexture("normalTex", sphereNrmTex.Id, TextureTarget.Texture2D, 15); shader.SetTexture("uvTex", sphereUvTex.Id, TextureTarget.Texture2D, 16); shader.SetTexture("tanTex", sphereTanTex.Id, TextureTarget.Texture2D, 17); shader.SetTexture("bitanTex", sphereBitanTex.Id, TextureTarget.Texture2D, 18); // Draw full screen "quad" (big triangle) ScreenDrawing.DrawScreenTriangle(shader, screenTriangle); }
public static void SystemColorVector3Uniform(Shader shader, System.Drawing.Color color, string name) { shader.SetVector3(name, ColorUtils.Vector4FromColor(color).Xyz); }
public static void LightColorVector3Uniform(Shader shader, LightColor color, string name) { // Not declared in the Shader class to make the Shader class more portable. shader.SetVector3(name, color.R, color.G, color.B); }