Sign in to follow this  
photo

[SOLVED] Sprite - setLayerTexCoord

Recommended Posts

Hey Unigine,

 

setLayerTexCoord isn't working with X and Y as 0 / 0

 

if you set now:

mysprite.setTexCoord(vec4(0.0f,0.0f,(engine.app.getWidth() / statusBarLayerSprite.getWidth()) +2,45.0f));

 

The sprites aren't rendered at all.

 

In attachment the example.

 

Greetings

Lars

roastatus.rar

Share this post


Link to post

x, y is tex coord scale

z, w is tex coord offset

Share this post


Link to post

Hello Frustum,

thanks for the help.
Now it make sense why the behavior was such strange.

I think the documentation needs an update:

"vec4 texcoord - Texture coordinates. The first pair of coordinates (x and y) is for the upper left corner, the second pair (z and w) is for the lower right corner."

Thanks

Share this post


Link to post

Sorry, the documentation was right.

The default texture coordinates are 0, 0, 1, 1.

The first pair is upper left. The second pair is lower right corner.

Share this post


Link to post

Hey Frustrum, 
but then its strange,test my example and put the first two textures to 0/0, and the textures aren't repeated, if you put them to 1/1 they are repeated.

I'm standing on a pipe?

Share this post


Link to post

Update: Found something realy strange going on:

 

If you have a look into spacing.png you'll the the red - arrow which displays on a "spacing" on the graphic -> post-248-0-05332600-1363205356_thumb.png

If you'll have a look on the pure added image -> post-248-0-97083500-1363205381_thumb.png theres no spacing at all.

 

I found out that:

        statusbarTopSprite.setWidth(engine.app.getWidth());
        statusbarTopSprite.arrange();
        WidgetSprite statusBarLayerSprite = new WidgetSprite(engine.getGui(),"roastatus/statusbar_repeating.png");


        statusBarLayerSprite.arrange();


        statusbarTopSprite.setTexCoord(vec4(1.0f,1.0f,(engine.app.getWidth() / statusBarLayerSprite.getWidth()) +2,45.0f));
        statusbarTopSprite.setWrapRepeat(1);
        statusbarTopSprite.arrange();

 

 

Textcord with setWrapRepeat includes this spacing:  statusbarTopSprite.setTexCoord(vec4(1.0f,1.0f,(engine.app.getWidth() / statusBarLayerSprite.getWidth()) +2,45.0f));  statusbarTopSprite.setWrapRepeat(1);

 

Update: if you remove the setTexCoord and setWrapRepeat it looks like post-248-0-51640700-1363205863_thumb.png (left top) - so theres no blackspacing between.

 

In attachment you're finding a little example where you can reproduce this error.

For a fast help I would be realy glad.

 

Thanks 

Lars

roastatus.rar

Share this post


Link to post

Push.

Share this post


Link to post

Be carefully with integer division because int/int = int.

 

statusbarTopSprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth()) / statusBarLayerSprite.getWidth(),1.0f));

with repeat:

00000.jpg

without:

00001.jpg

Share this post


Link to post

Hey frustum,

 

thanks for advice, float() casting didn't bring up the solution:

topLayerSprite.setTexCoord(vec4(1.0f,1.0f,float(float(engine.app.getWidth()) / float(statusBarLayerSprite.getWidth())) +float(2),45.0f));
            topLayerSprite.setWrapRepeat(1);
            topLayerSprite.arrange();

 

I just tried with float around engine app and then I put every where, same error.

I attached again the problem after casting to float aswell.

Edit: It makes no difference if I remove +float(2) or not. FYI.

Greetings

Lars

post-248-0-59955200-1363525032_thumb.png

Share this post


Link to post

Lars,

 

As you can see by yourself, in the example Frustum has provided there is no black spacing. And since it is rendered correctly, I suggest you look through your code again. It is possible that this pixel appears due to incorrect scaling (if we are talking about int division) or if wrong texture coordinates are set.

Share this post


Link to post

Hey Manguste,

I'll check it this evening again with the sample I provided Frustum aswell.

 

