Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the viewport_path of the ViewportTexture in a material renders it white #77207

Closed
Rindbee opened this issue May 18, 2023 · 0 comments · Fixed by #77209
Closed

Changing the viewport_path of the ViewportTexture in a material renders it white #77207

Rindbee opened this issue May 18, 2023 · 0 comments · Fixed by #77209

Comments

@Rindbee
Copy link
Contributor

Rindbee commented May 18, 2023

Godot version

v4.1.dev.custom_build [18112ba]

System information

Linux Mint 21.1, NVIDIA GeForce GTX 1050 Ti, Vulkan API 1.3.205

Issue description

This is a regression from #64388.

Textures seem to be used differently in 2D and 3D. They are rendered using the RID in 3D, and changing the viewport_path will cause the RID to change.

1.mp4

Steps to reproduce

  1. Download and import MRP.
  2. Open 1.tscn, and try to switch the viewport_path of the MeshInstance3D:mesh:material:albedo_texture in the MeshInstance3D node.
  3. After switching, the MeshInstance3D is rendered as white in the editor;
  4. Close and then reopen 1.tscn.

Minimal reproduction project

ViewportTexture-change-viewport_path.zip

@YuriSizov YuriSizov added this to the 4.1 milestone May 18, 2023
Poobslag added a commit to Poobslag/turbofat that referenced this issue Jun 6, 2023
Playfield still appears a little strange in the editor, and various
ViewportTextures are visible in the editor even though their
corresponding viewports are empty. This seems related to Godot #77207.

godotengine/godot#77207
Poobslag added a commit to Poobslag/turbofat that referenced this issue Jun 14, 2023
Playfield still appears a little strange in the editor, and various
ViewportTextures are visible in the editor even though their
corresponding viewports are empty. This seems related to Godot #77207.

godotengine/godot#77207
Poobslag added a commit to Poobslag/turbofat that referenced this issue Jun 21, 2023
Added project/.godot to .gitignore

Fixed compilation errors introduced by the automated tool, such as
nonsensical 'super' calls, 'PackedStringArray' references, local
variable renames like 'bbcode_text'.

Fixed untyped export annotations

Fixed enums typed as ints. Godot 4 introduces an enum type, and enums
and ints are no longer interchangeable.

TileMap.clear() overrode a parent function, result in an error in Godot
4. Its functionality of updating the corner map has been extracted into
TileMap.refresh().

Updated 'a := max(b, c)' calls to explicitly specify float type. This
avoids a Godot 4 error, 'The variable type is being inferred from
a Variant value, so it will be typed as Variant. (Warning treated as
error.)'

Removed non-static JSON, File, DirAccess calls. The conversion tool uses
a verbose syntax for parsing JSON, but there are simple static method
calls which suffice.

Fixed signal/method/field name conflicts. Godot 3.x let you have signals
with the same names as fields, but Godot 4.x is more strict. Some
signals like 'show' and 'hide' were renamed to 'shown' and 'hidden';
other fields like 'finish_triggered' were renamed to an absurdly verbose
and confusing 'finish_trigger_emitted', which I hope to fix on
refactoring day if I can think of a better name.

Godot 4 returns errors if you have methods like 'show()' with the same
name as signals like 'show'. While Godot 4 is inconsistent about its
naming, only a few places use present tense signals like 'Popup.popup_hide' and
most scripts use past tense signals like 'CanvasItem.hidden'.

Fixed overridden/redefined methods and fields. Some methods such as 'play',
'stop', 'show', 'hide' and 'grab_focus' were overridden deliberately, but we now
achieve this functionality differently. Other fields like 'PI' and 'TAU' were
overridden by accident, because those fields didn't exist in Godot 3.x.

Fixed code which executed boolean logic using strings, arrays,
dictionaries, etc. I fixed some of these before the Godot 4.x upgrade,
but there were still many remaining.

