Author Topic: Texture drawing  (Read 38441 times)

0 Members and 2 Guests are viewing this topic.

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 #15 on: June 14, 2011, 02:29:53 pm »
You can only check between the upper and lower points if in the virtual world, from where you are standing, they are one above another. But imagine you are standing at the bottom corner of a wall looking at the other corner of a wall. Now the points probably won't even be on the same X value. Although in reality, that formula is not about finding how tall the wall is, it's about figuring out what the scale factor you need to multiply your texture by.

And textures, I think this is where the misunderstanding is. If you simply draw a bounding box on the screen and fill it with a texture, yes, the wall will have a texture. But the texture won't change when the wall does. You could stand 2 feet from the wall, or 200 feet from the wall, and the texture would always be the same size. If the texture was a brick wall, at 200 feet away, the entire wall might just be a single brick. You have to scale the texture down so that as the wall gets smaller, the texture does too.

This same thing applies if you are looking at the wall from a weird angle, if you are doing what I said earlier, looking from the bottom corner to the top corner, obviously, the bricks closer to you will be bigger than the bricks farther away from you, and for this you need texture scaling.

Here is a simple game I made a while back using this concept. You can see that the wall gets closer, you have to scale the sprite up, otherwise, it wouldn't appear to get any closer.
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 jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Texture drawing
« Reply #16 on: June 14, 2011, 03:34:05 pm »
Do you have any axe code or something to demonstrate this principle? Maybe pretty pictures so my mind can understand it?

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 #17 on: June 14, 2011, 03:38:19 pm »
He gave pictures in his previous post.
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 #18 on: June 14, 2011, 03:52:28 pm »
Here is the website I was talking about earlier, it works completely of the screen coordinates of the triangle, and uses a method called linear interpolation.  It also works in scanlines, which is beneficial to us calculator users since scanlines are special for our screen and can be drawn rather quickly. 

http://www-users.mat.uni.torun.pl/~wrona/3d_tutor/tri_fillers.html

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 #19 on: June 14, 2011, 03:54:15 pm »
Here is the website I was talking about earlier, it works completely of the screen coordinates of the triangle, and uses a method called linear interpolation.  It also works in scanlines, which is beneficial to us calculator users since scanlines are special for our screen and can be drawn rather quickly. 

http://www-users.mat.uni.torun.pl/~wrona/3d_tutor/tri_fillers.html
Are you sure that's the right URL? I got the 'server not found' error
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 #20 on: June 14, 2011, 03:56:41 pm »
it works for me o.O

I've uploaded the file itself just in case

EDIT: Aw it didn't save the images :/
« Last Edit: June 14, 2011, 04:03:14 pm by Builderboy »

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 #21 on: June 14, 2011, 04:04:20 pm »
Yes, now it works.

Thanks, this is really useful. I'll save that link, and this will be the first thing I'm going to code tomorrow. Today, I haven't got enough time left.
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 #22 on: June 15, 2011, 03:47:36 pm »
I've already tried the solid triangle code on my computer. Works perfectely

Now I'l try the textured triangle
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 aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Texture drawing
« Reply #23 on: June 16, 2011, 07:54:25 am »
Congrats on that. Could you post screenies when you finish the tex draw routine?
I'm not a nerd but I pretend:

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Texture drawing
« Reply #24 on: June 16, 2011, 10:15:06 am »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Texture drawing
« Reply #25 on: June 16, 2011, 10:15:30 am »
Also, that raycasting tutorial is great.
I'm not a nerd but I pretend:

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 #26 on: June 16, 2011, 02:58:27 pm »
Congrats on that. Could you post screenies when you finish the tex draw routine?
Sure, but right now, I'm still trying to do it in a computer language. It's so much easier to first try it in a programming language you know, and then port it.

EDIT:I think I need some help with the textures: They just aren't being mapped correctly:

the texture itself is drawn at the right. The part that's inside the white triangle should be projected onto the triangle, while my code just pushed the whole texture in the triangle.
« Last Edit: June 16, 2011, 04:06:52 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 #27 on: June 17, 2011, 01:51:03 pm »
bad news: I think I'm going to stop with textures:I just can't get it right on my computer, and i noticed this:
Quote
Note! I find it hard to get good results using fixed point math because of inadequate precision
But that's not the main problem. The main problem is that I think that it would be way to slow. The normal triangle is fast enough, but on my computer, with 2.8GHz CPU, It takes over 5 secounds to draw the textured triangle. I know that game maker is very slow, but i don't think it's speed can be beaten by a calculator. A game just won't be fun when you have to wait for half an hour for each frame.

I think I'm going to make a 3D engine with solid faces, no textures. Unless somebody here knows how to beat the speed of a computer with a calc. (or is GM just way to slow to compare it to?)
« Last Edit: June 17, 2011, 01:54:03 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 aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Texture drawing
« Reply #28 on: June 17, 2011, 01:53:41 pm »
lol, you're right. Too bad.
I'm not a nerd but I pretend:

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 #29 on: June 17, 2011, 02:33:23 pm »
this can be caused by 2 different things: the algorithm is very inefissient, or Game Maker is very bad at drawing. There should be some way to efficiently draw triangles

btw: I just tested GM's drawing speed, and it turns out that drawing points with gm is really slow. Could there still be a chance that this is possible? I mean: OpenGL can render over a milion textured triangles with over 2000 fps. But openGL uses the graphics card, and a calculator hasn't got a good graphics card. Is there a chance that i could get reasonable speeds with this, or should i just give up?
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