Jump to content


Photo

Surfaces In 3d


  • Please log in to reply
10 replies to this topic

#1 Wackojacko10101

Wackojacko10101

    GMC Member

  • New Member
  • 5 posts

Posted 28 August 2009 - 10:43 PM

I'm trying to use surfaces as a 3d texture, but when I try to draw to it a slight glitch occurs. The walls seem to over lay in the strangest places.
Posted Image
I've found the problematic code if it helps.
surface_set_target(surface)draw_sprite(_guy,0,16,16)surface_reset_target()
Thank you in advance for any any help.
and a big thank you to Gear God, Bikekid2222 and Frankpiet.

Edited by Wackojacko10101, 19 September 2009 - 07:38 AM.

  • 0

#2 Southman

Southman

    I simply am not here

  • GMC Member
  • 1662 posts
  • Version:GM:Studio

Posted 28 August 2009 - 10:57 PM

turn off 3d mode first, then make the surface.
surfaces dont work right in 3d mode, if you read the manual, you would know that
  • 0

#3 frankpiet

frankpiet

    ^destroyed evil chicken^

  • New Member
  • 760 posts

Posted 28 August 2009 - 11:04 PM

it looks like hidden surface removal is off.

try turning it on:
d3d_set_hiden(1)

  • 0

#4 Newly Discovered

Newly Discovered

    Harmonious Genius

  • New Member
  • 2467 posts
  • Version:GM8

Posted 29 August 2009 - 12:02 AM

not only is the depth crazy, but you'll notice that models no longer go through each other, it's either in front, or behind.
I used surfaces to create 3D shadows:
Posted Image

I figured out it was wrecking the depth, so I set up this script:
depth=-objCamera.depth+distance_to_point(objCamera.x,objCamera.y);
this is in the step event of every object. this will adjust the object's depth based on the distance to the camera, fixing the depth issue.
the only problem now though, is because 3D objects no longer go through each other, you cannot draw more than one thing per object.
you can't set the depth per thing you draw right? so, having a human model made from arms, legs, torso, and head, everything is on a single depth, and the script does nothing to help this.

Edited by Newly Discovered, 29 August 2009 - 12:07 AM.

  • 0

#5 brac37

brac37

    GMC Member

  • GMC Member
  • 765 posts
  • Version:GM7

Posted 29 August 2009 - 04:47 PM

not only is the depth crazy, but you'll notice that models no longer go through each other, it's either in front, or behind.
I used surfaces to create 3D shadows:
Posted Image

I figured out it was wrecking the depth, so I set up this script:

depth=-objCamera.depth+distance_to_point(objCamera.x,objCamera.y);
this is in the step event of every object. this will adjust the object's depth based on the distance to the camera, fixing the depth issue.
the only problem now though, is because 3D objects no longer go through each other, you cannot draw more than one thing per object.
you can't set the depth per thing you draw right? so, having a human model made from arms, legs, torso, and head, everything is on a single depth, and the script does nothing to help this.


Indeed! For convex bodies, you can turn on backface culling to get things right, but with your bodies, you must divide them into parts. I have a similar experience with running games with Linux Wine.
  • 0

#6 Newly Discovered

Newly Discovered

    Harmonious Genius

  • New Member
  • 2467 posts
  • Version:GM8

Posted 29 August 2009 - 04:55 PM

I don't know if you can tell from here, but the trees are all made from a single object (obviously).
They're made with a cylinder down the middle, and then 5 walls set at different angles.

When you go up next to them, it's very clear the depth issue is in play.
I tried setting culling on, but that just defeats the purpose of having it off (so you can see both sides of the wall instead of drawing the exact same, but flipped).

I read that if you turn off d3d, you can use surfaces. but it probably isn't possible (in my 3D shadows) to turn it on, get 3D projection for shadows, turn it off, render those shadows to a surface, turn it back on, and draw the floor with the texture as the surface, is it?
  • 0

#7 Pie Person!

Pie Person!

    GM 6+ Lover

  • GMC Member
  • 1973 posts

Posted 29 August 2009 - 05:42 PM

I recommend that we stay far away from surfaces. This kind of thing is hard to manage, video memory is always hard to manage; its unflexible, a lot of graphics cards poop when Game Maker doesn't handle the video memory properly; and it is oddly abstracted, many times it seems that you have to cheat around to get the proper results.

Especially in 3D mode, you should pick another method rather than using surfaces. Surfaces are always worse.
  • 0

#8 Imerxion

Imerxion

    GMC Member

  • New Member
  • 3 posts

Posted 30 August 2009 - 06:30 PM

I figured out it was wrecking the depth, so I set up this script:

depth=-objCamera.depth+distance_to_point(objCamera.x,objCamera.y);
this is in the step event of every object. this will adjust the object's depth based on the distance to the camera, fixing the depth issue.
the only problem now though, is because 3D objects no longer go through each other, you cannot draw more than one thing per object.
you can't set the depth per thing you draw right? so, having a human model made from arms, legs, torso, and head, everything is on a single depth, and the script does nothing to help this.

You can do that.. Or you can reset the Z buffer after you build your surface and add it as a texture..
{
  _surface = surface_create(128,128);
  surface_set_target(_surface);
  d3d_set_projection_ortho(0,0,100,100,0);
  draw_clear_alpha(color,alpha);
  //Draw something :3
  surface_reset_target();
  //Make teh texture
  japan = sprite_create_from_surface(_surface,0,0,128,128,0,0,0,0);
  //reset z buffer
  d3d_end();
  d3d_start();
}

Edited by Imerxion, 30 August 2009 - 08:39 PM.

  • 0

#9 Schreib

Schreib

    Valen Shadowbreath

  • GMC Member
  • 1455 posts

Posted 11 September 2009 - 06:36 PM

Surfaces are fine to use in 3D. Why are people so concerned? Video memory management doesn't change in 3D.
  • 0

#10 weckar

weckar

    Helping Hand

  • New Member
  • 1946 posts

Posted 11 September 2009 - 06:52 PM

well, since the data for z-buffering and surfaces have a tendency to overlap and override each other...

Anyway, there's a reason surfaces are destroyed when using d3d_start()
  • 0

#11 GearGOD

GearGOD

    Deus Verus

  • GMC Member
  • 2153 posts

Posted 11 September 2009 - 07:49 PM

since the data for z-buffering and surfaces have a tendency to overlap and override each other.

Its simply GM's poor implementation. When a rendertarget is set, its contents (depth/stencil buffer included) are cleared. If the contents are to be preserved, the target needs to be resolved before being unset, and written back into during the reset. GM does not do this. Its not a bug, its not a tendency. Its simply how rendertargets work.

Theoretically, you should be able to draw to surface without destroying anything if you ensure that the surface drawing is the first operation that occurs during a step of the game loop.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users