/// <summary> /// Load a user defined heightmap /// </summary> /// <param name="image"></param> public void UpdateHeightmap(Bitmap image) { if (this.heightTexture != null) { this.heightTexture.Dispose(); } var storage = new TexImageBitmap(image, GL.GL_RED); var heightMapTexture = new Texture(storage, //new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP), new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP), new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP), new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_NEAREST), new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_NEAREST) ); heightMapTexture.TextureUnitIndex = 0; heightMapTexture.Initialize(); RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; program.SetUniform("heightMapTexture", heightMapTexture); this.heightTexture = heightMapTexture; }
public void RenderBeforeChildren(RenderEventArgs arg) { // gets mvpMatrix. ICamera camera = arg.Camera; mat4 projectionMat = camera.GetProjectionMatrix(); mat4 viewMat = camera.GetViewMatrix(); mat4 modelMat = this.GetModelMatrix(); mat4 mvpMatrix = projectionMat * viewMat * modelMat; // a render uint wraps everything(model data, shaders, glswitches, etc.) for rendering. ModernRenderUnit unit = this.RenderUnit; // gets render method. // There could be more than 1 method(vertex shader + fragment shader) to render the same model data. Thus we need an method array. RenderMethod method = unit.Methods[(int)this.CurrentMethod]; // shader program wraps vertex shader and fragment shader. ShaderProgram program = method.Program; //set value for 'uniform mat4 mvpMatrix'; in shader. program.SetUniform("mvpMatrix", mvpMatrix); switch (this.CurrentMethod) { case MethodType.SingleColor: break; case MethodType.MultiTexture: program.SetUniform("texture0", this.texture0); program.SetUniform("texture1", this.texture1); break; default: break; } // render the cube model via OpenGL. method.Render(); }
private void SaveImage(RenderFace side, RenderMethod method) { if (string.IsNullOrEmpty(this.FileName)) { return; } try { string fileName = GetSaveImageFileName(System.IO.Path.ChangeExtension(this.FileName, ".png")); if (string.IsNullOrEmpty(fileName)) { return; } int size = this.IconSize; byte[] buffer = HullIconGenerator.Generate((uint)size, (uint)size, this.FileName, side, method); BitmapHelpers.SaveBitmap(fileName, buffer, size, size); } catch (Exception ex) { MessageBox.Show(this, ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private BitmapSource CreateBitmapFromHullIcon(RenderFace side, RenderMethod method) { int size = this.IconSize; byte[] buffer = HullIconGenerator.Generate((uint)size, (uint)size, this.FileName, side, method); return(BitmapSource.Create(size, size, 96, 96, PixelFormats.Bgra32, null, buffer, size * 4)); }
public override void render(float elapsedTime) { Device d3dDevice = GuiController.Instance.D3dDevice; RenderMethod renderMethod = (RenderMethod)GuiController.Instance.Modifiers["Render Method"]; doRender(renderMethod); }
public void RenderBeforeChildren(RenderEventArgs arg, LightBase light) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); RenderMethod method = this.RenderUnit.Methods[1]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); //program.SetUniform("projectionMat", projection); //program.SetUniform("viewMat", view); program.SetUniform("modelMat", model); program.SetUniform("normalMat", glm.transpose(glm.inverse(model))); // light info. light.SetBlinnPhongUniforms(program); // material. program.SetUniform("material.diffuse", this.Color); program.SetUniform("material.specular", this.Color); program.SetUniform("material.shiness", this.Shiness); // eye pos. program.SetUniform("eyePos", camera.Position); // camera's position in world space. // use blinn phong or not? program.SetUniform("blinn", this.BlinnPhong); method.Render(); }
public void RenderUnderLight(ShadowMappingUnderLightEventArgs arg) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); LightBase light = arg.Light; mat4 lightProjection = light.GetProjectionMatrix(); mat4 lightView = light.GetViewMatrix(); RenderMethod method = this.RenderUnit.Methods[2]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); //program.SetUniform("projectionMat", projection); //program.SetUniform("viewMat", view); program.SetUniform("modelMat", model); program.SetUniform("normalMat", glm.transpose(glm.inverse(model))); program.SetUniform("shadowMat", lightBias * lightProjection * lightView); // light info. light.SetBlinnPhongUniforms(program); // material. program.SetUniform("material.diffuse", this.Color); program.SetUniform("material.specular", this.Color); program.SetUniform("material.shiness", this.Shiness); program.SetUniform("depthTexture", arg.ShadowMap); // eye pos. program.SetUniform("eyePos", camera.Position); // camera's position in world space. // use blinn phong or not? program.SetUniform("blinn", this.BlinnPhong); program.SetUniform("useShadow", this.UseShadow); method.Render(); }
/// <summary> /// Load a user defined heightmap /// </summary> /// <param name="image"></param> public void UpdateTexture(Bitmap image) { if (this.currentTexture != null) { this.currentTexture.Dispose(); } var storage = new TexImage2D(TexImage2D.Target.Texture2D, 0, GL.GL_RGBA, image.Width, image.Height, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, new ImageDataProvider(image)); var texture = new Texture(TextureTarget.Texture2D, storage, //new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR), new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR) ); texture.TextureUnitIndex = 0; texture.Initialize(); RenderMethod method = this.RenderUnit.Methods[(int)RenderMode.Textured]; ShaderProgram program = method.Program; program.SetUniform("textureMap", texture); this.currentTexture = texture; }
public override void RenderBeforeChildren(RenderEventArgs arg) { TransformFeedbackObject tf = transformFeedbackObjects[(currentIndex + 1) % 2]; // update { GL.Instance.Enable(GL.GL_RASTERIZER_DISCARD); RenderMethod method = this.RenderUnit.Methods[currentIndex]; ShaderProgram program = method.Program; //program.SetUniform("xxx", value); method.Render(this.ControlMode, tf); // update buffers and record output to tf's binding. GL.Instance.Disable(GL.GL_RASTERIZER_DISCARD); } // render { RenderMethod method = this.RenderUnit.Methods[(currentIndex + 1) % 2 + 2]; ShaderProgram program = method.Program; ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); program.SetUniform(mvpMatrix, projection * view * model); //unit.Render(); // this method must specify vertex count. tf.Draw(method); // render updated buffers without specifying vertex count. } // exchange { currentIndex = (currentIndex + 1) % 2; } }
public void RenderBeforeChildren(RenderEventArgs arg) { // gets mvpMatrix. ICamera camera = arg.Camera; mat4 projectionMat = camera.GetProjectionMatrix(); mat4 viewMat = camera.GetViewMatrix(); mat4 modelMat = this.GetModelMatrix(); mat4 mvpMatrix = projectionMat * viewMat * modelMat; // a render uint wraps everything(model data, shaders, glswitches, etc.) for rendering. ModernRenderUnit unit = this.RenderUnit; // gets render method. // There could be more than 1 method(vertex shader + fragment shader) to render the same model data. Thus we need an method array. RenderMethod method = unit.Methods[0]; // shader program wraps vertex shader and fragment shader. ShaderProgram program = method.Program; //set value for 'uniform mat4 mvpMatrix'; in shader. program.SetUniform("mvpMatrix", mvpMatrix); { program.SetUniform("halfTransparent", true); // render the cube model via OpenGL. method.Render(); } { program.SetUniform("halfTransparent", false); this.polygonModeSwitch.On(); this.lineWidthSwitch.On(); // render the cube model via OpenGL. method.Render(); this.lineWidthSwitch.Off(); this.polygonModeSwitch.Off(); } }
public void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); mat4 normal = glm.transpose(glm.inverse(view * model)); if (this.RenderModel) { RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; program.SetUniform(projectionMat, projection); program.SetUniform(viewMat, view); program.SetUniform(modelMat, model); program.SetUniform(normalMatrix, normal); method.Render(); } if (this.RenderNormal) { RenderMethod method = this.RenderUnit.Methods[1]; ShaderProgram program = method.Program; program.SetUniform(projectionMat, projection); program.SetUniform(viewMat, view); program.SetUniform(modelMat, model); method.Render(); } }
public void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; program.SetUniform("MVP", projection * view * model); if (this.RenderAsWireframe) { // render wireframe. program.SetUniform("renderWireframe", true); polygonMode.On(); polygonOffsetState.On(); method.Render(); polygonOffsetState.Off(); polygonMode.Off(); } else { // render solid body. program.SetUniform("renderWireframe", false); method.Render(); } }
/// <summary> /// Renders a visual as PNG, XPS, and PDF. /// </summary> public void RenderVisual(string name, RenderMethod renderMethod, bool copyAcroTests) { Name = name; this.visual = renderMethod(); SaveImage(); SaveXps(); SavePdf(); AppendToResultPdf(); if (copyAcroTests && Directory.Exists("..\\..\\..\\!AcroTests")) { string from, to; string s = Directory.GetCurrentDirectory(); // TODO: use GetDirectoryName(Assembly.GetExecutingAssembly().Location) from = name + ".xml"; to = "..\\..\\..\\!AcroTests\\" + from; if (File.Exists(to)) { File.Delete(to); } File.Copy(from, to); try { from = name + ".xps"; to = "..\\..\\..\\AcroTests\\" + from; if (File.Exists(to)) { File.Delete(to); } File.Copy(from, to); } catch { } } }
//private float g_stepSize = 0.001f; protected override void DoInitialize() { base.DoInitialize(); { int width = 128, height = 128, depth = 128; string filename = "math.raw"; if (!File.Exists(filename)) { Voxel[] data = VolumeData.GetData(width, height, depth); using (var fs = new FileStream(filename, FileMode.Create, FileAccess.Write)) using (var bw = new BinaryWriter(fs)) { for (int i = 0; i < data.Length; i++) { Voxel v = data[i]; bw.Write(v.r); bw.Write(v.g); bw.Write(v.b); } } } byte[] volumeData = GetVolumeData(filename); this.volume3DTexture = InitVolume3DTexture(volumeData, width, height, depth); } { RenderMethod method = this.RenderUnit.Methods[1]; ShaderProgram program = method.Program; program.SetUniform("VolumeTex", this.volume3DTexture); //var clearColor = new float[4]; //GL.Instance.GetFloatv((uint)GetTarget.ColorClearValue, clearColor); //program.SetUniform("backgroundColor", new vec4(clearColor[0], clearColor[1], clearColor[2], clearColor[3])); program.SetUniform("backgroundColor", System.Drawing.Color.SkyBlue.ToVec4()); } }
public void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); program.SetUniform("outMouseDownPosition", this.outMouseDownPosition); program.SetUniform("inMouseDownPosition", this.inMouseDownPosition); program.SetUniform("inMouseMovePosition", this.inMouseMovePosition); program.SetUniform("outMouseMovePosition", this.outMouseMovePosition); bool mouseDown = this.mouseDown; if (!mouseDown) { this.stippleSwitch.On(); } method.Render(); if (!mouseDown) { this.stippleSwitch.Off(); } }
public override void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; //program.SetUniform() //uniform mat4 gWorld; program.SetUniform("gWorld", model); //uniform vec3 gEyeWorldPos; program.SetUniform("gEyeWorldPos", camera.Position); //uniform mat4 gVP; program.SetUniform("gVP", projection * view); //uniform sampler2D gDisplacementMap; program.SetUniform("gDisplacementMap", this.displacementMap); //uniform float gDispFactor; program.SetUniform("gDispFactor", this.dispFactor); //uniform DirectionalLight gDirectionalLight; program.SetUniform("gDirectionalLight.Base.Color", this.directionalLight.Color); program.SetUniform("gDirectionalLight.Base.AmbientIntensity", this.directionalLight.AmbientIntensity); program.SetUniform("gDirectionalLight.Base.DiffuseIntensity", this.directionalLight.DiffuseIntensity); program.SetUniform("gDirectionalLight.Direction", this.directionalLight.direction); //uniform sampler2D gColorMap; program.SetUniform("gColorMap", this.colorMap); //uniform float gMatSpecularIntensity; program.SetUniform("gMatSpecularIntensity", 0.1f); //uniform float gSpecularPower; program.SetUniform("gSpecularPower", 0.1f); method.Render(); }
private void ChangeRenderMethod(RenderMethod renderMethod) { rayTracingControl1.RenderMethod = renderMethod; switch (renderMethod) { case RenderMethod.Automatic: btnRenderMethodAutomatic.Checked = true; btnRenderMethodRayTracing.Checked = false; btnRenderMethodXna.Checked = false; break; case RenderMethod.RayTracing: btnRenderMethodAutomatic.Checked = false; btnRenderMethodRayTracing.Checked = true; btnRenderMethodXna.Checked = false; break; case RenderMethod.Xna: btnRenderMethodAutomatic.Checked = false; btnRenderMethodRayTracing.Checked = false; btnRenderMethodXna.Checked = true; break; } }
protected override void DoInitialize() { base.DoInitialize(); // make sure model only returns once. this.vVertexBuffer = (from item in this.RenderUnit.Model.GetVertexAttributeBuffer(SlicesModel.position) select item).First(); var bmp = new Bitmap(1, 1); var bmpG = Graphics.FromImage(bmp); var font = new Font("Arial", 256, GraphicsUnit.Pixel); string text = "煮"; SizeF bigSize = bmpG.MeasureString(text, font); var bitmap = new Bitmap((int)Math.Ceiling(bigSize.Width), (int)Math.Ceiling(bigSize.Height)); using (var g = Graphics.FromImage(bitmap)) { g.DrawString(text, font, Brushes.White, 0, 0); } Texture volume = AmberLoader.Load(bitmap); volume.TextureUnitIndex = 0; Texture lut = TransferFunctionLoader.Load(); lut.TextureUnitIndex = 1; { RenderMethod method = this.RenderUnit.Methods[(int)RenderMode.Default]; ShaderProgram program = method.Program; program.SetUniform("volume", volume); } { RenderMethod method = this.RenderUnit.Methods[(int)RenderMode.Classification]; ShaderProgram program = method.Program; program.SetUniform("volume", volume); program.SetUniform("lut", lut); } }
private RenderMethod GetRenderMethod() { object o = piRareFieldsEnsured.GetValue(this, null); RenderMethod myRenderMethod = (RenderMethod)fiRenderMethod.GetValue(o); return(myRenderMethod); }
protected override void DoInitialize() { base.DoInitialize(); string folder = System.Windows.Forms.Application.StartupPath; { string tff = "tff.png"; this.texTransfer = InitTFF1DTexture(tff); } //{ // string filename = System.IO.Path.Combine(folder + @"\..\..\..\..\Infrastructure\CSharpGL.Models", "filename.raw"); // byte[] volumeData = GetVolumeData(filename); // this.volume3DTexture = InitVolume3DTexture(volumeData, 16, 16, 16); //} { int width = 128, height = 128, depth = 128; byte[] volumeData = VolumeDataGenerator.GetData(width, height, depth); // write volume data to raw file. //using (var fs = new FileStream("self.raw", FileMode.Create, FileAccess.Write)) //using (var bw = new BinaryWriter(fs)) //{ // bw.Write(volumeData); //} this.texVolume = InitVolume3DTexture(volumeData, width, height, depth); } { RenderMethod method = this.RenderUnit.Methods[1]; ShaderProgram program = method.Program; program.SetUniform("texTansfer", this.texTransfer); program.SetUniform("texVolume", this.texVolume); program.SetUniform("backgroundColor", System.Drawing.Color.SkyBlue.ToVec4()); } }
protected override void DoInitialize() { base.DoInitialize(); this.lastTime = DateTime.Now; this.RotateSpeed = 0.2f; var bitmap = new Bitmap(@"sunColor.png"); var storage = new TexImage1D(GL.GL_RGBA, bitmap.Width, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, new ImageDataProvider(bitmap)); var texture = new Texture(storage, new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE), new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE), new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE), new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR), new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR) ); texture.Initialize(); bitmap.Dispose(); RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; program.SetUniform("sunColor", texture); }
public void RenderBeforeChildren(RenderEventArgs arg) { // gets mvpMatrix. ICamera camera = arg.Camera; mat4 projectionMat = camera.GetProjectionMatrix(); mat4 viewMat = camera.GetViewMatrix(); mat4 modelMat = this.GetModelMatrix(); mat4 mvpMatrix = projectionMat * viewMat * modelMat; // a render uint wraps everything(model data, shaders, glswitches, etc.) for rendering. ModernRenderUnit unit = this.RenderUnit; // gets render method. // There could be more than 1 method(vertex shader + fragment shader) to render the same model data. Thus we need an method array. RenderMethod method = unit.Methods[0]; // shader program wraps vertex shader and fragment shader. ShaderProgram program = method.Program; //set value for 'uniform mat4 mvpMatrix'; in shader. program.SetUniform("mvpMatrix", mvpMatrix); program.SetUniform("color", Color); program.SetUniform("lightDir", LightDir); program.SetUniform("lightColor", LightColor); program.SetUniform("renderMode", (int)renderMode); program.SetUniform("viewPos", arg.Camera.Position); // render the cube model via OpenGL. method.Render(); }
protected unsafe override void DoInitialize() { base.DoInitialize(); // pbr: generate a 2D LUT from the BRDF equations used. // then re-configure capture framebuffer object and render screen-space quad with BRDF shader. // pbr: setup framebuffer var captureFBO = new Framebuffer(512, 512); captureFBO.Bind(); var captureRBO = new Renderbuffer(512, 512, GL.GL_DEPTH_COMPONENT24); captureFBO.Attach(FramebufferTarget.Framebuffer, captureRBO, AttachmentLocation.Depth); captureFBO.Attach(FramebufferTarget.Framebuffer, this.texBRDF, 0u); captureFBO.CheckCompleteness(); captureFBO.Unbind(); RenderMethod method = this.RenderUnit.Methods[0]; ViewportSwitch viewportSwitch = new ViewportSwitch(0, 0, 512, 512); viewportSwitch.On(); captureFBO.Bind(); GL.Instance.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); method.Render(); captureFBO.Unbind(); viewportSwitch.Off(); captureFBO.Dispose(); this.texBRDF.GetImage(512, 512).Save(string.Format("texBRDF.png")); }
/// <summary> /// Load a user defined heightmap /// </summary> /// <param name="image"></param> public void UpdateTexture(Bitmap image) { if (this.currentTexture != null) { this.currentTexture.Dispose(); } var storage = new TexImageBitmap(image); var texture = new Texture(storage, //new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR), new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR) ); texture.TextureUnitIndex = 0; texture.Initialize(); RenderMethod method = this.RenderUnit.Methods[(int)RenderMode.Textured]; ShaderProgram program = method.Program; program.SetUniform("textureMap", texture); this.currentTexture = texture; }
public void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.Camera; mat4 projectionMat = camera.GetProjectionMatrix(); mat4 viewMat = camera.GetViewMatrix(); mat4 modelMat = this.GetModelMatrix(); ModernRenderUnit unit = this.RenderUnit; RenderMethod method = unit.Methods[0]; ShaderProgram program = method.Program; program.SetUniform("projectionMat", projectionMat); program.SetUniform("mvMat", viewMat * modelMat); program.SetUniform("normalMat", glm.transpose(glm.inverse(viewMat * modelMat))); mat4[] boneMatrixes = this.textureModel.GetBoneMatrixes(); boneMatrixes = null; if (boneMatrixes != null) { program.SetUniform("bones", boneMatrixes); } program.SetUniform("useBones", boneMatrixes != null); Texture tex = this.textureModel.Texture; if (tex != null) { program.SetUniform("textureMap", tex); } program.SetUniform("useDefault", tex != null ? 0.0f : 1.0f); program.SetUniform("light_position", new vec3(1, 1, 1) * 10); method.Render(); }
protected override void DoInitialize() { base.DoInitialize(); var bmp = new Bitmap(1, 1); var bmpG = Graphics.FromImage(bmp); var font = new Font("Arial", 256, GraphicsUnit.Pixel); string text = "煮"; SizeF bigSize = bmpG.MeasureString(text, font); var bitmap = new Bitmap((int)Math.Ceiling(bigSize.Width), (int)Math.Ceiling(bigSize.Height)); using (var g = Graphics.FromImage(bitmap)) { g.DrawString(text, font, Brushes.White, 0, 0); } Texture volume = AmberLoader.Load(bitmap); volume.TextureUnitIndex = 0; for (int i = 0; i < this.RenderUnit.Methods.Length; i++) { RenderMethod method = this.RenderUnit.Methods[i]; ShaderProgram program = method.Program; program.SetUniform("volume", volume); program.SetUniform("step_size", new vec3(1.0f / AmberLoader.length, 1.0f / AmberLoader.length, 1.0f / AmberLoader.length)); } }
public void RenderBeforeChildren(RenderEventArgs arg) { if (!this.mouseDown) { return; } if (this.inMouseDownPositionUpdated || this.inMouseMovePositionUpdated) { UpdateModel(this.InMouseDownPosition, this.InMouseMovePosition); this.inMouseDownPositionUpdated = false; this.inMouseMovePositionUpdated = false; } ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); method.Render(); }
public void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); mat4 normal = glm.transpose(glm.inverse(view * model)); RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; program.SetUniform("projection", projection); program.SetUniform("view", view); program.SetUniform("model", model); { program.SetUniform("albedo", Albedo); program.SetUniform("metallic", Metallic); program.SetUniform("roughness", Roughness); program.SetUniform("ao", AO); } { program.SetUniform("irradianceMap", this.IrradianceMap); } program.SetUniform("lightPositions", lightPositions); program.SetUniform("lightColors", lightColors); program.SetUniform("camPos", camera.Position); method.Render(); }
//private float g_stepSize = 0.001f; protected override void DoInitialize() { base.DoInitialize(); string folder = System.Windows.Forms.Application.StartupPath; string tff = System.IO.Path.Combine(folder + @"\Infrastructure\CSharpGL.Models", "tff.dat"); this.transferFunc1DTexture = InitTFF1DTexture(tff); string head256 = System.IO.Path.Combine(folder + @"\Infrastructure\CSharpGL.Models", "head256.raw"); byte[] volumeData = GetVolumeData(head256); this.volume3DTexture = InitVolume3DTexture(volumeData, 256, 256, 225); { // setting uniforms such as // ScreenSize // StepSize // TransferFunc // ExitPoints i.e. the backface, the backface hold the ExitPoints of ray casting // VolumeTex the texture that hold the volume data i.e. head256.raw RenderMethod method = this.RenderUnit.Methods[1]; ShaderProgram program = method.Program; //program.SetUniform("StepSize", this.g_stepSize); program.SetUniform("TransferFunc", this.transferFunc1DTexture); program.SetUniform("VolumeTex", this.volume3DTexture); //var clearColor = new float[4]; //OpenGL.GetFloat(GetTarget.ColorClearValue, clearColor); //this.raycastRenderer.glUniform("backgroundColor", clearColor.ToVec4()); program.SetUniform("backgroundColor", new vec4(0.4f, 0.8f, 1.0f, 1.0f)); } }
public override void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); RenderMethod method = this.RenderUnit.Methods[0]; ShaderProgram program = method.Program; // setup uniforms program.SetUniform("projectionMatrix", projection); program.SetUniform("viewMatrix", view); GL.Instance.Clear(GL.GL_ACCUM_BUFFER_BIT); for (int i = 0; i < 3; i++) { mat4 matrix = glm.translate(mat4.identity(), new vec3(i, 0, 0)); matrix = glm.scale(matrix, this.Scale); matrix = glm.rotate(matrix, this.RotationAngle, this.RotationAxis); program.SetUniform("modelMatrix", matrix); method.Render(); if (i == 0) { GL.Instance.Accum(GL.GL_LOAD, 0.5f); } else { GL.Instance.Accum(GL.GL_ACCUM, 0.5f / (float)i); } } GL.Instance.Accum(GL.GL_RETURN, 1.0f); }
private static void Render( CameraBase CameraState, SceneBase Scene, RenderMethod Method, byte MaxDepth, float Epsilon, byte RouletteDepth, float MaximumTerminationProbability, Framebuffer Fb, bool UseMultithreading ) { if ( UseMultithreading ) { Parallel.For<ThreadLocalState>( 0, Fb.Rows, () => new ThreadLocalState( Scene, Method, MaxDepth, Epsilon, RouletteDepth, MaximumTerminationProbability ), ( Y, Loop, State ) => { for ( int X = 0; X < Fb.Columns; X++ ) { Fb[Y, X] = CameraState.RenderPixel( Fb.Columns, Fb.Rows, X, Y, State ); } return State; }, ( State ) => { } ); } else { ThreadLocalState State = new ThreadLocalState( Scene, Method, MaxDepth, Epsilon, RouletteDepth, MaximumTerminationProbability ); for ( int Y = 0; Y < Fb.Rows; Y++ ) { for ( int X = 0; X < Fb.Columns; X++ ) { Fb[Y, X] = CameraState.RenderPixel( Fb.Columns, Fb.Rows, X, Y, State ); } } } }
public static void Pinhole( SceneBase Scene, RenderMethod Method, Framebuffer Fb, byte MaxDepth, float Epsilon, byte RouletteDepth, float MaximumTerminationProbability, bool UseMultithreading, float ImagePlaneDistance, float ImagePlaneHeight, float ImagePlaneWidth, Point PinholeLocation, Vector CameraDirection, Vector Up, UInt16 XSamplesPerPixel, UInt16 YSamplesPerPixel, bool Jitter ) { PinholeCamera Camera = new PinholeCamera( ImagePlaneDistance, ImagePlaneHeight, ImagePlaneWidth, PinholeLocation, CameraDirection, Up, XSamplesPerPixel, YSamplesPerPixel, Jitter ); Render( Camera, Scene, Method, MaxDepth, Epsilon, RouletteDepth, MaximumTerminationProbability, Fb, UseMultithreading ); }
private void ChangeRenderMethod(RenderMethod renderMethod) { rayTracingControl1.RenderMethod = renderMethod; switch (renderMethod) { case RenderMethod.Automatic : btnRenderMethodAutomatic.Checked = true; btnRenderMethodRayTracing.Checked = false; btnRenderMethodXna.Checked = false; break; case RenderMethod.RayTracing: btnRenderMethodAutomatic.Checked = false; btnRenderMethodRayTracing.Checked = true; btnRenderMethodXna.Checked = false; break; case RenderMethod.Xna: btnRenderMethodAutomatic.Checked = false; btnRenderMethodRayTracing.Checked = false; btnRenderMethodXna.Checked = true; break; } }
internal void SetPostFormRenderDelegate(RenderMethod renderMethod) { this._postFormRenderDelegate = renderMethod; }
/// <summary> /// Overriden to correctly redirect rendermethod calls. /// </summary> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // if our container is not visible, don't replace placeholder's content if (!Visible) return; //log.Debug(string.Format("OnPreRender Content['{0}']", this.contentPlaceHolderID)); Control ctlRoot = (this.Page.Master != null) ? (Control)this.Page.Master : (Control)this.Page; Control ctl = ctlRoot.FindControl(this.contentPlaceHolderID); if (ctl != null) { log.Debug(string.Format("OnPreRender Content['{0}'] found placeholder - replacing RenderMethod",this.contentPlaceHolderID)); RenderMethod myRenderMethod = GetRenderMethod(); //log.Debug(string.Format("OnPreRender Content['{0}'] renderMethod found={1}", this.contentPlaceHolderID,(myRenderMethod != null ? "true" : "false"))); // prevent content control from rendering itself this.SetRenderMethodDelegate(new RenderMethod(RenderNothing)); if (myRenderMethod == null) { myRenderMethod = new RenderMethod(RenderChildControls); } // instead replace placeholder's rendermethod to render this control's content ctl.SetRenderMethodDelegate(myRenderMethod); } else { throw new ArgumentException(string.Format("No ContentPlaceHolder with id '{0}' defined on this page.", this.contentPlaceHolderID)); } }
void IHtmlForm.SetRenderMethodDelegate(RenderMethod renderMethod) { _form.SetRenderMethodDelegate(renderMethod); }
public ThreadLocalState( SceneBase Scene, RenderMethod Method, byte MaxDepth, float Epsilon, byte RouletteDepth, float MaximumTerminationProbability ) { this.Rng = new Random(); switch ( Method ) { case RenderMethod.PathTrace: this.RayTracer = new PathTracer( Scene, MaxDepth, Epsilon, Rng, RouletteDepth, MaximumTerminationProbability ); break; default: // RenderMethod.RecursiveRayTrace this.RayTracer = new RecursiveRayTracer( Scene, MaxDepth, Epsilon, Rng, RouletteDepth, MaximumTerminationProbability ); break; } }
public void SetRenderMethodDelegate(RenderMethod renderMethod) { this.RareFieldsEnsured.RenderMethod = renderMethod; this.Controls.SetCollectionReadOnly("Collection_readonly_Codeblocks"); }
public override void close() { currentRenderMethod = RenderMethod.Unsorted; disposeCajas(); }
public void RenderVisual(string name, RenderMethod renderMethod) { RenderVisual(name, renderMethod, false); }
/// <summary> /// Renders a visual as PNG, XPS, and PDF. /// </summary> public void RenderVisual(string name, RenderMethod renderMethod, bool copyAcroTests) { Name = name; this.visual = renderMethod(); SaveImage(); SaveXps(); SavePdf(); AppendToResultPdf(); if (copyAcroTests && Directory.Exists("..\\..\\..\\!AcroTests")) { string from, to; string s = Directory.GetCurrentDirectory(); from = name + ".xml"; to = "..\\..\\..\\!AcroTests\\" + from; if (File.Exists(to)) File.Delete(to); File.Copy(from, to); try { from = name + ".xps"; to = "..\\..\\..\\AcroTests\\" + from; if (File.Exists(to)) File.Delete(to); File.Copy(from, to); } catch { } } }
public void SetRenderMethodDelegate(RenderMethod renderMethod) { RareFieldsEnsured.RenderMethod = renderMethod; // Make the collection readonly if there are code blocks (ASURT 78810) Controls.SetCollectionReadOnly(SR.Collection_readonly_Codeblocks); }
private void doRender(RenderMethod renderMethod) { if (currentRenderMethod != renderMethod) { currentRenderMethod = renderMethod; } switch (currentRenderMethod) { case RenderMethod.Unsorted: doUnsortedRender(); break; case RenderMethod.Texture_Sort: doTextureSortRender(); break; } }
/////////////////////////////////////////////////////////////////////////// public FuncRenderer( RenderMethod rm, object parameter = null ) { this.renderMethod = rm; this.parameter = parameter; }
public void SetRenderMethodDelegate (RenderMethod renderMethod) //DIT { _renderMethodDelegate = renderMethod; }
void IPage.SetPostFormRenderDelegate(RenderMethod renderMethod) { _page.SetPostFormRenderDelegate(renderMethod); }
public void SetRenderMethodDelegate(RenderMethod renderMethod) {}
void IPage.SetRenderMethodDelegate(RenderMethod renderMethod) { _page.SetRenderMethodDelegate(renderMethod); }