Updated draw_polygon calls. Polygon antialiasing is disabled; this used to be
specified as a parameter to draw_colored_polygon but 'Normal maps are now
specified as part of the CanvasTexture rather than specifying them on the
Canvasitem itself' godotengine/godot#59683

Updated TileMap API references. Some methods like TileMap.get_cellv and
TileMap.get_cell_autotile_coord have Godot 4 replacements, others kept
the same name but introduced a new 'layer' parameter. Replaced Vector2/Rect2
references with Vector2i/Rect2i where appropriate

Various Godot 4 API renames: scancode -> keycode, pressed -> button_pressed,
constant -> theme_constant, autowrap -> autowrap_mode, Array.remove ->
remove_at, Array.invert -> reverse, FuncRef -> Callable,
OS.has_touchscreen_ui_hint -> DisplayServer.is_touchscreen_available,
update -> queue_redraw

Updated signal.connect(), signal.disconnect(), signal.is_connected() calls. The
automated process changed a lot of these but changed them in an unnecessarily
verbose way. I shortened them using nicer syntax, and fixed the ones it didn't
touch.

Compilation errors for tests

Updated Array.slice() calls.

Array.slice is now exclusive, not inclusive.

idle_frame -> process_frame

All tests pass. argb -> rgba; Joystick button mapping.

Replaced ARGB colors with RGBA; Godot 4.0 uses RGBA strings instead of Godot
3.x's ARGB.

Fixed KeybindManager's joystick button mapping. The old
get_joy_button_mapping() method returned an incredibly verbose and
unhelpful string, so I created a lookup table adapted from Godot 3.x.

Changed 'DPAD' references to 'D-Pad'. Despite Godot 3.x returning 'DPAD'
from its 'get_joy_button_string' method, I couldn't find it in its
source code, and Godot 4.x calls it a 'D-Pad' as well.

ReleaseToolkit fixes; stretch, theme, autowrap, align

Updated window stretch mode to 'canvas_items'

Added default font sizes to .theme files.

Fixed ReleaseToolkit's output label settings: autowrap_mode,
horizontal_alignment

Globally fixed align, valign, autowrap properties

'loop' -> 'loop_mode'

Updated 'extract keycode strings' logic

The keycode ranges for keys like 'Escape' and 'Tab' changed in Godot 4.
Additionally, Godot now logs a console error if you call
get_keycode_string with an invalid keycode, so I've created a skip list

scancodes -> keycodes

Godot 4 seems to have replaced the 'scancode' terminology with
'keycode', so I'm following their example. A player on an AZERTY
keyboard doesn't care that they pressed the key corresponding to the 'Q' key's
position, they care that they pressed the 'A' key.

Replaced #warning-ignore comments with annotations

Removed Utils.randi_range(); randi_range() is now a native function

Resolved some 'int instead of enum' warnings

Added Creatures.Orientation.NONE; some code was assigning orientation enums a
value of '-1' but there was no way to represent that state with an enum.

Minor comment delinting

Parameters

Resolving warnings

