Godot 4 Game Development Cookbook by Jeff Johnson

Godot 4 Game Development Cookbook by Jeff Johnson

Author:Jeff Johnson
Language: eng
Format: epub
Publisher: Packt Publishing Limited
Published: 2023-05-11T00:00:00+00:00


How it works…

We dragged the icon.svg file into the viewport. In the CanvasItem section of the Inspector, we left-clicked on Material and then on <empty> to the right of Material so that we could create a new shader material. We selected New ShaderMaterial from the drop-down list.

Then, we left-clicked on ShaderMaterial, which appeared in the place of <empty> to reveal its properties. We left-clicked on <empty> to the right of Shader and selected New Shader. We made sure that it was a visual shader and that it was a Canvas Item type—these should have been the default. In the Path field, we named the shader UVFunc.tres.

We clicked on UVFunc.tres, which is on the left of Shader in Material in the CanvasItem section of the Inspector. This shows the Shader Editor on the bottom panel under the viewport. We right-clicked in the Shader Editor to the left of the Output node. We selected the Texture2D node by searching for texture2d and selecting Texture2D under Textures | Functions and then left-clicking on the Create button.

In the Texture2D node, we clicked on Texture at the top and selected Texture2D from the drop-down list. Then, we left-clicked and dragged the dot on the right side of Color in the Texture2D node to the dot on the left of Color in the Output node.

We added the UVFunc node by right-clicking anywhere to the left of the Texture2D node and clicking Add Node in the popup. In the Search box, we typed uvf and clicked on UVFunction, located in Textures | Common. Then, we left-clicked on the Create button. We left-clicked on the dot on the right side of UV in the UVFunc node and dragged it to the dot to the left of UV in the Texture2D node.

In the UVFunc node, we changed the x and y values of Scale to .5 each and the x and y values of Offset to .25 each. We changed the Function values to Scaling and Panning to see how the icon.svg file changed. Change the values to something different to see what happens.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.