DCEmulation

dreamcast development • homebrew software • hardware hacking • indie games • emulators • and more!
Back to main site
It is currently Sat Oct 25, 2014 4:09 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: KGLX - Rendering Issues
PostPosted: Mon Jul 02, 2012 8:27 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
So, I have just recently started programming with OpenGL.

Using KGLX on DC, so far the results are good

Models are in the format MD2

Texture filter is set to PVR_FILTER_BLINEAR, the only thing that could help is Mip-Mapping

Image

I have managed to work out a basic camera implementation

Image

So far so good

Image

But problems occur with clipping of large polygons

Image

Also obviously transparency not working correctly

Image

So I post here for help with Clipping and Transparency. Any comments appreciated.


Top
 Profile  
 
PostPosted: Tue Jul 03, 2012 9:28 am 
Offline
The Crabby Overlord
The Crabby Overlord
User avatar

Joined: Mon May 27, 2002 9:31 am
Posts: 4249
I've never used KGLX, but from a hardware standpoint I might be able to at least partially explain things. Just prefacing it with that I've never used KGLX, so I don't know for sure if these are the issues you're running into or not...

With the original KGL that is included with KOS in kos-ports, you have to actually switch primitive lists, just like you would using the PVR directly. That means that you have to actually tell it that you're going to start rendering translucent polygons before you do so. With the original KGL, this is done by calling glKosFinishList() until it would open up the translucent list (if you're using the normal PVR init and not doing anything fancy, just once would do the trick after you're done with everything that's opaque). I don't know for sure if this is the same in KGLX, but it might explain the problems with transparency that you're seeing.

As for the clipping issue you're seeing, I can't think of anything off the top of my head that would cause that particular issue. If I had to guess, I'd say its probably that the polygon is getting culled, so check how you're handling culling and what KGLX does by default with that.


Top
 Profile  
 
PostPosted: Tue Jul 03, 2012 12:17 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
BlueCrab wrote:
With the original KGL that is included with KOS in kos-ports, you have to actually switch primitive lists, just like you would using the PVR directly.


Thanks BlueCrab!

I didnt realize that the list must be switched manually. That helped me solve the problem.

After that was fixed, I realized there was also something else going on.
The texture still looked pretty much like the previous post.

This problem was because I created the texture using GL_DECAL:
Code:
glTexEnvi( GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_DECAL );


Switch to the mode GL_MODULATE and now success!

Furthermore, the blending mode must be set to achieve the desired transparency level:
Code:
glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA ); /* Fully Transparent */


Image

Code:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); /* Semi Transparent */


Image


Top
 Profile  
 
PostPosted: Tue Jul 03, 2012 5:35 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
Having fun with transparent textures

Image

And abusing the mess out of the SH4 ( ~20fps )

Image

Wrote a basic skybox render function

Image

But still having problems with clipping

Image

Nobody has any ideas here? If needed, I can post some relevant code...


Top
 Profile  
 
PostPosted: Thu Jul 05, 2012 6:51 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 140
Hello Phenom !

Is it possible to look at the source code ? It would be easier to find your clipping problem.

_________________
ImageDynamite Dreams Dreamcast fans : http://www.facebook.com/dddreamcast


Top
 Profile  
 
PostPosted: Thu Jul 05, 2012 1:21 pm 
Offline
DCEmu Crazy Poster
DCEmu Crazy Poster

Joined: Tue Aug 30, 2011 1:29 am
Posts: 32
I hope you'll fix the pb.
Good luck.

_________________
http://www.dreamcast.fr / http://dreamcast-news.blogspot.com


Top
 Profile  
 
PostPosted: Fri Jul 06, 2012 4:46 am 
Offline
DC Developer
DC Developer
User avatar

Joined: Sat Dec 01, 2007 7:51 am
Posts: 295
Wow that's very nice. So you're working on the next "Hypertension" ?


Top
 Profile  
 
PostPosted: Sun Jul 08, 2012 2:43 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
patbier wrote:
Hello Phenom !

Is it possible to look at the source code ? It would be easier to find your clipping problem.


Check your inbox. I sent you a link to my source via PM.

Neoblast wrote:
Wow that's very nice. So you're working on the next "Hypertension" ?


Nope. I am developing independently. :P
As things turn out, that project only needed modelers.

Anyway, here are some latest screens of what Im working on...
Image

Image

For the curious, here is a cdi to check out the demo
Attachment:
dc-engine-3d-cdi-070812.rar [2.93 MiB]
Downloaded 73 times


Because Patbier said his K:OS did not come with KGLX, I will post the library here:
Attachment:
libkglx.tar.gz [95.87 KiB]
Downloaded 55 times


Top
 Profile  
 
PostPosted: Mon Jul 09, 2012 12:00 pm 
Offline
Mental DCEmu
Mental DCEmu
User avatar

Joined: Wed Mar 30, 2011 10:13 am
Posts: 308
Can I look at the source code too?

_________________
How do I try to build a Dreamcast toolchain:
Image


Top
 Profile  
 
PostPosted: Mon Jul 16, 2012 6:37 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
RyoDC wrote:
Can I look at the source code too?


Do you think you can help solve the clipping problem?
Because Im not ready to release the source, publicly...
Patbier and myself have worked together in the past, and he has trusted me with some of his sources.

But, if you have any questions about it, I would be happy to answer, and even share snippets of code / logic.


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 2:14 am 
Offline
DC Developer
DC Developer
User avatar

Joined: Sun Sep 05, 2010 3:44 am
Posts: 78
Looking at the libkglx file you are using, I think you are using the same version as Heinrich Tillack (author of Iris3D), the 0.41, isn't it?

