#Transparency Problem With Viewport Texture

1 messages · Page 1 of 1 (latest)

surreal dagger
#

Hello everyone, I want to make the output of a script attached to my control node visible without any background, however I get the clear color as the background. The control node is the child of a subviewport and I use the subviewport texture to render the output to a plane. I've already tried the flag "transparent bg" in the subviewport but it renders completely black if I do that. Does anyone have any ideas on how to fix this?

river timber
#

Maybe change this

#

Clear color

#

To be transparent

surreal dagger
#

Thanks I'll try that but I thought that there would be an alternative way to control the background from the nodes in the scene

river timber
#

You`re welcome

surreal dagger
#

when I tried this it still shows the color instead of being transparent unfortunately

river timber
#

Can you please show me a screenshot of the issue

surreal dagger
#

right now it's showing this but I want to only show the graph and make the background transparent

#

the graph is the output of a script attached to the control node

river timber
#

So the part that`s grey, its supposed to be transparent in that part?

surreal dagger
#

yes

river timber
#

So you would see your desktop through the program

#

?

surreal dagger
#

so that it looks like the graph is floating in 3d space

river timber
#
surreal dagger
#

I appreciate the help a lot but I don't think that's what I'm looking for. Here is the full picture of how it looks in game right now. I would like to make the grey part transparent to get the float effect but not actually make what I'm doing in the computer outside of the game visible

river timber
#

Ohhhh

#

What object has the graph on it

#

Like what is it called

surreal dagger
#

the control node

#

called control in the screenshot

river timber
#

Maybe try looking in the inspector

#

For a transparency setting

surreal dagger
#

yes I tried that I enabled transparent background here in the viewport

river timber
#

No, on the control node

surreal dagger
#

I'm sorry but I don't see the setting here

river timber
#

Wait, no, on the mesh

#

The mesh is the grey block right?

#

With the graph on it

surreal dagger
#

the mesh has the viewport texture yes

river timber
#

Try looking for a transparency setting there

surreal dagger
#

hmmm there is a transparency setting but when I turn it completely to 1 it's invisible

river timber
#

So if you put the transparenncy to 1 the graph dissapears too?

surreal dagger
#

I can't see the background or the graph

#

yes

river timber
#

Alright

#

Does the graph texture have a grey background?

#

Like, in the part of the editor that says filesystem

#

Bottom left by default

surreal dagger
#

I don't save the graph as a texture it's calculated when I hit play

#

and it's drawn with the draw function

#

it's supposed to continually change in the game

river timber
#

I think that the graph might be inheriting the transparency of the mesh

#

Is the thing being drawn on the mesg

#

Is the graph drawn on the mesh

surreal dagger
#

you can have the full script here:

extends Control

var num_nodes: int = 5 # Default number of nodes
var node_positions: Array = []
var connections: Array = []

func _ready():
_generate_graph()
queue_redraw() # Request a redraw

func _generate_graph():
# Generate positions for nodes in a circle layout
node_positions.clear()
connections.clear()
var radius = min(size.x, size.y) * 0.4 # Adjust as needed
var center = Vector2(size.x / 2, size.y / 2)
for i in range(num_nodes):
var angle = i * TAU / num_nodes
var position = center + Vector2(cos(angle), sin(angle)) * radius
node_positions.append(position)
# Generate connections (edges) between nodes (e.g., connecting each node to the next)
for i in range(num_nodes):
connections.append([i, (i + 1) % num_nodes]) # Creates a circular graph

func _draw():
# Draw connections
for conn in connections:
var from_pos = node_positions[conn[0]]
var to_pos = node_positions[conn[1]]
draw_line(from_pos, to_pos, Color.BLACK, 2)
# Draw nodes
for pos in node_positions:
draw_circle(pos, 10, Color.BLACK)

func set_num_nodes(n):
num_nodes = n
_generate_graph()
queue_redraw()

#

it's not drawn on the mesh it's attached to the control node

river timber
#

I think that because the mesh is transparent, it makes the subViewport inherit that, and then its passed down to the Control, making the graph invisible

#

Do you see any things on the control node about visibility?

surreal dagger
#

these are the settings I see

#

I've just tried using top level and transparent bg in wiewport together I got my hopes up but it didn't work...

river timber
#

Maybe put show behind parent on the mesh

#

Wait, why does the mesh even exist

#

Isnt that what`s making the grey square

surreal dagger
#

the mesh is supposed to display the viewport texture

#

the albedo is set to viewport texture

#

the mesh is the default godot plane and it's supposed to be white by default

#

so my guess is that it's the viewport

river timber
#

What happens if you make the subviewport a child of the node3d and remove the mesh

surreal dagger
#

let's see

#

it disappears

river timber
#

What if you make the control a child of the node3d and get rid of the subviewport

surreal dagger
#

but the way it's being rendered in the mesh is as a subviewporttexture here

river timber
#

Wait

#

Cant you just make that material transparent

#

Texture

#

Whatever

surreal dagger
#

yes but then the graph can't appear

river timber
#

No like the texture

#

It looks grey

#

Cant you make that texture transparent

surreal dagger
#

it looks grey but the only thing I can do is set the subviewport node there