Main Menu

problem with draw mode ?

Started by reno, January 12, 2008, 09:58:39 AM

Previous topic - Next topic

reno



Hi,

I've got a problem or maybe it is PB who do something strange  ???

In this image, you can see 3 sprites using 3 draw mode :

1/ BlitMode (0),

2/ RotationMode (2),

3/ RotationMode + Colour Alpha (2+2048).


The original sprite's size image is a power of 2, 64x64.

I don't make any scaling or rotation.

1/image is drawed at the good size, like the original,

2/As you can see, the sprite's image is now deformed : it's like if the pixel were a very little bit streched,

3/With the color alpha enabled (0.5 for example), the sprite's image is again more "streched" !


What could I do to avoid that (because I would use RotationMode + Colour Alpha) ?
More games ? Go to my website :)
http://www.thereeteam.com/

kevin


It's to do with the edge translation and easily solved by adjusting the sprites UV values.   

reno

Yes, but the UV sprites command don't work anymore with 1.7x

As you said :

Quote
The following commands are no longer a part of PlayBasic.

Quote
   SpriteParent
    SpriteImageUV
    ...

???

Another solution Kevin ? Thank you.
More games ? Go to my website :)
http://www.thereeteam.com/

kevin


reno

Sorry Kevin... but the doc doesn't exist for this new command and I can't find any info about it on the forum :|

I can't make it run :(

I have another question : what is the differnce between "LoadFxImage" and "Load3DImage" ?

;)
More games ? Go to my website :)
http://www.thereeteam.com/

Big C.

Here u have an overview about the new, changed, removed commands of newer pb versions... also u can read about this information in the history.txt which u will found in your pb installed folder..


reno

Yes, I used this topic, but what I need, is a complete documentation, like in the PB's help files, to understand how work each new functions.
More games ? Go to my website :)
http://www.thereeteam.com/

kevin

Quote from: reno on January 16, 2008, 01:24:11 PM
Sorry Kevin... but the doc doesn't exist for this new command and I can't find any info about it on the forum :|


  PokeSpriteFaceUV      ThisSprite,FaceIndex,EdgeIndex, U#,V#

ThisSprite = The Sprite we wish to perform an action upon
FaceIndex = The index of the face (within the sprite) this action is to perform upon
EdgeIndex=  The index of the edge of this face which said action will be performed upon (Faces have either 3 or 4 edges,  3sided face is triangle,  4 side they're a quad)   Sprites default to create face  #0 with a 4 side face.
U#=  The  U component of this point on the the texture.  UV values range between 0 and 1
V#=  The  V component of this point upon the texture.  UV values range between 0 and 1



Quote
I have another question : what is the differnce between "LoadFxImage" and "Load3DImage" ?

   PB has 3 different image types,  with 3 different rendering engines (for the most part).  The Image types are termed as Video,  FX &  now 3D

   * Video is a image that stored in graphics card Video Memory.  These as GPU accelerated using Direct Draw. 

   * FX images are for the software rendering engine and reside in system memory.. 

    * 3D images are for the Direct 3D acceleration.   These are in fact 3D Textures behind the scenes.  They're for use with the 3D acceleration features found in PB1.64 and above.  Stuff like alpha blending, rotation and sprite entities.

     


kevin

Quote from: reno on January 16, 2008, 05:53:35 PM
Yes, I used this topic, but what I need, is a complete documentation, like in the PB's help files, to understand how work each new functions.

See:  http://www.underwaredesign.com/forums/index.php?topic=1602.0   

reno

#9
Hi and thank you for your help Kevin.

I worked this last days with the "PokeSpriteFaceUV" function... without good results  :'(

I used a 64x64 image and the rotation+alpha color.

1 - when the image was with an angle of zero, I used  this to correct the UV :


PokeSpriteFaceUV b1,0,0,0.00,0.00
PokeSpriteFaceUV b1,0,1,1.00,0.00
PokeSpriteFaceUV b1,0,2,1.00,1.02
PokeSpriteFaceUV b1,0,3,0.00,1.02


2 - when playing with alpha and always an angle of zero I used this :


PokeSpriteFaceUV b1,0,0,0.00,0.00
PokeSpriteFaceUV b1,0,1,1.02,0.00
PokeSpriteFaceUV b1,0,2,1.02,1.02
PokeSpriteFaceUV b1,0,3,0.00,1.02


As you can see, in your function, the U and V are normaly a float between 0 and 1. But in this case, I had to go higher to correct the image rendering.

3 - I stoped here, because I saw that if I apply a rotation to the image, and/or if the image was in another size, this UV were always changing, making impossible to tweak them in the correct way  :'(

So I just changed the angle of my in game cursor to 45° and decided to not apply color alpha when the image'angle was at 0°.


I read lastday the forums and see that you are working in the VM 2. I hope that it will work with 3D image  8)

PS : I know that PB is in work in progress, but the filtering filter only work with 3D images. And yes, working with 3D images, at this time, is very very sloooow ;)

Continue on your good work !
More games ? Go to my website :)
http://www.thereeteam.com/

kevin

Quote

So I just changed the angle of my in game cursor to 45° and decided to not apply color alpha when the image'angle was at 0°.

  PB1.7x editions work completely different from PB1.63 in terms rendering methods.  V1.63 and bellow render each sprites as a quads, this is not possible in the unified (hardware 3D ->software) editions of PB1.7x and above.   So sprites are drawn as pair of triangles since this is how the hardware likes the 3d objects to be formated. 

In other words hardware rendering takes precedence over the software render. So for the draw modes not supported by hardware, these fall through to the software render simply so that something is drawn.  The problem is that sprite rendering in the software render is only ever optimized to render quads, and not shared edge triangles. Since as the edge conversion rules (middle pairs are shared) are different when a quad has to be presented as triangle pair.   This will cause sheering on most rotated elements in the software render under PB1.7x and above. 



Quote
I read lastday the forums and see that you are working in the VM 2. I hope that it will work with 3D image  8)

Work on VM2 has nothing to do with the GFX engine.



Quote
PS : I know that PB is in work in progress, but the filtering filter only work with 3D images. And yes, working with 3D images, at this time, is very very sloooow ;)

  erm no, not all draw modes of the software render (aka the sprite draw modes from PB1.63 and bellow) can be 3d accelerated.  In fact most can't.  (Rotation, Alpha variable, Alpha 50 and Alpha Addition are the only support render modes with 3D images).  In your example above, you're not using 3d hardware at all,  in stead you're using the software engine to read the source pixels from 3D formated image in video memory.  Which is a NO NO.

    Learn About Image Modes

   Bilinear image filtering is only possible through the hardware render.  The software engine is unlikely to ever support it. 

reno

Thkank you for the help ;)

I tried this week the graphic rendering and can't make 3D images work without biiig slowdown...

Here is what I do (with one camera and one world) :

1.6x
Quote

1 - loadFXimage
2 - creat a sprite and assign it with (2+2048)
3 - draw ordered sprite

... works ,normaly.


1.71g
Quote

1 - load3Dimage
2 - creat a sprite and assign it with (2+2048)
3 - draw ordered sprite

... ultra slow and no alpha !

I tried to use "PrepareFXimage", and other tweak without succes  :-[
Can you help me. I know that most effect can't work, but I can't understand why it is so slow. What did I miss ?

Error Missing Closing Square Bracket
More games ? Go to my website :)
http://www.thereeteam.com/

kevin

QuoteCan you help me. I know that most effect can't work, but I can't understand why it is so slow. What did I miss ? 

     If you load/create a 3d image then the pixel data exists in Video Memory on GPU side of your computer.   This memory is local to the GPU, but not the CPU.  Only the hardware render  can fetch (read/write) the pixel data quickly in video memory.   The software render can't read Video Memory (where the image is stored) as it's not local to the CPU.   So every time it has to fetch a pixel from the texture to draw it, the CPU stalls waiting for it.   Even on PCX buses this is still 20 or 30 times slower than reading system memory.





img=MakeParticle(64,rndrgb())



Do
Cls rgb(30,50,70)


if spaceKey() or fps()>30
; Add another sprite with Image
AddSprite(img)
endif

FadeAngle#=wrapangle(Fadeangle#,1)

FadeLevel#=CosRadius(FadeAngle#,1)
if FadeLevel#<0.01 then FadeLevel#=0.01
if FadeLevel#>0.99 then FadeLevel#=0.99

Me=GetFirstSprite()
While Me>0
SpriteAlphaLevel me,FadeLevel#
me=GetNextSprite(me)
endWhile

DrawAllSprites

; show the original image
Drawimage img,0,0,false
Print FadeAngle#
print FadeLevel#

Sync
loop




Function AddSprite(img)
Spr=NewSprite(rnd(getSCreenWidth()),rnd(GetSCreenHeight()),img)
SpriteDrawMode Spr,2 +2048
SpriteAlphaColour Spr,rndrgb()
ENdFUnction


` *=----------------------------------------------------------------------=*
`              >> Make particle Image <<
` *=----------------------------------------------------------------------=*

Function MakeParticle(Size,Col)
ThisImage=NewFXImage(Size,Size)
RenderPhongImage  ThisImage,Size/2,Size/2,col,255,260/(size/2)
EndFunction ThisImage


reno

Thanks, I understand the concept, but how do you use sprites with Load3Dimage ?
More games ? Go to my website :)
http://www.thereeteam.com/

kevin



img=MakeParticle(64,rndrgb())


Do
Cls rgb(30,50,70)


if spaceKey() or fps()>30
; Add another sprite with Image
AddSprite(img)
endif

DrawAllSprites

; show the original image
Drawimage img,0,0,false

Sync
loop




Function AddSprite(img)
Spr=NewSprite(rnd(getSCreenWidth()),rnd(GetSCreenHeight()),img)
SpriteDrawMode Spr,2 +16 ; use Alpha Addition blend
SpriteAlphaColour Spr,rndrgb()
ENdFUnction


` *=----------------------------------------------------------------------=*
`              >> Make particle Image <<
` *=----------------------------------------------------------------------=*

Function MakeParticle(Size,Col)
ThisImage=New3DImage(Size,Size)
RenderPhongImage  ThisImage,Size/2,Size/2,col,255,260/(size/2)
EndFunction ThisImage