I changed all int divisions to float division so there shouldnt be a problem anymore.

But y I'll check it this evening and notify you.

Greets

Lars

Share this post


Link to post

Hello Manguste, Hello Frustum,

 

I tried it a new, I attached a label where you see this problem.

Here the screenshot where you see the label "test" which shows that setTexCoords does something strange:post-248-0-35285400-1363892698_thumb.png

If i remove the texcoord and the wrap I got this: post-248-0-20092300-1363892847_thumb.png

 

 

Where you see the Image isn't destroyed.

 

PS: I casted all to (float) etc. but problem still exists.

I hope you can reproduce this error now.

In attachment the project with the attached label so you can see it.

 

Thanks

Lars

roastatus_new.rar

Share this post


Link to post

Put <label/> in UI under <sprite/>

post-135-0-42693700-1363899490_thumb.jpg

Share this post


Link to post

Hey Anton,

 

but that means that the label is attached ABOVE the sprite.

I wanted to show that the label is shown below the sprite cause its wrapped wrong and so a spacing is created.

Have a look into the pic posted before.

Here you see that the label is shown if i attach this behind the sprite.

This comes up if I use "settexcoord" and "setWrap" functionality, without it doesn't happend.

 

But thanks for hint anyway.

So Issue still open.

 

Greets

Lars

Share this post


Link to post

Update: Maybe its a problem in Windows and you're testing it on Linux?

Greetings

Lars

Share this post


Link to post

Maybe I found a solution for this problem I'll inform you in some days anew with the solution or with more informations.

What I can say till now: Seems like a white space above the image which is rendered into the middle (realy strange whats going on there).

 

Greetings

Lars

Share this post


Link to post

Hello Unigine again,

 

I found the issue of the repeating bug now. It seems, like I posted above, that the "whitespace (its transparent)" in the image is killing the wrapFunctionality.

This whitespace is above the "statusbar" can be made visibile in photoshop or call this image with paint then you will see it. - It would be cool when you can check this aswell, a transparency shouldn't kill this functionality at all.

 

IMPORTANT ASWELL:

 

At all we got another issue with this functionality:

 

In Windows 7 the wrapping works after I removed the transparency above the statusbar.

In Linux (Ubuntu 12.10 to be exactly) it doesn't work.

This bug occures with and without the transparency in image..

 

Have a look into the attachment to see the bug in Linux:post-248-0-21323900-1364589966_thumb.png

Have a look into the attachment to see how it works looks on Windows:post-248-0-01327700-1364590035_thumb.png

 

 

In attachment the new version with the new image file without the transparency above the statusbar.

Iif you want the transparency as well to test, have a look into a post before with the attached roastatus.rar.

 

Greetings

Lars

roastatus.rar

Share this post


Link to post

lars.saalbach,

 

Thanks! I've sent this information to the developers (and about sprite with alpha-channel too).

Share this post


Link to post

Seems to be fixed.

Share this post


Link to post

Hi Manguste,

 

it isn't fixed.

We did a workarround with a sprite with 2600 pixel width.

Cause the widest resolution we support is 2550.

 

So we dismissed at first the .setWrap functionality etc.

So bug is still open.

Greetings

Lars

Share this post


Link to post

Please set the correct texture coordinates for sprites:

statusbarTopSprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth() / statusBarLayerSprite.getWidth()),1.0f));

mysprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth() / statusBarLayerSprite.getWidth()),1.0f));

Share this post


Link to post

The problem is in wrong texture coordinates.

statusbarTopSprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth()) / statusBarLayerSprite.getWidth(),1.0f));
mysprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth()) / statusBarLayerSprite.getWidth(),1.0f));
The first pair of numbers is upper-left corner.

The second pair is a lower-right corner.

The default value (0,0,1,1) means whole sprite coverage by texture without repeat.

Share this post


Link to post

Hey Frustum,

we tested it now on Windows and Linux, its working!

Thanks for your BIG afford!

 

Case can be closed.

Greetings

Lars

Share this post


Link to post
Sign in to follow this