public MadTank(Actor self, MadTankInfo info) { this.self = self; this.info = info; renderUnit = self.Trait <RenderUnit>(); screenShaker = self.World.WorldActor.Trait <ScreenShaker>(); }
public override void RenderBeforeChildren(RenderEventArgs arg) { TransformFeedbackObject tf = transformFeedbackObjects[(currentIndex + 1) % 2]; // update { GL.Instance.Enable(GL.GL_RASTERIZER_DISCARD); RenderUnit unit = this.RenderUnits[currentIndex]; ShaderProgram program = unit.Program; //program.SetUniform("xxx", value); unit.Render(tf); // update buffers and record output to tf's binding. GL.Instance.Disable(GL.GL_RASTERIZER_DISCARD); } // render { RenderUnit unit = this.RenderUnits[(currentIndex + 1) % 2 + 2]; ShaderProgram program = unit.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(unit); // render updated buffers without specifying vertex count. } // exchange { currentIndex = (currentIndex + 1) % 2; } }
public RAHarvesterDockSequence(Actor self, Actor proc) { this.proc = proc; state = State.Turn; harv = self.Trait <Harvester>(); ru = self.Trait <RenderUnit>(); }
public override void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.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); unit.Render(); }
public override void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); mat4 normal = glm.transpose(glm.inverse(view * model)); if (this.RenderModel) { RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; program.SetUniform(projectionMatrix, projection); program.SetUniform(viewMatrix, view); program.SetUniform(modelMatrix, model); program.SetUniform(normalMatrix, normal); unit.Render(); } if (this.RenderNormal) { RenderUnit unit = this.RenderUnits[1]; ShaderProgram program = unit.Program; program.SetUniform(projectionMatrix, projection); program.SetUniform(viewMatrix, view); program.SetUniform(modelMatrix, model); unit.Render(); } }
private static void InsertRenderUnit(List <RenderUnit> list, FChar character, Random random, int x, out int newX, Font font) { RenderUnit unit = new RenderUnit(); if (!font.images.ContainsKey(character)) { unit.x = x; unit.image = null; unit.corrCharacter = character; unit.rightBorderX = unit.x + (int)(0.3 * Font.pixelsPerCmH); list.Add(unit); newX = x + (int)(0.3 * Font.pixelsPerCmV); return; } int selectedImageIndex = random.Next(font.images[character].Count()); unit.x = (int)(x - font.leftMargins[character][selectedImageIndex] * Font.pixelsPerCmV); unit.image = font.images[character][selectedImageIndex]; unit.corrCharacter = character; unit.rightBorderX = unit.x + (int)(font.rightMargins[character][selectedImageIndex] * Font.pixelsPerCmH); list.Add(unit); newX = x + (int)((font.rightMargins[character][selectedImageIndex] - font.leftMargins[character][selectedImageIndex] + letterDistance) * Font.pixelsPerCmV); }
protected override void DoInitialize() { base.DoInitialize(); this.lastTime = DateTime.Now; this.RotateSpeed = 0.2f; var bitmap = new Bitmap(@"sunColor.png"); var storage = new TexImage1D(0, GL.GL_RGBA, bitmap.Width, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, new ImageDataProvider(bitmap)); var texture = new Texture(TextureTarget.Texture1D, 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(); RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; program.SetUniform("sunColor", texture); }
/// <summary> /// might need to make this thread safe. /// </summary> /// <param name="s"></param> public virtual void SetSprite(RenderUnit ru) { if (ParentObject != null) { ParentObject.renderUnit = ru; } }
/// <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(); RenderUnit unit = this.RenderUnits[(int)RenderMode.Textured]; ShaderProgram program = unit.Program; program.SetUniform("textureMap", texture); this.currentTexture = texture; }
protected override void DoInitialize() { base.DoInitialize(); this.vVertexBuffer = this.model.GetVertexAttributeBuffer(SlicesModel.position); Texture volume = Engine256Loader.Load(); volume.TextureUnitIndex = 0; Texture lut = TransferFunctionLoader.Load(); lut.TextureUnitIndex = 1; { RenderUnit unit = this.RenderUnits[(int)RenderMode.Default]; ShaderProgram program = unit.Program; program.SetUniform("volume", volume); } { RenderUnit unit = this.RenderUnits[(int)RenderMode.Classification]; ShaderProgram program = unit.Program; program.SetUniform("volume", volume); program.SetUniform("lut", lut); } }
public RAHarvesterDockSequence(Actor self, Actor proc) { this.proc = proc; state = State.Turn; harv = self.Trait<Harvester>(); ru = self.Trait<RenderUnit>(); }
/// <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 TexImage2D(TexImage2D.Target.Texture2D, 0, GL.GL_RED, image.Width, image.Height, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, new ImageDataProvider(image)); var heightMapTexture = new Texture(TextureTarget.Texture2D, 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(); RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; program.SetUniform("heightMapTexture", heightMapTexture); this.heightTexture = heightMapTexture; }
public HarvestResource(Actor self, int2 cell) { harv = self.Trait<Harvester>(); facing = self.Trait<IFacing>(); renderUnit = self.Trait<RenderUnit>(); resourceLayer = self.World.WorldActor.Trait<ResourceLayer>(); harvestCell = cell; }
public HarvesterDockSequence(Actor self, Actor proc) { this.proc = proc; state = State.Turn; harv = self.Trait<Harvester>(); ru = self.Trait<RenderUnit>(); startDock = self.Trait<IHasLocation>().PxPosition; endDock = proc.Trait<IHasLocation>().PxPosition + new PVecInt(-15,8); }
public HarvesterDockSequence(Actor self, Actor proc) { this.proc = proc; state = State.Turn; harv = self.Trait <Harvester>(); ru = self.Trait <RenderUnit>(); startDock = self.CenterPosition; endDock = proc.CenterPosition + DockOffset; }
public HarvesterDockSequence(Actor self, Actor proc) { this.proc = proc; state = State.Turn; harv = self.Trait<Harvester>(); ru = self.Trait<RenderUnit>(); startDock = self.CenterPosition; endDock = proc.CenterPosition + DockOffset; }
public HarvesterDockSequence(Actor self, Actor proc) { this.proc = proc; state = State.Turn; harv = self.Trait <Harvester>(); ru = self.Trait <RenderUnit>(); startDock = self.Trait <IHasLocation>().PxPosition; endDock = proc.Trait <IHasLocation>().PxPosition + new int2(-15, 8); }
internal void RegisterCamera(RenderCamera camera) { Camera component = camera.GetComponent <Camera>(); if ((component.get_cullingMask() & 1 << base.get_gameObject().get_layer()) != 0) { this.m_RenderUnit = new RenderUnit(camera, this); camera.RegisterObject(this); } }
protected override void DoInitialize() { base.DoInitialize(); { var bitmap = new Bitmap(@"heightmap.png"); var storage = new TexImage2D(TexImage2D.Target.Texture2D, 0, GL.GL_RGBA, bitmap.Width, bitmap.Height, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, new ImageDataProvider(bitmap)); var texture = new Texture(TextureTarget.Texture2D, storage); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_REPEAT)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_REPEAT)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_REPEAT)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR)); texture.Initialize(); texture.TextureUnitIndex = 0; bitmap.Dispose(); this.displacementMap = texture; } { var bitmap = new Bitmap(@"diffuse.png"); var storage = new TexImage2D(TexImage2D.Target.Texture2D, 0, GL.GL_RGBA, bitmap.Width, bitmap.Height, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, new ImageDataProvider(bitmap)); var texture = new Texture(TextureTarget.Texture2D, storage); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_REPEAT)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_REPEAT)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_REPEAT)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR)); texture.Initialize(); texture.TextureUnitIndex = 1; bitmap.Dispose(); this.colorMap = texture; } { var light = new DirectionalLight(); light.Color = new vec3(1, 1, 1); light.AmbientIntensity = 1.0f; light.DiffuseIntensity = 0.01f; light.direction = new vec3(1, 1, 0); this.directionalLight = light; } { RenderUnit unit = this.RenderUnits[0]; VertexArrayObject vao = unit.VertexArrayObject; IndexBuffer indexBuffer = vao.IndexBuffer; indexBuffer.Mode = DrawMode.Patches; var polygonModeState = new PolygonModeState(CSharpGL.PolygonMode.Fill); unit.StateList.Add(polygonModeState); this.PolygonMode = polygonModeState; } }
public override void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; program.SetUniform("MVP", projection * view * model); unit.Render(); }
protected override void DoInitialize() { base.DoInitialize(); RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; program.SetUniform("TERRAIN_SIZE", new ivec2(TerainModel.TERRAIN_WIDTH, TerainModel.TERRAIN_DEPTH)); program.SetUniform("scale", (TerainModel.TERRAIN_WIDTH + TerainModel.TERRAIN_DEPTH) * 0.08f); var image = new Bitmap("heightmap512x512.png"); this.UpdateHeightmap(image); }
public SwallowActor(Actor self, Target target, WeaponInfo weapon) { this.target = target; this.weapon = weapon; sandworm = self.Trait <Sandworm>(); positionable = self.Trait <Mobile>(); swallow = self.Trait <AttackSwallow>(); renderUnit = self.Trait <RenderUnit>(); radarPings = self.World.WorldActor.TraitOrDefault <RadarPings>(); countdown = swallow.Info.AttackTime; renderUnit.DefaultAnimation.ReplaceAnim("burrowed"); stance = AttackState.Burrowed; location = target.Actor.Location; }
protected override void DoInitialize() { base.DoInitialize(); Texture volume = Engine256Loader.Load(); volume.TextureUnitIndex = 0; for (int i = 0; i < this.RenderUnits.Count; i++) { RenderUnit unit = this.RenderUnits[i]; ShaderProgram program = unit.Program; program.SetUniform("volume", volume); program.SetUniform("step_size", new vec3(1.0f / Engine256Loader.XDIM, 1.0f / Engine256Loader.YDIM, 1.0f / Engine256Loader.ZDIM)); } }
protected override void DoInitialize() { base.DoInitialize(); for (int i = 0; i < 2; i++) { var tf = new TransformFeedbackObject(); RenderUnit unit = this.RenderUnits[i]; VertexShaderAttribute[] attributes = unit.VertexArrayObject.VertexAttributes; for (uint t = 0; t < attributes.Length; t++) { tf.BindBuffer(t, attributes[t].Buffer); } this.transformFeedbackObjects[i] = tf; } }
public override void RenderBeforeChildren(RenderEventArgs arg) { ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); mat4 mv = view * model; vec3 cameraPos = new vec3(glm.inverse(mv) * new vec4(0, 0, 0, 1)); RenderUnit unit = this.RenderUnits[(int)this.CurrentMode]; ShaderProgram program = unit.Program; program.SetUniform("MVP", projection * view * model); program.SetUniform("camPos", cameraPos); unit.Render(); }
public override void RenderBeforeChildren(RenderEventArgs arg) { RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); mat4 normal = glm.transpose(glm.inverse(view * model)); program.SetUniform(projectionMatrix, projection); program.SetUniform(viewMatrix, view); program.SetUniform(modelMatrix, model); program.SetUniform(normalMatrix, normal); program.SetUniform(lightPosition, new vec3(view * new vec4(light.Position, 1.0f))); program.SetUniform(spotDirection, new vec3(view * new vec4(-light.Position, 0.0f))); unit.Render(); }
public override void RenderBeforeChildren(CSharpGL.RenderEventArgs arg) { if (!this.IsInitialized) { this.Initialize(); } ICamera camera = arg.CameraStack.Peek(); mat4 projectionMatrix = camera.GetProjectionMatrix(); mat4 viewMatrix = camera.GetViewMatrix(); mat4 modelMatrix = this.GetModelMatrix(); RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; program.SetUniform(mvpMatrix, projectionMatrix * viewMatrix * modelMatrix); program.SetUniform(skybox, this.texture); unit.Render(); }
public void UpdateTexture(Bitmap bitmap) { bitmap.RotateFlip(RotateFlipType.Rotate180FlipX); var texture = new Texture(TextureTarget.Texture2D, new TexImage2D(TexImage2D.Target.Texture2D, 0, (int)GL.GL_RGBA, bitmap.Width, bitmap.Height, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, new ImageDataProvider(bitmap))); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR)); texture.Initialize(); RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; program.SetUniform("u_texture", texture); }
public override void RenderBeforeChildren(RenderEventArgs arg) { RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); mat3 normal = new mat3(glm.transpose(glm.inverse(view * model))); program.SetUniform(MVP, projection * view * model); program.SetUniform(normalMatrix, normal); vec3 lightDir = new vec3(view * new vec4(this.Light.Direction, 0.0f)); program.SetUniform(lightDirection, lightDir); var cameraDrection = new vec3(0, 0, 1); // camera direction in eye/view/camera space. program.SetUniform(halfVector, (lightDir + cameraDrection).normalize()); unit.Render(); }
private void RaycastingSetupUniforms(int width, int height) { // 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 RenderUnit unit = this.RenderUnits[1]; ShaderProgram program = unit.Program; program.SetUniform("ScreenSize", new vec2(width, height)); program.SetUniform("StepSize", g_stepSize); program.SetUniform("TransferFunc", this.transferFunc1DTexture); program.SetUniform("ExitPoints", this.backface2DTexture); 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)); }
protected override void DoInitialize() { base.DoInitialize(); { this.GroupX = 1; this.GroupY = 1; this.GroupZ = 1; } { // This is the texture that the compute program will write into var storage = new TexStorage2D(TexStorage2D.Target.Texture2D, 8, GL.GL_RGBA32F, 256, 256); var texture = new Texture(TextureTarget.Texture2D, storage); texture.Initialize(); this.outputTexture = texture; } { RenderUnit unit = this.RenderUnits[2]; ShaderProgram program = unit.Program; program.SetUniform("output_image", this.outputTexture); } }
public override void RenderBeforeChildren(RenderEventArgs arg) { var viewport = new int[4]; GL.Instance.GetIntegerv((uint)GetTarget.Viewport, viewport); if (this.width != viewport[2] || this.height != viewport[3]) { Resize(viewport[2], viewport[3]); this.width = viewport[2]; this.height = viewport[3]; } ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); this.UpdateRotation(); mat4 model = this.GetModelMatrix(); mat4 mvp = projection * view * model; { RenderUnit unit = this.RenderUnits[0]; ShaderProgram program = unit.Program; program.SetUniform("MVP", mvp); // render to texture this.framebuffer.Bind(FramebufferTarget.Framebuffer); GL.Instance.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); { unit.Render(); } this.framebuffer.Unbind(FramebufferTarget.Framebuffer); } { RenderUnit unit = this.RenderUnits[1]; ShaderProgram program = unit.Program; program.SetUniform("MVP", mvp); unit.Render(); } }
public override void RenderBeforeChildren(RenderEventArgs arg) { TransformFeedbackObject tf = transformFeedbackObjects[(currentIndex + 1) % 2]; // update { GL.Instance.Enable(GL.GL_RASTERIZER_DISCARD); RenderUnit unit = this.RenderUnits[currentIndex]; ShaderProgram program = unit.Program; // set the uniforms program.SetUniform("center", center); program.SetUniform("radius", radius); program.SetUniform("g", g); program.SetUniform("dt", dt); program.SetUniform("bounce", bounce); program.SetUniform("seed", random.Next()); unit.Render(tf); // update buffers and record output to tf's binding. GL.Instance.Disable(GL.GL_RASTERIZER_DISCARD); } // render { RenderUnit unit = this.RenderUnits[(currentIndex + 1) % 2 + 2]; ShaderProgram program = unit.Program; ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); program.SetUniform("Projection", projection); program.SetUniform("View", view * model); //unit.Render(); // this methos must specify vertes count. tf.Draw(unit); // render updated buffersi without specifying vertex count. } // exchange { currentIndex = (currentIndex + 1) % 2; } }
public override void RenderBeforeChildren(RenderEventArgs arg) { { RenderUnit unit = this.RenderUnits[0]; ShaderProgram computeProgram = unit.Program; // Activate the compute program and bind the output texture image computeProgram.Bind(); glBindImageTexture((uint)computeProgram.GetUniformLocation("input_image"), this.texture.Id, 0, false, 0, GL.GL_READ_WRITE, GL.GL_RGBA32F); glBindImageTexture((uint)computeProgram.GetUniformLocation("output_image"), this.intermediateTexture.Id, 0, false, 0, GL.GL_READ_WRITE, GL.GL_RGBA32F); // Dispatch glDispatchCompute(1, width, 1); glMemoryBarrier(GL.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); computeProgram.Unbind(); computeProgram.Bind(); glBindImageTexture((uint)computeProgram.GetUniformLocation("input_image"), this.intermediateTexture.Id, 0, false, 0, GL.GL_READ_WRITE, GL.GL_RGBA32F); glBindImageTexture((uint)computeProgram.GetUniformLocation("output_image"), this.finalTexture.Id, 0, false, 0, GL.GL_READ_WRITE, GL.GL_RGBA32F); // Dispatch glDispatchCompute(1, height, 1); glMemoryBarrier(GL.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); computeProgram.Unbind(); } { ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); var renderUnit = this.RenderUnits[1]; // the only render unit in this node. ShaderProgram program = renderUnit.Program; program.SetUniform(tex, this.finalTexture); program.SetUniform(projectionMatrix, projection); program.SetUniform(viewMatrix, view); program.SetUniform(modelMatrix, model); renderUnit.Render(); } }
public SpriteHarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength) : base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength) { ru = self.Trait<RenderUnit>(); }