Help with Draw.Texture examples

Avatar
  • updated

I'm unclear about how to use Draw.Texture.  I'd like to array the same texture (or tile) to create a specific line type.


This Renders 1 Texture :

Sprite sprite = Resources.Load(spritePath) as Sprite;
Draw.Texture(sprite.texture, new Vector2(1, 1), .25f);


This Renders Nothing :


Draw.Texture(sprite.texture, new Vector2(1, 1), .25f);
Draw.Texture(sprite.texture, new Vector2(2, 2), .25f);


This Also Renders Nothing:


 for (int i = 0; i < 10; i++)
{
   Sprite sprite = Resources.Load(spritePath) as Sprite;
   Draw.Texture(sprite.texture, new Vector2((float)i, 1), .25f);
}


I saw a post about using the Rect overload for setting uvs, but haven't had any luck on my own.  Any help would be greatly appreciated.

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Freya Holmér creator

what's the surrounding context? did you set up the draw command properly, and are you calling it in a valid part of the render pipeline?

There's lots of info on that in the docs on immediate mode. You'll also need to have [ExecuteAlways] if you expect it to show up without hitting play.

also make sure the texture isn't null.

if all else fails, it's possible the shader cache might be broken, and you'll have to do a clean reinstall: https://shapes.userecho.com/knowledge-bases/2/articles/290-how-to-do-a-clean-reinstall-of-shapes

Avatar
trevor gronseth

Context : I've been using Shapes for a few weeks (to draw lines) and everything works great.  This is my first attempt at textures.  I'm exclusively using Immediate Mode.

This achieved what I was attempting to do (my Sprite wrap mode is set to Repeat): 

Draw.Texture(sprite.texture, new Rect(0, 0, 10, 1), new Rect(0, 0, 10, 1));

Image 790

I guess my only question is this:  If I call the above line 2 times in a row, nothing gets rendered.  Do I need to clear anything or is it a bug?

Avatar
Freya Holmér creator
Quote from trevor gronseth

Context : I've been using Shapes for a few weeks (to draw lines) and everything works great.  This is my first attempt at textures.  I'm exclusively using Immediate Mode.

This achieved what I was attempting to do (my Sprite wrap mode is set to Repeat): 

Draw.Texture(sprite.texture, new Rect(0, 0, 10, 1), new Rect(0, 0, 10, 1));

Image 790

I guess my only question is this:  If I call the above line 2 times in a row, nothing gets rendered.  Do I need to clear anything or is it a bug?

when multiple calls go invisible, that's usually a sign of broken instancing. Make sure you've got the latest version, I recall fixing something related to this. This is also usually fixed by a clean reinstall!

Avatar
trevor gronseth

I've only just started using it, so I should be current (4.3.1).  Do you want me to report this as a bug?

Avatar
Freya Holmér creator
Quote from trevor gronseth

I've only just started using it, so I should be current (4.3.1).  Do you want me to report this as a bug?

try this first:

https://shapes.userecho.com/knowledge-bases/2/articles/290-how-to-do-a-clean-reinstall-of-shapes

if that doesn't work, report a bug yeah!


Avatar
Trevor G

Freya,  


It looks like the problem was related to GPU instancing.  If I disabled that, then it rendered the textures as expected.  Here's the strange part (and I'll post this over in the Render On Build mega-thread)...If I changed the "Quad Interpolation Quality" setting from MEDIUM to LOW, then the textures work with or without GPU instancing on.