Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions rendering/mesh_texture_rd/2d_array_mesh.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[gd_resource type="ArrayMesh" format=3 uid="uid://j7duroqwmiuw"]

[resource]
_surfaces = [{
"2d": true,
"aabb": AABB(-64, -64, 0, 128, 128, 0),
"attribute_data": PackedByteArray(51, 51, 118, 63, 0, 0, 0, 0, 0, 0, 32, 61, 0, 0, 0, 0, 205, 204, 204, 58, 0, 0, 32, 61, 0, 0, 0, 0, 102, 102, 121, 63, 154, 153, 249, 60, 0, 0, 128, 63, 51, 51, 119, 63, 0, 0, 128, 63, 205, 204, 127, 63, 0, 0, 118, 63, 0, 0, 128, 63, 205, 204, 204, 60),
"format": 34393296913,
"index_count": 18,
"index_data": PackedByteArray(0, 0, 7, 0, 6, 0, 6, 0, 5, 0, 4, 0, 4, 0, 3, 0, 2, 0, 2, 0, 1, 0, 0, 0, 0, 0, 6, 0, 4, 0, 4, 0, 2, 0, 0, 0),
"primitive": 3,
"uv_scale": Vector4(0, 0, 0, 0),
"vertex_count": 8,
"vertex_data": PackedByteArray(102, 102, 108, 66, 0, 0, 128, 194, 0, 0, 108, 194, 0, 0, 128, 194, 51, 51, 127, 194, 0, 0, 108, 194, 0, 0, 128, 194, 204, 204, 114, 66, 102, 102, 112, 194, 0, 0, 128, 66, 102, 102, 110, 66, 0, 0, 128, 66, 154, 153, 127, 66, 0, 0, 108, 66, 0, 0, 128, 66, 51, 51, 115, 194)
}]
39 changes: 39 additions & 0 deletions rendering/mesh_texture_rd/3d.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[gd_scene load_steps=7 format=3 uid="uid://mx52oimcwqtn"]

[ext_resource type="Texture2D" uid="uid://bg8txxwsr4qn8" path="res://text_texture.tres" id="1_y2yqg"]

[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_y2yqg"]
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
ground_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)

[sub_resource type="Sky" id="Sky_fji6l"]
sky_material = SubResource("ProceduralSkyMaterial_y2yqg")

[sub_resource type="Environment" id="Environment_73ytm"]
background_mode = 2
sky = SubResource("Sky_fji6l")
tonemap_mode = 2
glow_enabled = true

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_y2yqg"]
transparency = 1
shading_mode = 0
albedo_texture = ExtResource("1_y2yqg")

[sub_resource type="BoxMesh" id="BoxMesh_p1i0w"]

[node name="3d" type="Node3D"]

