godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.15k stars 21.19k forks source link

Ability to set a mirrored repeat texture flag on viewportSprite node #15329

Closed blurymind closed 6 years ago

blurymind commented 6 years ago

This will allow us to make a wraparound viewport, where the player can wraparound a single screen

On a texture of a sprite node one can set this by: 1 Add Sprite 2 Load texture 3 Check Region on 4 set Region Rect (0,0,640,480) 5 Edit texture 6 Check Repeat on ImageTexture Flags.

I was actually wondering whats the simplest way to do it in other ways, but the paralax layers seem to not work for a player moving around a stationary screen

blurymind commented 6 years ago

looking into doing it with parallax layer instead, I found out that it has a limitation that prevents complete tiling on non-moving screen with sprites moving inside it: https://github.com/godotengine/godot/issues/15359

It only tiles partially, its not very good for games where the camera doesn't move, but you need the screen to wraparound. Classic examples can be found in many arcade games, such as pacman, some of the first mario arcades, https://youtu.be/j4lKDTgifl8?t=52s

See this article for a better description: https://en.wikipedia.org/wiki/Wraparound_(video_games)

We can't easily achieve it in godot at the moment. In my case I can't do it via teleporting because it looks ugly - especially on bigger sprites to disappear and reappear. I also want to use it for a tiling texture editor I am making in godot, so that absolutely needs to show both halves of the sprite on two ends of the screen

mrcdk commented 6 years ago

how do you intend to do a wraparound with a repeated texture? if your viewport texture is 640x480 and your sprite is at (700,200) no matter how your texture is set, mirroring or not, the sprite won't be shown because the texture will only render the stuff inside the 640x480

This is what the repeat flag means in a texture: https://open.gl/media/img/c3_clamping.png

  1. Repeat enabled.
  2. Repeat mirror.
  3. Repeat disabled.
  4. AFAIK it's not supported in Godot.
blurymind commented 6 years ago

I've been scratching my head over this for quite a while- do you think its possible to do via a screen shader? I cant get it to work so far :((

@reduz suggested that it would need a new type of a node in https://github.com/godotengine/godot/issues/15359 (approach2 of the problem)

blurymind commented 6 years ago

I am going to close this request because having investigated it more, it seems like a bad approach to the problem. Sorry for wasting anyone's time @mrcdk is correct- things get cropped out. I actually did it with a screen shader and even tried with queue_screenshot and update

ariahiro64 commented 3 months ago

im a 3d artist that is porting my hombrew to pc but because features like this are missing are in every other engine its not a simple matter of resetting up materials and import. these features can save memory and be use creatively to reduce texture size and im very dissapointed if i use this i have to remake practically every single model.. from an n64 game... that vulkan and opengl supports this.... i used these features that are in unity and unreal. i also dont want to use a game engine with those licenses. im in a bind.