public override void _Ready() { // Called every time the node is added to the scene. // Initialization here statManager = (StatManager)GetNode("/root/StatManager"); mat = (ShaderMaterial)GetMaterial(); }
void setShaderMode(Node node, bool showTexture, bool highlight) { if (node is MeshInstance) { MeshInstance mesh = (MeshInstance)node; if (mesh.GetSurfaceMaterial(0) is ShaderMaterial) { ShaderMaterial mat = (ShaderMaterial)mesh.GetSurfaceMaterial(0); if (mat.Shader.ResourcePath == SHADER_PATH) { ShaderMaterial nmat = (ShaderMaterial)mat.Duplicate(); nmat.SetShaderParam("ShowTexture", showTexture); nmat.SetShaderParam("Highlight", highlight); nmat.SetShaderParam("PointSize", 2); mesh.SetSurfaceMaterial(0, nmat); mat.Dispose(); } } } for (int i = 0; i < node.GetChildCount(); i++) { setShaderMode(node.GetChild(i), showTexture, highlight); } }
public override void _Ready() { interact = GetNode <Area2D>("Interact"); shader = (ShaderMaterial)GetNode <Sprite>("Sprite").Material; interact.Connect("body_entered", this, nameof(BodyEntered)); interact.Connect("body_exited", this, nameof(BodyExited)); }
/// <summary> /// /// </summary> /// <param name="control"></param> public override void Load(Control control) { base.Load(control); camera = new PerspectiveCamera(40, control.Width / (float)control.Height, 1, 10000); this.camera.Position.Z = 2000; scene = new Scene(); geometry = new SphereGeometry(15, 64, 32); for (var i = 0; i < N; i++) { var material = new ShaderMaterial() { VertexShader = VertexShader, FragmentShader = this.GenerateFragmentShader() }; var mesh = new Mesh(geometry, material); mesh.Position.X = (0.5f - Mat.Random()) * 1000; mesh.Position.Y = (0.5f - Mat.Random()) * 1000; mesh.Position.Z = (0.5f - Mat.Random()) * 1000; scene.Add(mesh); meshes.Add(mesh); } renderer.SetClearColor(Color.White); this.renderer.Size = control.Size; }
public void finalToConvertSprite() { GD.Print("final the convertion"); GD.Print("first draw"); var img = captureViewport.GetTexture().GetData(); img.FlipY(); var imgTex = new ImageTexture(); imgTex.CreateFromImage(img); var convertedSprite = new Sprite(); convertedSprite.Texture = imgTex; convertedSprite.Centered = false; convertedSprite.Position = new Vector2(xMin, yMin); if (drawMode == drawObjectMode.brush) { var material = new ShaderMaterial(); material.Shader = (Shader)ResourceLoader.Load("res://shaders/blackFix.shader"); convertedSprite.Material = material; } else if (drawMode == drawObjectMode.erase) { convertedSprite.Material = Material; } GetParent().AddChild(convertedSprite); this.Visible = false; EmitSignal("converted_sprite", this, convertedSprite); captureViewport.QueueFree(); cloneDrawObject.QueueFree(); expectedSpriteConvertion = false; this.QueueFree(); }
public PointVoxelMesher(int CHUNK_X_COUNT, int CHUNK_Y_COUNT, int CHUNK_Z_COUNT, int CHUNK_SIZE, float VOX_SIZE, ShaderMaterial s = null) : base(CHUNK_X_COUNT, CHUNK_Y_COUNT, CHUNK_Z_COUNT, CHUNK_SIZE, VOX_SIZE) { if (s == null) { mat = new ShaderMaterial(); mat.SetShader(ResourceLoader.Load(@"res://assets/shaders/point_shader_test.shader") as Shader); mat.SetShaderParam("albedo", new Color(1f, 1f, 1f, 1)); mat.SetShaderParam("point_size", 1f); } else { mat = s; } // mat.SetCullMode(CullMode.Disabled); this.CHUNK_X_COUNT = CHUNK_X_COUNT; this.CHUNK_Y_COUNT = CHUNK_Y_COUNT; this.CHUNK_Z_COUNT = CHUNK_Z_COUNT; this.CHUNK_SIZE = CHUNK_SIZE; this.VOX_SIZE = VOX_SIZE; vertices = vertices = new Vector3[] { new Vector3(0, 0, 0), new Vector3(VOX_SIZE, 0, 0), new Vector3(VOX_SIZE, 0, VOX_SIZE), new Vector3(0, 0, VOX_SIZE), new Vector3(0, VOX_SIZE, 0), new Vector3(VOX_SIZE, VOX_SIZE, 0), new Vector3(VOX_SIZE, VOX_SIZE, VOX_SIZE), new Vector3(0, VOX_SIZE, VOX_SIZE) }; }
public override void _Ready() { Mat = new ShaderMaterial(); Mat.Shader = TrailShader; Mat.SetShaderParam("alpha", 1); MaterialOverride = Mat; }
// Called when the node enters the scene tree for the first time. public override void _Ready() { ViewportContainer cont = GetNode <ViewportContainer>("ViewportContainer"); mat = (ShaderMaterial)cont.Material; mainView = GetNode <Viewport>("ViewportContainer/Viewport"); }
public void onMouseEntered() { var mat = new ShaderMaterial(); mat.Shader = (Shader)GD.Load("res://scenes/item-on-ground-hover.shader"); this.meshInstance.MaterialOverride = mat; }
public override void _Ready() { var mesh = GD.Load <Mesh>("res://asset/cube/cube.obj"); //var diffuse = ResourceLoader.Load<Texture>("res://asset/cube/cube-diffuse.png"); //put together a meshInstance from code var meshInst = new MeshInstance(); meshInst.Mesh = mesh; meshInst.MaterialOverride = GD.Load <ShaderMaterial>("res://asset/cube/cube.shaderMaterial.tres"); meshInst.Translate(Vector3.Up * 3); AddChild(meshInst); //put together a ShaderMaterial via code var shader = GD.Load <Shader>("res://asset/cube/cube.shader"); var diffuse = GD.Load <Texture>("res://asset/cube/cube-diffuse.png"); var meshInstWithShadMat = new MeshInstance(); meshInstWithShadMat.Mesh = mesh; var shadMat = new ShaderMaterial(); shadMat.Shader = shader; //need to explicitly set default shader params yourself when setting up a ShaderMaterial through code shadMat.SetShaderParam("albedo", Colors.White); shadMat.SetShaderParam("uv1_scale", Vector3.One); shadMat.SetShaderParam("uv1_offset", Vector3.Zero); shadMat.SetShaderParam("uv2_scale", Vector3.One); shadMat.SetShaderParam("uv2_offset", Vector3.Zero); shadMat.SetShaderParam("texture_albedo", diffuse); meshInstWithShadMat.MaterialOverride = shadMat; AddChild(meshInstWithShadMat); }
public override void _Ready() { if (Terrain == null || Terrain.GetWidth() != TileSize || Terrain.GetHeight() != TileSize) { Terrain = new ImageTexture(); Terrain.Create(TileSize, TileSize, Image.Format.Rgbaf); terrainImg = new Image(); terrainImg.Create(TileSize, TileSize, false, Image.Format.Rgbaf); } if (Mesh == null) { var mesh = new PlaneMesh(); mesh.Size = new Vector2(TileSize, TileSize); mesh.SubdivideWidth = TileSize; mesh.SubdivideDepth = TileSize; Mesh = mesh; var mat = new ShaderMaterial(); mat.SetShader(TerrainShader); SetSurfaceMaterial(0, mat); } if (WorldPos != Vector3.Zero) { _LoadTerrainData(); } hydraulics = new HydraulicSimulation(Terrain); terrainImg = Terrain.GetData(); }
public override void Init() { _world = new World(RC); // load mesh as geometry var geo1 = MeshReader.LoadGeometry("Assets/Cube.obj.model"); // create and set shader var sp = RC.CreateShader(VsSimpleTexture, PsSimpleTexture); RC.SetShader(sp); var material = new ShaderMaterial(sp); // load a texture and write a text on it var imgData = RC.LoadImage("Assets/cube_tex.jpg"); imgData = RC.TextOnImage(imgData, "Verdana", 80f, "FUSEE rocks!", "Black", 0, 30); var iTex = RC.CreateTexture(imgData); Texture1Param = sp.GetShaderParam("texture1"); RC.SetShaderParamTexture(Texture1Param, iTex); // add object with material _world.AddObject(geo1, material, 0, 0, 500); RC.ClearColor = new float4(0.1f, 0.1f, 0.1f, 1); }
/// <summary> /// /// </summary> /// <param name="control"></param> public override void Load(Control control) { base.Load(control); camera = new Camera(); this.camera.Position.Z = 1; scene = new Scene(); var geometry = new PlaneGeometry(2, 2); uniforms = new Uniforms { { "time", new Uniform() { { "type", "f" }, { "value", 1.0f } } }, { "resolution", new Uniform() { { "type", "v2" }, { "value", new Vector2() } } } }; var material = new ShaderMaterial(null) { Uniforms = uniforms, VertexShader = VertexShader, FragmentShader = FragmentShader, }; mesh = new Mesh(geometry, material); scene.Add(mesh); }
public void loadLastDrawings() { var img = new Image(); var err = img.Load("user://lastDraw.png"); if (err == Error.Ok) { var imgTex = new ImageTexture(); imgTex.CreateFromImage(img); var spr = new Sprite(); spr.Centered = false; var shader = (Shader)ResourceLoader.Load("res://shaders/blackFix.shader"); var material = new ShaderMaterial(); material.Shader = shader; spr.Material = material; spr.Material = material; spr.Texture = imgTex; drawContainerNode.AddChild(spr); } else { GD.PrintErr(err); } }
public void init(Texture[] normals, Texture[] difuses, Color[] cores, ShaderMaterial frente) { Normals = normals; Difuses = difuses; Cores = cores; Frente = frente; }
public override void _Ready() { Instance = this; wallShader = (ShaderMaterial)GetNode <CanvasItem>($"/root/GlobalShaders/{wallPath}").Material; // wallPaletteShader = (ShaderMaterial) GlobalWindow.Instance.GetNode<CanvasItem>(wallPalettePath).Material; backgroundShader = (ShaderMaterial)GlobalWindow.Instance.GetNode <CanvasItem>($"/root/GlobalShaders/{backgroundPath}").Material; }
public PreRecordState(BaseController controller, int attacksCount) { this.controller = controller; canChangeState = false; transitionTime = (float)Global.config.GetValue("Config", "TransitionTime"); if (!isSignInit) { sign = (int)Global.config.GetValue("Config", "InitTransitionSign"); isSignInit = true; } else { sign = -sign; } controller.ResetGetReadyLabel(); state = new RecordActionsState(controller, attacksCount); if (material == null) { material = (ShaderMaterial)GD.Load("res://NegativeShaderMaterial.material"); } GD.Print("Transition to record attacks"); controller.Attacker.Animate(Action.Timeout); controller.Defender.Animate(Action.Timeout); getReadySound = (AudioStreamPlayer)controller.GetNode("Sounds").GetNode("GetReadySound"); getReadySound.Play(); }
public CartaFactory() { recurso = ResourceLoader.Load <PackedScene>("res://scene/Carta.tscn"); difuses = carregaDifuses(); normals = carregaNormals(); cores = carregaCores(); shaderFrente = carregaShaderFrente(); }
public void DrawEntityShadowVolume(DynamicLight Light, ShaderMaterial ShadowVolume) { RenderAPI.DbgPushGroup("Entity DrawShadowVolume"); for (int i = 0; i < Entities.Length; i++) { Entities[i].DrawShadowVolume(Light.GetBoundingSphere(), ShadowVolume); } RenderAPI.DbgPopGroup(); }
public async override void _Ready() { parent = GetParent(); if (!parent.HasMethod("BlockMap")) { GD.PushError("BlockLighting node [" + Name + "] is not a child of BlockLayer."); invalid = true; return; } padUp = new Sprite(); padDown = new Sprite(); padRight = new Sprite(); padLeft = new Sprite(); AddChild(padUp); AddChild(padRight); AddChild(padDown); AddChild(padLeft); padUp.Texture = pixel; padUp.Centered = false; padRight.Texture = pixel; padRight.Centered = false; padDown.Texture = pixel; padDown.Centered = false; padLeft.Texture = pixel; padLeft.Centered = false; padUp.Position = new Vector2(-1, -1); padUp.Scale = new Vector2(3, 1); padRight.Position = new Vector2(-1, 0); padRight.Scale = new Vector2(1, 1); padDown.Position = new Vector2(-1, 1); padDown.Scale = new Vector2(3, 1); padLeft.Position = new Vector2(1, 0); padLeft.Scale = new Vector2(1, 1); Texture = pixel; Material = new ShaderMaterial(); (Material as ShaderMaterial).Shader = shader; await ToSignal(parent, "finished_setup"); data_node = (BlockData)parent.Get("data_node"); Texture = pixel; Centered = false; BlockProp = (Array)parent.Get("block_properties"); update_data(); ThreadStart threadStart = new ThreadStart(LightingThread); thread = new System.Threading.Thread(threadStart); thread.Priority = ThreadPriority.Highest; thread.Start(); }
public override void _Ready() { material = (ShaderMaterial)Material; SetAmount(Settings.Instance.ChromaticAmount); OnChanged(Settings.Instance.ChromaticEnabled); Settings.Instance.ChromaticAmount.OnChanged += SetAmount; Settings.Instance.ChromaticEnabled.OnChanged += OnChanged; }
public void DrawShadowVolume(ShaderMaterial ShadowVolume) { RenderAPI.DbgPushGroup("Map DrawShadowVolume"); for (int ModelIdx = 0; ModelIdx < MapModels.Length; ModelIdx++) { MapModels[ModelIdx].DrawShadowVolume(ShadowVolume); } RenderAPI.DbgPopGroup(); }
private static void Paint(ShaderMaterial material, Color color, string key, IEnumerable <int> variations) { int k = 0; foreach (int variation in variations) { material.SetShaderParam(string.Format("{0}_{1}", key, k), GetColorVariation(color, variation)); k++; } }
public override void _Ready() { gradientTexture.Gradient = new Gradient(); ShaderMaterial shader = (ShaderMaterial)Material; shader.SetShaderParam("colors", gradientTexture); shader.SetShaderParam("seal", 0f); tween = new Tween(); AddChild(tween); }
public Object(Geometry geo, ShaderMaterial m, int x, int y, int z) { _mesh = geo.ToMesh(); _material = m; _posX = x; _posY = y; _posZ = z; _angX = .0f; _angY = .0f; _angY = .0f; }
public override void _Process(float Delta) { Assert(MinAdsMultiplyer > 0 && MinAdsMultiplyer <= 1); if (Ads) { AdsMultiplyer = Clamp(AdsMultiplyer - (Delta * (1 - MinAdsMultiplyer) / AdsTime), MinAdsMultiplyer, 1); } else { AdsMultiplyer = Clamp(AdsMultiplyer + (Delta * (1 - MinAdsMultiplyer) / AdsTime), MinAdsMultiplyer, 1); } Cam.Fov = Game.Fov * AdsMultiplyer; ApplyLookVertical(0); var ToRemove = new List <Hitscan.AdditiveRecoil>(); foreach (Hitscan.AdditiveRecoil Instance in ActiveAdditiveRecoil) { Instance.Life += Delta; if (Instance.Life > Instance.Length) { ToRemove.Add(Instance); } } foreach (Hitscan.AdditiveRecoil Instance in ToRemove) { ActiveAdditiveRecoil.Remove(Instance); } if (Inventory[InventorySlot] != null) { Items.ID Id = Inventory[InventorySlot].Id; ViewmodelItem.Mesh = Items.Meshes[Id]; ShaderMaterial Mat = new ShaderMaterial(); Mat.Shader = Items.TileShader; Mat.SetShaderParam("texture_albedo", Items.Textures[Id]); ViewmodelItem.MaterialOverride = Mat; ViewmodelItem.Show(); { Items.IdInfo Info = Items.IdInfos[Inventory[InventorySlot].Id]; if (IsPrimaryFiring && CurrentCooldown >= CurrentMaxCooldown && Info.UseDelegate != null && Info.FullAuto) { Items.UseItem(Inventory[InventorySlot], this); } } } else { ViewmodelItem.Hide(); } }
/// <summary> /// </summary> /// <param name="name"> /// </param> /// <param name="scene"> /// </param> public LinesMesh(string name, Scene scene) : base(name, scene) { this._colorShader = new ShaderMaterial( "colorShader", scene, "color", new ShaderMaterialOptions { attributes = new Array <string>("position"), uniforms = new Array <string>("worldViewProjection", "color") }); }
public override void DrawShadowVolume(BoundSphere Light, ShaderMaterial ShadowVolume) { if (RenderModel != null) { if (Light.Collide(RenderModel.BoundingSphere + UpdatedPosition)) { SetRenderModelData(); RenderModel.DrawShadowVolume(ShadowVolume); } } }
static void DrawPointLightMask(DynamicLight Light) { if (StencilMat == null) { StencilMat = new ShaderMaterial("nop", Engine.GetShader("nop")); } PreparePointLight(Light); Engine.PointLightMesh.Material = StencilMat; Engine.PointLightMesh.Draw(); }
// ================================================================ public override void _Ready() { if (!UseTitleScreen) { Player.EnableCamera(true); Controller.SceneGoto(StartScene); Player.Main.Position = StartPosition; } Shader = (ShaderMaterial)GetNode <CanvasLayer>("CanvasLayer").GetNode <ColorRect>("Shader").Material; }