The article is relevant to my last post, Godot: Texture, Grid Map, Move And Rotate.
I want to create a 3D game by Godot, here are some notes about it.
All files in the project are uploaded to GitHub:

Add Music And Play

Create a new node container to manage all audio streams.
Add an AudioStreamPlayer3D child node, load ogg file for its Stream. Adjust the parameters Unit Size and Max Db to get a better sound effect.

Add a test key and play our audio by it.

add key

Add playing code.

func _physics_process( delta ):
     if Input.is_action_pressed("test_key"):
        var player:AudioStreamPlayer3D = musicContainer.get_node( "explose" ).d
uplicate() = = false
        player.global_transform.origin = $player/Camera.global_transform.origin
        $"/root".add_child( player )

Put Camera’s View To A Mesh’s Surface

Create a MeshInstance and generate a cube as mesh object. Add Viewport and its child node, the new Viewport object has its child node which is a Camera object.
We mark the flag Current of the camera true to use the camera in the ancestor viewport.

Then we need to create a shader material for our wall. Material – Create ShaderMaterial – click shader and edit, add the following code for the it.

shader_type spatial;
render_mode unshaded;

uniform sampler2D refl_tx;
void fragment(){
    ALBEDO = texture( refl_tx, vec2(1.0 - SCREEN_UV.x, SCREEN_UV.y) ).rgb;

Finally, make sure the resource local to scene and create a new viewport texture which connects child node Viewport for Refl tx.

Categories: Godot

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments

Content Summary
: Input your strings, the tool can get a brief summary of the content for you.

Would love your thoughts, please comment.x