Did you try with Chui's implementation? I understand that it is more advanced and is compatible with OpenGl 1.2, but I don't know exactly how far did he arrive. I sent you a PM with the details, but maybe that clipping problem is already solved! :)


Top
 Profile  
 
PostPosted: Wed Jul 18, 2012 8:23 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
Indiket wrote:
Looking at the libkglx file you are using, I think you are using the same version as Heinrich Tillack (author of Iris3D), the 0.41, isn't it?

Did you try with Chui's implementation? I understand that it is more advanced and is compatible with OpenGl 1.2, but I don't know exactly how far did he arrive. I sent you a PM with the details, but maybe that clipping problem is already solved! :)


Well, I still have not looked at the"Chui" build.
But I did look at the /examples/ included in the kglx-0.4.1 package you sent me, as they were not included with kos.
I did realize that DC uses "slightly" different z-clipping than normal gl.
Code:
glEnable(GL_KOS_NEARZ_CLIPPING);

Seems to help mostly.
The skybox is rendered fine, I just need to fix the rotations for the *new texture format being used for environment map.
Image

Image


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 10:59 am 
Offline
Mental DCEmu
Mental DCEmu
User avatar

Joined: Wed Mar 30, 2011 10:13 am
Posts: 308
...

_________________
How do I try to build a Dreamcast toolchain:
Image


Last edited by RyoDC on Wed Oct 17, 2012 5:39 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Tue Oct 16, 2012 11:52 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Sat Dec 01, 2007 7:51 am
Posts: 295
Do you get full 60 fps in these tests? Tried chui's version?
It's more advanced


Top
 Profile  
 
PostPosted: Sat Nov 10, 2012 1:49 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
Neoblast wrote:
Do you get full 60 fps in these tests? Tried chui's version?
It's more advanced


Yeah, Indiket sent me Chui's KGLX some time ago. In the end, it was not any faster and led to some transparency problems.

But yes, now things are rendered at Full 640x480p@60fps.

Thanks to some small optimizations advised by Bouz on the forums here, DC-Engine-3D is capable of Rendering ~50,000 polys/second

And there is still some room to optimize :P

Image


Attachments:
dc-engine-3d-111012.rar [1.99 MiB]
Downloaded 29 times
Top
 Profile  
 
PostPosted: Sat Nov 10, 2012 8:41 pm 
Offline
DCEmu Crazy Poster
DCEmu Crazy Poster

Joined: Sun Oct 04, 2009 9:13 am
Posts: 34
That doesn't actually run at 60 FPS on real hardware. It's 30 FPS when looking up into the sky, and 20 FPS when looking at the grass.


Top
 Profile  
 
PostPosted: Mon Nov 12, 2012 10:59 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
TapamN wrote:
That doesn't actually run at 60 FPS on real hardware. It's 30 FPS when looking up into the sky, and 20 FPS when looking at the grass.


Thank you for testing. Right now my DC is broken and i can not test.

I have re-written the render code, now based on meshes optimized for use with glVertexPointer().

Code:
void DCE_GlRenderArray( DCE_MESH * mesh )
{   
    glBindTexture(GL_TEXTURE_2D, mesh->texaddr);
   
    glVertexPointer(3, GL_FLOAT, 0, mesh->vert);   
    glEnableClientState(GL_VERTEX_ARRAY);
   
    glTexCoordPointer(2, GL_FLOAT, 0, mesh->texcoord);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);   
   
    if(mesh->primitive==DCE_RENDER_QUAD)
       glDrawArrays(GL_QUADS, 0, mesh->verts*mesh->primitive );
    else
       glDrawArrays(GL_TRIANGLES, 0, mesh->verts*mesh->primitive );
   
    glDisableClientState(GL_VERTEX_ARRAY);   
}


With that, I have written a utility to export 3ds models into my optimized DCE_MESH format.

Can someone test on real hardware?

Image

Image


Attachments:
dc-engine-3d-111212.rar [2.55 MiB]
Downloaded 27 times
Top
 Profile  
 
PostPosted: Tue Nov 13, 2012 2:16 pm 
Offline
Mental DCEmu
Mental DCEmu
User avatar

Joined: Wed Mar 30, 2011 10:13 am
Posts: 308
Phenom, tell me please, how do you debug your applications?

_________________
How do I try to build a Dreamcast toolchain:
Image


Top
 Profile  
 
PostPosted: Tue Nov 13, 2012 4:24 pm 
Offline
DCEmu Crazy Poster
DCEmu Crazy Poster

Joined: Sun Oct 04, 2009 9:13 am
Posts: 34
The newest one doesn't even seem to render. I can see the console output of the initialization and FPS counter, but get a black screen. It doesn't freeze completely, as the FPS counter still periodically updates. I couldn't get the controller or keyboard to do anything, like quit the program, either.


Top
 Profile  
 
PostPosted: Tue Nov 13, 2012 6:41 pm 
Offline
DC Developer
DC Developer
User avatar

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 417
TapamN wrote:
The newest one doesn't even seem to render. I can see the console output of the initialization and FPS counter, but get a black screen. It doesn't freeze completely, as the FPS counter still periodically updates. I couldn't get the controller or keyboard to do anything, like quit the program, either.


Well when it first loads, the mesh will be behind you so just use the d-pad to turn around.

RyoDC wrote:
Phenom, tell me please, how do you debug your applications?


Well, I dont use a debugger, really.

When things dont work as I suspect they should, I start throwing some printf() statements to track the progress.

Most DC devs probably frown on me for doing so much testing using an emulator, lol.

If you have more specific questions, feel free to shoot me a PM.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group