[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_73ytm")

[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
shadow_enabled = true

[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
material_override = SubResource("StandardMaterial3D_y2yqg")
mesh = SubResource("BoxMesh_p1i0w")

[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(0.7071068, 0.5, -0.5, 0, 0.7071068, 0.70710677, 0.7071068, -0.5, 0.5, -1, 1, 1)
11 changes: 11 additions & 0 deletions rendering/mesh_texture_rd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Rasterize Mesh Texture

This is a demo showing how to set up a basic render pipeline to draw mesh to texture using RenderingDevice.

Language: GDScript

Renderer: Mobile

## Screenshots

![Screenshot](screenshots/rasterize_mesh_texture.webp)
29 changes: 29 additions & 0 deletions rendering/mesh_texture_rd/base_texture.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#[vertex]
#version 450

layout(location = 0) in vec3 position;
layout(location = 1) in vec2 uv;

layout(location = 0) out vec2 uv_interp;

layout(push_constant) uniform Data {
mat4 xform;
};

void main() {
uv_interp = uv;
gl_Position = xform * vec4(position, 1.0);
}

#[fragment]
#version 450

layout(location = 0) in vec2 uv_interp;

layout(location = 0) out vec4 frag_color;

layout(set = 0, binding = 0) uniform sampler2D tex;

void main() {
frag_color = texture(tex, uv_interp);
}
14 changes: 14 additions & 0 deletions rendering/mesh_texture_rd/base_texture.glsl.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[remap]

importer="glsl"
type="RDShaderFile"
uid="uid://bsbaafha2qt2x"
path="res://.godot/imported/base_texture.glsl-7668889287fcd72a7484b036a760efd0.res"

[deps]

source_file="res://base_texture.glsl"
dest_files=["res://.godot/imported/base_texture.glsl-7668889287fcd72a7484b036a760efd0.res"]

[params]

1 change: 1 addition & 0 deletions rendering/mesh_texture_rd/godot_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions rendering/mesh_texture_rd/godot_icon.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://crm65s53yy1n6"
path="res://.godot/imported/godot_icon.svg-7b3f4db08ef4bccb8acaa5db9e9fe760.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://godot_icon.svg"
dest_files=["res://.godot/imported/godot_icon.svg-7b3f4db08ef4bccb8acaa5db9e9fe760.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
process/resolution_scale=1.0
detect_3d/compress_to=0
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
Binary file added rendering/mesh_texture_rd/icon.webp
Binary file not shown.
37 changes: 37 additions & 0 deletions rendering/mesh_texture_rd/icon.webp.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://b1ukde136ayme"
path="res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.webp"
dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
process/resolution_scale=1.0
detect_3d/compress_to=0
68 changes: 68 additions & 0 deletions rendering/mesh_texture_rd/main.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[gd_scene load_steps=14 format=3 uid="uid://cnk1inmvelj4x"]

[ext_resource type="Texture2D" uid="uid://crm65s53yy1n6" path="res://godot_icon.svg" id="1_7mycd"]
[ext_resource type="RDShaderFile" uid="uid://bsbaafha2qt2x" path="res://base_texture.glsl" id="2_7mycd"]
[ext_resource type="Script" uid="uid://cdfq6x7v36k1e" path="res://mesh_texture_rd.gd" id="3_5vw27"]
[ext_resource type="ArrayMesh" uid="uid://j7duroqwmiuw" path="res://2d_array_mesh.tres" id="4_1bvp3"]
[ext_resource type="Texture2D" uid="uid://bg8txxwsr4qn8" path="res://text_texture.tres" id="4_lquwl"]
[ext_resource type="PackedScene" uid="uid://mx52oimcwqtn" path="res://3d.tscn" id="6_7mycd"]

[sub_resource type="PrismMesh" id="PrismMesh_kek77"]

[sub_resource type="Texture2DRD" id="Texture2DRD_5vw27"]
script = ExtResource("3_5vw27")
clear_color = Color(0.412266, 0.447241, 0.735728, 1)
mesh = SubResource("PrismMesh_kek77")
base_texture = ExtResource("1_7mycd")
projection = Projection(-0.6, -1.3, 0, 0, 1.1, -1.67, 0, 0, -0.76, 0, -1.2, 0, 0, -0.26, 0, 1.36)

[sub_resource type="TorusMesh" id="TorusMesh_lquwl"]

[sub_resource type="Texture2DRD" id="Texture2DRD_7mycd"]
script = ExtResource("3_5vw27")
clear_color = Color(0.271125, 0.510188, 0.620698, 1)
mesh = SubResource("TorusMesh_lquwl")
base_texture = ExtResource("1_7mycd")
projection = Projection(-0.7, -0.92, 0.5, 0, 0.25, -1.5, 0.32, 0, 1.43, -0.14, 0.48, 0.14, 0.1, 0.02, 0.75, 1.85)
metadata/_custom_type_script = "uid://delyovxoqvijt"

[sub_resource type="QuadMesh" id="QuadMesh_1bvp3"]

[sub_resource type="Texture2DRD" id="Texture2DRD_lquwl"]
script = ExtResource("3_5vw27")
clear_color = Color(0.572798, 0.384286, 0.683792, 0.337255)
mesh = SubResource("QuadMesh_1bvp3")
base_texture = ExtResource("1_7mycd")
projection = Projection(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
metadata/_custom_type_script = "uid://delyovxoqvijt"

[sub_resource type="Texture2DRD" id="Texture2DRD_272bh"]
script = ExtResource("3_5vw27")
mesh = ExtResource("4_1bvp3")
base_texture = ExtResource("1_7mycd")
projection = Projection(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 100)
metadata/_custom_type_script = "uid://cdfq6x7v36k1e"

[node name="Node2D" type="Node2D"]

[node name="Prism" type="Sprite2D" parent="."]
position = Vector2(573, 321)
texture = SubResource("Texture2DRD_5vw27")

[node name="Torus" type="Sprite2D" parent="."]
position = Vector2(898, 319)
texture = SubResource("Texture2DRD_7mycd")

[node name="Quad" type="Sprite2D" parent="."]
position = Vector2(252, 321)
texture = SubResource("Texture2DRD_lquwl")

[node name="Text" type="Sprite2D" parent="."]
position = Vector2(293, 89)
texture = ExtResource("4_lquwl")

[node name="3d" parent="." instance=ExtResource("6_7mycd")]

[node name="2DMesh" type="Sprite2D" parent="."]
position = Vector2(244, 797)
texture = SubResource("Texture2DRD_272bh")
Loading
Loading