Added workarounds for static method calls. Self static method calls are
discouraged in Godot 4.x and result in a warning, due to Godot #69282
(godotengine/godot#69282)

There are many workarounds to avoid these warnings, but they all carry
severe drawbacks. Suppressing the warnings is the most sensible option,
but results in 300% more source code - transforming formerly readable
code into bloated festering piles of unnecessary comments and annotations. (See
test-level-history.gd for the most egregious example.) Prefixing the
static method calls is another option, but is gross for unnamed scripts,
and impossible for autoload singletons.

shader_param -> shader_parameter

Resolved all warnings from running unit tests.

Fixed anti-aliasing for landmark lines

Re-saved fonts/themes to avoid warnings.

Updated FontFitLabel references to use font_sizes property

Split up fonts and sizes. Created FontFitButtonDemo.

Created FontFitButtonDemo.

Scenes no longer use sized fonts like 'blogger-sans-bold-18.tres', but
instead use a regular font like 'blogger-sans-bold' with a font size
like '18'.

Removed redundant sized font files

Font files no longer store information on sizes.

Disabled @tool scripts.

I'm encountering crashes opening complex scenes like Puzzle.tscn and
PuzzleTileMap.tscn -- while I know the tilemaps are a mess, I also think
these kinds of tool scripts could be causing problems.

Disabled blend file import to avoid warning

Fixed invalid atlas size in PuzzleTileMap.tscn

Started rewriting puzzle tileset from scratch

NightPuzzleMap atlas, add_sibling

Updated NightPuzzleMap atlas texture sizes to fix out of bounds errors.

Fixed errant 'add_sibling' call.

Fixed bad atlas data for night playfield

Resolve some warnings/errors related to puzzles

Increased size of 'empty-8' resource.

Puzzle.tscn errors. Puzzle.tscn no longer crashes.

Puzzle scene no longer crashes editor.

Fixed FryingPansUi

icon-outline.shader now includes a modulate property. In Godot 4.x,
shaders no longer apply the 'modulate' property so we need to implement it
ourselves.

Experimenting with PlayfieldDemo

rv

PlayfieldDemo doesn't crash on startup

Recreating PuzzleTileMap from scratch

Godot's tilemap converter created literally thousands of 'Tile
Alternatives' for each tilemap. This results in .tscn files which, if
saved, balloon from ~5 kb to ~5 mb. The Godot editor can technically
open them, but there is no way to remove the Tile Alternatives except
right clicking each one.

Compatibility renderer.

Workaround for Godot #71350. The Vulkan rendering backends are complex and require a long time to start (about 10 seconds). The resulting graphical enhancements are worth it, but during development I prefer the faster loading times of the Compatibility renderer.

godotengine/godot#71350

Created alternative-tile-remover.gd EditorScript

alternative-tile-remover.gd works around a peculiarity of the Godot 4
upgrade process where it assumes all tilesets are 16x16, and then
creates a set of 8 tile alternatives for each tile. This means a
5000x5000 texture will have 780,000 (!) tile alternatives defined.

Experimenting with EditorScript

Experimented with making all tilesets 16x16 pixels

Restored TileMap cell sizes, atlas regions

Removed 'OldPuzzleTileSet' stuff. Removed next_alternative_id

I originally branched 'OldPuzzleTileSet' thinking I'd need to rewrite
the TileMaps and TileSets from scratch because they were crashing Godot,
but I found a better workaround.

Removed unnecessary 'next_alternative_id' properties.

Fixed PuzzleTileSet tile size

todo

Fixed playfield shadow positioning

Unset 'flip_v' for viewport textures

Something changed between Godot 3 and Godot 4 where flip_v is no longer
important.

Experimenting with PlayfieldFx alternative tiles

create_alternative_tile is having seemingly no effect

Added alternative tile tool script

This script proves that our approach to creating alternative tiles
works; something else is wrong

Fixed playfield lights not appearing.

Colors no longer function for dictionary indexes, so I'm now indexing
the dictionary by the color's hex representation

Regular playfield fx lights work, rainbow lights don't

removed next_alternative_id

cleanup/delint

PlayfieldDemo mostly works.

Playfield still appears a little strange in the editor, and various
ViewportTextures are visible in the editor even though their
corresponding viewports are empty. This seems related to Godot #77207.

godotengine/godot#77207

Fixed chalkboard stretching

Fixed ProgressBoardDemo, ProgressBoardTrailDemo

Particles lost a lot of important properties, including their initial
velocity and scale. "Baked point" calculations no longer work the same
way, because baked points are not equidistant.

Globally fixed Particles2D properties: initial_velocity, scale

Replaced 'initial_velocity', 'initial_velocity_random' with
'initial_velocity_min', 'initial_velocity_max'. Replaced 'scale',
'scale_random' with 'scale_min', 'scale_max'.

Globally fixed tilemap method references.

get_cellv -> get_cell_source_id
get_cell -> get_cell_source_id
cell_size -> tile_set.tile_size
clear -> clear_layer
set_cell calls must include fourth parameter 'Vector2.ZERO'
tile_set.tile_get_texture(id) -> tile_set.get_source(id).texture
tile_set.tile_get_material(id) -> tile_set.get_source(id).get_tile_data(Vector2i.ZERO, 0).material

Fixed ChatFrameDemo.

Fixed ChatFrame layout; restored anchors.

RectFitLabel's get_height() call was not passing in the font height, so
it was getting back an incorrect result.

Enabled 'repeat_enable' for chat shader texture.

Updated 'visible_characters_behavior' to 'characters_after_shaping' to
allow RectFitLabel's get_line_count() to return an accurate count and
reshape itself.

Globally tweaked 'visible_characters_behavior', 'repeat_enable'

Enabled VisibleCharactersBehavior -> VC_CHARS_AFTER_SHAPING for labels
which respond to line count.

Added repeat_enable flag for textures which need it.

Fixed rect_rotation math. Removed Godot #21789 workaround.

The Godot 4 upgrade process replaces 'rect_rotation' with 'rotation',
but rect_rotation is in degrees and rotation is in radians, and the
upgrader does not convert them. I've converted the values.

Removed Godot #21789 workaround to force 'get_class' to return a
specific value. This was implemented because 'if (field is MyClass)' did not
work in Godot 3, but it works in Godot 4 so the workaround is not
necessary.

Investigating buggy input

Scancode fixes. InputMapDemo improvements.

Converted stored scancodes from Godot 3 scancodes like '16777231' to
Godot 4 scancodes like '4194319'.

Experimenting with ChatChoices

Added debug stufff to chat choices

Improved 'swallow chat input' code

In Godot 4, the signal order appears to have changed. The old code to
swallow the player's input during chat prompts was also preventing chat
prompts from being selected at all -- the button wasn't even being pressed.

Starting to fix creatures, moods

Fixed creature 'tool scripts'

DnaLoader.load_dna() seems to work? maybe?

Prevent more CreatureVisuals warnings/errors

Fixed DNA not being unloaded

rotation_degrees, process_mode

Changed rotation_degrees to rotation. Godot's AnimationPlayer will still
animate a 'rotation_degrees' property but just treats it as radians, so all
objects rotate about 60x further than they're supposed to. I've manually
(ugh) converted all degree values to radians.

Updated process_mode=2 to process_mode=3. Godot 3 did not have
process_mode but had pause_mode, but Godot 4 converts this value
incorrectly: process_mode=2 is not 'always process', it is 'process when
paused'

Fixed stream ids

Fixed cubic interpolation glitch with animations

Godot 4 changed how cubic interpolation works; for values like [0, 16,
12] the interpolation used to gradually shift the value from 0 to 16 and
back down to 12. In Godot 4, it now swings the value radically from 0 to
40, and then back down to 12. I worked around this bug by adding a
second redundant point along the curve. It still doesn't look identical
to Godot 3, but it looks similar.

Fixed MusicPlayerDemo

Restored creature limbs moving as they fatten

The 'fat players' in Godot 3 used to preserve sprite positions even when
stop() was called, but in Godot 4 the sprite positions are reset unless
we explicitly call 'stop(true)' which preserves them.

Restored default creature visuals.

Without these creature visuals, MoodDemo looks really strange when it
first pops up.

Restored 'y_sort_enabled'. Updated RichTextLabel clear fix.

Enabled 'y_sort_enabled' property for YSort nodes from Godot 3.5.

Updated RichTextLabel clear fix -- updating the 'text' field to empty
clears the tag stack.

edit creature off

Fixed carrot particle effects.

Global particle fixes: disable_z, color_ramp, etc

The initial_velocity and scale properties had already been updated, but
I updated the remaining properties:
  flag_disable_z -> particle_flag_disable_z
  orbit_velocity -> orbit_velocity_min/max
  anim_offset -> anim_offset_min/max
  mission_shape = 2 -> 3 (box)
  angle -> angle_min/max
  damping -> damping_min_max

Additionally, particle gradients have changed from 'GradientTexture2D'
to 'GradientTexture1D'.

I restored some missing particle properties for scenes such as
NightPlayfield, CreatureVisuals and PieceManager. Godot 4 removed these
particle properties automatically upon saving the scene for the first
time.

CHanged onion reset to 'discrete'

Changed Onion AnimationPlayer's blend modes to 'discrete' to avoid a
warning, 'Value track: Onion:frame with different update modes are
blended. Blending prioritizes Discrete mode, so other update mode tracks
will not be blended. (User)'

Onion state machine advance_mode.

Updated onion state machine 'advance_mode' to auto. Godot 3 defaults to
auto, but Godot 4 defaults to 'enabled' which prevents the state machine
from doing everything. (Not sure why they did this.)

Fixed PuzzleTileMap corners. Fixed shark warnings.

PuzzleTileMap corners were using the wrong tile size.

Removed unused puzzle-corner-tile-set-g4.tres.

Fixed 'shadowed field name' warning.

Fixed LevelRankDemo appearance, signals

FileDialog, AcceptDialog are no longer controls, and instead have a
'size' attribute. I've set the size to be sensible.

Dialogs no longer include a 'popup_hide' signal and there is seemingly
no replacement. I've added a PopupHideSignalEmitter node which hooks
into 'visibility_changed'.

Dialog sizes, modes.

In Godot 3, dialogs were Controls and used a layout manager. In Godot 4,
dialogs must have their size set explicitly.

Applied 'popup_hide' kludge throughout project

Refactored 'internal field' workaround

Unlike setget in previous Godot versions, the properties setter and getter are
always called, even when accessed inside the same class (with or without
prefixing with self.). This makes the behavior consistent. Godot's official
guidance is to use another variable for direct access and make the property
code use that name.

We now override the getters to return the internal value as well. This
avoids an edge case where the internal value was set, but the external
value still returned the old value.

Fixed some warnings from PuzzleCritterDemo

Fixed crashes when launching PuzzleCritterDemo

PuzzleCritterDemo warnings/errors. Locales.

Updated MilestoneHud ProgressBar styles for Godot 4.

Fixed compile errors in food-items.gd

Removed unused field from overworld-exit.gd.

Added missing 'en' 'es' locales to project settings.

Cosmetic SettingsMenu changes

Overrode default 'line_spacing' value for labels. This was making the
volume sliders taller than they used to be and making the UI less
efficient where fewer rows were visible.

Fixed 'delete save slot' button to be square again.

Dialog backdrops, confirm close buttons

Fixed dialog backdrops; with Godot 4's anchor changes, these backdrops
were all zero size in the upper left corner. They're now fullscreen
again.

Restored close button events for confirm dialogs. There is no longer a
`get_close_button` method and signals are instead added to the `close`
event.

Added missing super() calls.

Godot 3 automatically called native parent methods such as _ready() and
_physics_process() but Godot 4 does not. I've added these explicit
parent method calls. I think these are only necessary when extending
custom types such as 'RectFitLabel' and 'OverworldObstacle', not
built-in types such as 'AnimationPlayer'

Fixed ProgressBars.

show_as_percent -> show_percentage, custom_styles/fg ->
theme_override_styles/fill, custom_styles/bg ->
theme_override_styles/background

Creature orientations. Removed super(). Puzzle UI.

Updated creature orientations; .tscn files do not use the constants
defined in 'creatures.gd' so they were all off by one.

Removed unnecessary 'super()' calls; calling 'super()' when no parent
method is defined results in an error.

Updated label spacing for labels in Puzzle.gd.

Updated settings menu close button size.

Unset stretch_shrink, replaced Light2D masks

Unset 'stretch_shrink' mode for RestaurantView, this was making the
camera very very zoomed out.

Replaced Light2Ds using clip mode with Sprite2Ds using clip_children.
Godot 4 removed the 'clip mode' for Light2D.

Camera3D -> Camera2D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants