Author Topic: Texture drawing  (Read 38454 times)

0 Members and 3 Guests are viewing this topic.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Texture drawing
« Reply #30 on: June 17, 2011, 02:39:15 pm »
Don't give up; I'm pretty sure you can find a way. GM is really inefficient from when I used it. If you use low-res textures you might be able to pull it off on calc.
In-progress: Graviter (...)

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Texture drawing
« Reply #31 on: June 17, 2011, 02:46:57 pm »
Don't give up; I'm pretty sure you can find a way. GM is really inefficient from when I used it. If you use low-res textures you might be able to pull it off on calc.
I know. GM is really inefficient with almost everything it can do, but 5 seconds for only one triangle is a very long time, even for GM. And for a resonable gameplay, there should be at least 5 fps, and that while there wil be abouth 150 triangles be drawn. that means that it should be abouth 1000 times as fast as GM (I calculated it), so i really doubt that this is possible.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Texture drawing
« Reply #32 on: June 17, 2011, 10:14:21 pm »
First I think you should see if you can draw 150 solid triangles at 5FPS, and after you get that working you can start on textures :) That way you gain experience and can work better on textures ^^

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Texture drawing
« Reply #33 on: June 17, 2011, 11:16:13 pm »
Well, to give you an upperbound of what is possible on the calculator. I made this:

I got this running with about 20 polygons per frame at 15 fps. That's 300 polygons per second. Now, it wasn't full screen, but it was in grayscale, so we can probably call that an even trade and say I would have gotten 300 polygons per second full screen in black and white.


You want to go for textured polygons, I would imagine that textured polygons take around 4 times as long, (complete guess), so you could probably pull off 75 polygons per second with well optimized code. At that rate, you would be getting 15 polygons at 5 fps. Of course to get this though, you're going to have to make some seriously optimized texturing routines, but I bet you could do it.

But, what I am trying to say is that polygon rendering on the calculator is totally possible, so don't give up.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Texture drawing
« Reply #34 on: June 18, 2011, 03:10:31 pm »
whoa, that looks really good. Is it raycasting, mode-7 or 'real' 3D?

back on topic:
how can i calculate the fps? When i try to optimise it, i would like to know if it has any effect.

Anyway, i really think i'm going to give up with textured triangles, and try textured quads instead. This should make it faster as quads can be fully done in 2D, so perspective correction won't be necessary.
« Last Edit: June 18, 2011, 03:21:59 pm by ben_g »
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Texture drawing
« Reply #35 on: June 18, 2011, 03:21:08 pm »
Either Calc84 or Runer presented a tilemapping 3d engine while back that had simple textures. I can't seem to find the screenshots, though.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Texture drawing
« Reply #36 on: June 18, 2011, 03:22:54 pm »
has it got a routine to draw a textured quad?
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Texture drawing
« Reply #37 on: June 18, 2011, 03:32:28 pm »
You can just use two triangles for that, but I guess a dedicated routine could be more optimized.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Texture drawing
« Reply #38 on: June 18, 2011, 03:44:46 pm »
has it got a routine to draw a textured quad?

I'm not sure why you would want to draw quads as well, since having more than one routine is going to slow down your code.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Texture drawing
« Reply #39 on: June 21, 2011, 01:57:42 pm »
i'm not going to do it as well, I'm going to do a quad instaed of two triangles, becouse i think it would be faster
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Texture drawing
« Reply #40 on: June 21, 2011, 02:08:28 pm »
Either Calc84 or Runer presented a tilemapping 3d engine while back that had simple textures. I can't seem to find the screenshots, though.
I believe you're referencing this: http://ourl.ca/8272

Edit: Most recent screenies: http://ourl.ca/8272/154635
« Last Edit: June 21, 2011, 02:09:28 pm by ztrumpet »

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Texture drawing
« Reply #41 on: June 26, 2011, 04:03:22 pm »
This is the best i could make it do. Could somebody please check out the code and tell me what I'm doing wrong?

Spoiler For code:
//////////////////////////////////////////////////////////
//Texture triangle

draw_sprite(sprite0,1,450,0)
//draw_sprite(sprite0,1,450,100)


