public override void Run(RenderControl render) { var material = MeshPhongMaterial.Create("phong.bspline"); material.SetUniform("diffuse", Uniform.Create(new Vector3(1, 0, 1))); var shape = CreateShape(); var node = BrepSceneNode.Create(shape, material, null); render.ShowSceneNode(node); }
public override void Animation(RenderControl render, float time) { if (mMaterial == null) { return; } mMaterial.SetUniform("time", Uniform.Create(time)); render.RequestDraw(); }
public override void Run(RenderControl render) { mGeometry = GeometryBuilder.CreatePlane(20000, 20000, worldWidth - 1, worldDepth - 1); var position = mGeometry.GetGeometry().GetAttribute(0); position.SetDataUsage(EnumBufferDataUsage.DYNAMIC_DRAW); var mPosition = new Float32Array(position.GetData()); for (uint i = 0; i < position.GetCount() / 3; i++) { float z = (float)(35 * Math.Sin(i / 2)); mPosition.SetValue(i * 3 + 2, z); } var material = BasicMaterial.Create("basic-water"); var img = FileImage.Create(GetResourcePath("textures/water.png")); var texture = new ImageTexture2D(); texture.SetSource(img); var desc = texture.GetDesc(); desc.SetWrapS(EnumTextureWrappingType.REPEAT); desc.SetWrapT(EnumTextureWrappingType.REPEAT); texture.SetRepeat(new Vector2(5, 5)); material.AddTexture("map", texture); var color = Vector3.ColorFromHex(0x0044ff); material.SetUniform("diffuse", Uniform.Create(color)); var node = new PrimitiveSceneNode(mGeometry, material); node.SetPickable(false); node.SetCulling(false); render.ShowSceneNode(node); }
private IBindable CreateMaterialUniform() { var materialDescriptionUniform = Uniform <Material> .Create( "MaterialDescription", BufferUsage.UniformBuffer | BufferUsage.Dynamic, ShaderStages.Vertex | ShaderStages.Fragment); materialDescriptionUniform.UniformData = new Material[] { new Material { AmbientColor = _light0.Parameters.AmbientLightColor * _material.AmbientColor, Shininess = _material.Shininess, DiffuseColor = _light0.Parameters.DiffuseLightColor * _material.DiffuseColor, Padding0 = 0f, SpecularColor = _light0.Parameters.SpecularLightColor * _material.SpecularColor, MaterialOverride = _overrideColor ? 1 : 0, Padding1 = Vector4.Zero } }; return(materialDescriptionUniform); }
private IBindable CreateLightSourceUniform() { var lightSourceUniform = Uniform <LightSource> .Create( "LightSource", BufferUsage.UniformBuffer | BufferUsage.Dynamic, ShaderStages.Vertex | ShaderStages.Fragment); lightSourceUniform.UniformData = new LightSource[] { new LightSource { AmbientColor = _light0.Parameters.AmbientLightColor, LightPower = _light0.Parameters.LightPower, DiffuseColor = _light0.Parameters.DiffuseLightColor, AttenuationConstant = _light0.Parameters.AttenuationConstant, SpecularColor = _light0.Parameters.SpecularLightColor, IsHeadlight = _light0 is PhongHeadlight ? 1 : 0, Position = _light0 is PhongPositionalLight light ? light.Position : Vector4.Zero } }; return(lightSourceUniform); }
public override void Run(RenderControl render) { mMaterial1 = MeshPhongMaterial.Create("phong.texture"); mMaterial1.SetUniform("diffuse", Uniform.Create(new Vector3(1, 0, 1))); var texture = ImageTexture2D.Create(GetResourcePath("textures/bricks2.jpg")); texture.SetRepeat(new Vector2(2.0f, 2.0f)); texture.UpdateTransform(); mMaterial1.SetColorMap(texture); var shape = ShapeBuilder.MakeBox(GP.XOY(), 4, 4, 8); mNode = BrepSceneNode.Create(shape, mMaterial1, null); mMaterial2 = MeshPhongMaterial.Create("phong.texture"); var texture2 = ImageTexture2D.Create(GetResourcePath("textures/water.png")); mMaterial2.SetColorMap(texture2); render.ShowSceneNode(mNode); }