A_x=200
A_y=0
A_u=0
A_v=0
B_x=400
B_y=100
B_u=0
B_v=100
C_x=300
C_y=200
C_u=100
C_v=100



var i;
 if (B_y-A_y > 0) dx1=(B_x-A_x)/(B_y-A_y) else dx1=0;
if (C_y-A_y > 0) dx2=(C_x-A_x)/(C_y-A_y) else dx2=0;
if (C_y-B_y > 0) dx3=(C_x-B_x)/(C_y-B_y) else dx3=0;

   du2=(B_u-A_u)/(B_y-A_y)
   du1=(C_u-A_u)/(C_y-A_y)
   dv2=(B_v-A_v)/(B_y-A_y)
   dv1=(C_v-A_v)/(C_y-A_y)
   du3=(C_u-B_u)/(C_y-B_y)
   dv3=(C_v-B_v)/(C_y-B_y)


     
 E_x=A_x
 E_y=A_y
 S_x=E_x
 S_y=E_y
 E_u=A_u
 E_v=A_v
 S_u=E_u
 S_v=E_v
 
if(dx1 > dx2) {
   S_u=A_u
   S_v=A_v
   E_u=A_u
   E_v=A_v
while(S_y<=B_y){
   S_y+=1
   E_y+=1
   S_x+=dx2
   E_x+=dx1
   S_u+=du1
   S_v+=dv1
   E_u+=du2
   E_v+=dv2
   //draw_line(S_x,S_y,E_x,S_y)
//   du=(E_u-S_u)/(E_x-S_x)
//   dv=(E_v-S_v)/(E_x-S_x)
//   P_u=S_u
//   P_v=S_v
   for(i=S_x;i<=E_x;i+=1){
//   draw_point_color(i,S_y,draw_getpixel(P_u+450,P_v))
//   P_u+=du
//   P_v+=dv
   tmp=(i-S_x)/(E_x-S_x)
   draw_point_color(i,S_y,draw_getpixel(450+((1-tmp)*S_u+tmp*E_u),(1-tmp)*S_v+tmp*E_v))
   }
   }
E_x=B_x
  E_y=B_y
   du3=(C_u-B_u)/(C_y-B_y)
   dv3=(C_v-B_v)/(C_y-B_y)
   E_u=B_u
   E_v=B_v
while(S_y<=C_y){
   S_y+=1
   E_y+=1

//draw_line(S_x,S_y,E_x,S_y)
for(i=S_x;i<=E_x;i+=1){
   tmp=(i-S_x)/(E_x-S_x)
   draw_point_color(i,S_y,draw_getpixel(450+((1-tmp)*S_u+tmp*E_u),(1-tmp)*S_v+tmp*E_v))
   //draw_point_color(i,S_y,c_red)
   }
      S_x+=dx2
   E_x+=dx3
   S_u+=du2
   S_v+=dv2
   E_u+=du3
   E_v+=dv3
}
} else {                                        //Ignore everything behind this for now//////////////////////////////////////////////////////////////////////////////
while(S_y<=B_y){
   S_y+=1
   E_y+=1
   S_x+=dx1
   E_x+=dx2
draw_line(S_x,S_y,E_x,S_y)}
S_x=B_x
  S_y=B_y
 while(S_y<=C_y){
   S_Y+=1
   E_y+=1
   S_x+=dx3


draw_sprite draws the sprite at the given location. Ignore the 2nd argument.
draw_point_color draws a point at the given coordinates with the given color
draw_getpixel returns the color of the given pixel.

Only check the first part of the code (before the else in the middle), becouse that's the part that is run with a triangle with that shape.

Sorry that I'm asking for help again, but i really can't get it right.
« Last Edit: June 26, 2011, 04:04:12 pm by ben_g »
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Texture drawing
« Reply #42 on: June 27, 2011, 05:54:25 pm »
Messing around with the code for a whole day hasn't solved anything, so i decided to bump this topic, hoping for a solution.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Texture drawing
« Reply #43 on: June 27, 2011, 07:48:55 pm »
Take a look at the link ztrumpet posted. Runer actually wrote out his texture code.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Texture drawing
« Reply #44 on: June 27, 2011, 07:53:44 pm »
Ummm...that link is to a raycaster, which renders stuff quite differently from a polygon engine.