3d kgl pvr texture format
-
- DCEmu Freak
- Posts: 82
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Thu Mar 10, 2016 7:14 am
- Has thanked: 0
- Been thanked: 1 time
3d kgl pvr texture format
Hi, I have just create my first own 3d object with the sample code in nehe directory.
Everything works but I can't change the pvr texture file when I try to convert my png file. The one with sample code works.
I tried with texconv whitout succes. I whish to tried texturepacker but need pro version to convert to PVR format
"/home/saturn/dc/texconv-master/texconv.exe -i image/banane.jpg -o image/banane.pvr -f RGB565 -t -p image/preview.png -v"
Which tool can I use for converting to pvr ?
Everything works but I can't change the pvr texture file when I try to convert my png file. The one with sample code works.
I tried with texconv whitout succes. I whish to tried texturepacker but need pro version to convert to PVR format
"/home/saturn/dc/texconv-master/texconv.exe -i image/banane.jpg -o image/banane.pvr -f RGB565 -t -p image/preview.png -v"
Which tool can I use for converting to pvr ?
- lerabot
- Insane DCEmu
- Posts: 134
- Joined: Sun Nov 01, 2015 8:25 pm
- Has thanked: 2 times
- Been thanked: 19 times
Re: 3d kgl pvr texture format
I've also had a lot of trouble with .pvr files. I've been working with .png and .dtex lately.
I'd be interesting in seeing how other are converting files to .pvr.
Tonma, this is how I've been laoding texture in my engine -> http://dcemulation.org/?title=Loading_P ... L_textures
I'd be interesting in seeing how other are converting files to .pvr.
Tonma, this is how I've been laoding texture in my engine -> http://dcemulation.org/?title=Loading_P ... L_textures
- BlueCrab
- The Crabby Overlord
- Posts: 5660
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: 3d kgl pvr texture format
As lerabot says, you're probably much better off not using .pvr files. There's almost no reason to use them, over other options that are much easier to handle (.png, .kmg, etc).
Re: 3d kgl pvr texture format
Thanks,
I have tried your tutorial and made test with VQ format too.
My first 3d textured object on Dreamcast it's awesome
I have a problem with the transparency of the texture. I have the same problem with the png texture and the VQ texutre. As you can see on the picture I have white color isntead of transparency. Maybe that's come from the emulator Demul.
For the VQ texture, i've used vqenc with -a (ARGB444) or -b format (ARGB1555) and in my code :
$(KOS_BASE)/utils/vqenc/vqenc.exe -t -v -a fruit.png
GL_UNSIGNED_SHORT_5_6_5_VQ_TWID //normal
GL_UNSIGNED_SHORT_1_5_5_5_VQ_TWID //transparency 1-bit (on/off)
GL_UNSIGNED_SHORT_4_4_4_4_VQ_TWID //transparency alpha
I have tried your tutorial and made test with VQ format too.
My first 3d textured object on Dreamcast it's awesome
I have a problem with the transparency of the texture. I have the same problem with the png texture and the VQ texutre. As you can see on the picture I have white color isntead of transparency. Maybe that's come from the emulator Demul.
For the VQ texture, i've used vqenc with -a (ARGB444) or -b format (ARGB1555) and in my code :
$(KOS_BASE)/utils/vqenc/vqenc.exe -t -v -a fruit.png
GL_UNSIGNED_SHORT_5_6_5_VQ_TWID //normal
GL_UNSIGNED_SHORT_1_5_5_5_VQ_TWID //transparency 1-bit (on/off)
GL_UNSIGNED_SHORT_4_4_4_4_VQ_TWID //transparency alpha
- BlueCrab
- The Crabby Overlord
- Posts: 5660
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: 3d kgl pvr texture format
Did you set up the proper texture parameters for the alpha to work and did you enable GL_BLEND? Look at the examples/dreamcast/kgl/basic/gl example for how to set that up if you aren't sure how (that seems to be the smallest example that does it, anyway)...
Re: 3d kgl pvr texture format
Thanks, that's works well.
I added :
glEnable(GL_BLEND);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); //rgbA
glDisable(GL_CULL_FACE);
But also need :
// Set Blend Mode //
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
I added :
glEnable(GL_BLEND);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); //rgbA
glDisable(GL_CULL_FACE);
But also need :
// Set Blend Mode //
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Re: 3d kgl pvr texture format
I've tried your script for blender to export an 3d object whitout success. (https://sites.google.com/site/vmusquad/home/blender2dc)lerabot wrote: ↑Sun Apr 08, 2018 11:25 am I've also had a lot of trouble with .pvr files. I've been working with .png and .dtex lately.
I'd be interesting in seeing how other are converting files to .pvr.
Tonma, this is how I've been laoding texture in my engine -> http://dcemulation.org/?title=Loading_P ... L_textures
I have blender 2.78c, add your script but nothing in File -> external data
Sorry bad files.
Last edited by tonma on Thu Apr 12, 2018 2:52 am, edited 1 time in total.
- lerabot
- Insane DCEmu
- Posts: 134
- Joined: Sun Nov 01, 2015 8:25 pm
- Has thanked: 2 times
- Been thanked: 19 times
Re: 3d kgl pvr texture format
I'll give you a proper answer tonight. I might have messed something in the exporter, I've never really tested it at the time
Good to know you got your texture working!
Good to know you got your texture working!
Re: 3d kgl pvr texture format
Sorry, it's my fault, I didn't use the good file.
Your script works when you make no mistake like me.
I tried with a plane :
Thanks for this code.
Your script works when you make no mistake like me.
I tried with a plane :
Code: Select all
const float Plane_vertices[4][3] = {
{ -1.000000f, -1.000000f, 0.000000f },
{ 1.000000f, -1.000000f, 0.000000f },
{ -1.000000f, 1.000000f, 0.000000f },
{ 1.000000f, 1.000000f, 0.000000f },
Re: 3d kgl pvr texture format
I've made more complex test and I have a problem.
I don't think that comes from the python script because I have the same probleme with obj export.
It seems it's only export mesh without contact as you can see on the picture. Maybe beacause I use quad and not triangle.
I have 24 vertices, 22 faces and 44 triangle. Blender export only vertices but no Cube_triangle. (const int Cube_triangles[22][3] = {
};)
I've modify a little the python raw export script to add the string : glVertex3f(x,y,z); and it's working :
I don't think that comes from the python script because I have the same probleme with obj export.
It seems it's only export mesh without contact as you can see on the picture. Maybe beacause I use quad and not triangle.
I have 24 vertices, 22 faces and 44 triangle. Blender export only vertices but no Cube_triangle. (const int Cube_triangles[22][3] = {
};)
Spoiler!
I've modify a little the python raw export script to add the string : glVertex3f(x,y,z); and it's working :
- lerabot
- Insane DCEmu
- Posts: 134
- Joined: Sun Nov 01, 2015 8:25 pm
- Has thanked: 2 times
- Been thanked: 19 times
Re: 3d kgl pvr texture format
I had strange UV mapping errors.
So I have rewrite the python script and now I can export blender to DC with UV mapping for quad polygons. But I need to do some tests before public release with more complex objects and change the text output (i'll create a temporary array to place value).
Now I have :
The blender viewport blur because I use small texture (64*64)
So I have rewrite the python script and now I can export blender to DC with UV mapping for quad polygons. But I need to do some tests before public release with more complex objects and change the text output (i'll create a temporary array to place value).
Now I have :
Spoiler!
- lerabot
- Insane DCEmu
- Posts: 134
- Joined: Sun Nov 01, 2015 8:25 pm
- Has thanked: 2 times
- Been thanked: 19 times
Re: 3d kgl pvr texture format
I feel like working on this sooo much. But I have so much thing to do for work! Shoot me a github link at some point. I'd love to make this compatible with the current openGL implementations.
Re: 3d kgl pvr texture format
Working version of my modified python script for blender to export quad polygon.
Code: Select all
glTexCoord2f(0.125000f, 1.000000f); glVertex3f(1.000000f, 0.999999f, 1.000000f);
...
glTexCoord2f(0.000000f, 0.875000f); glVertex3f(-1.000000f, -1.000000f, 1.000000f);
- Attachments
-
- blender2dc.zip
- (81.27 KiB) Downloaded 68 times
Re: 3d kgl pvr texture format
The blender export also works for triangulate model : 2310 tri
Need to add light for better effect. But I think I need to add Normal to my export
Need to add light for better effect. But I think I need to add Normal to my export
Re: 3d kgl pvr texture format
Now with normals for the light. Always 2310 tri.
I need to modify a little the python script when export with triangle or quad for the normals.
I need to modify a little the python script when export with triangle or quad for the normals.
- lerabot
- Insane DCEmu
- Posts: 134
- Joined: Sun Nov 01, 2015 8:25 pm
- Has thanked: 2 times
- Been thanked: 19 times
Re: 3d kgl pvr texture format
You should make a tutorial! Like what's your workflow from the blender model to drawing the mush in game. + lights
I'd love to have this!
Look good man!
I'd love to have this!
Look good man!
Re: 3d kgl pvr texture format
I have made some test and the framerate fall down to 30 fps.
[update ]
I can draw nearly 3000 triangles at 60fps. With/without texture. Not so bad, but I think we can draw more than that.
I used pvr_stats_t for showing the fps :
I have read somewhere than we must load data of the 3d object in gpu ram to gain speed and not loading all data every frame.
I have tested two way with nearly the same speed, so I certainly not doing the right things :
And all the code
[update ]
I can draw nearly 3000 triangles at 60fps. With/without texture. Not so bad, but I think we can draw more than that.
I used pvr_stats_t for showing the fps :
Code: Select all
sprintf(tmp, "frame rate: %f fps last_time: %f\n",
(double)stats.frame_rate, (double)stats.frame_last_time);
bfont_draw_str(vram_s + 10 * 640 + 180, 640, 0, tmp);
I have tested two way with nearly the same speed, so I certainly not doing the right things :
Code: Select all
glBegin(GL_QUADS);
glNormal3f(0.00f, -1.00f, 0.00f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-100.0f, -10.0f, 100.0f);
glNormal3f(0.00f, 1.00f, 0.00f); glTexCoord2f(1.0f, 0.0f); glVertex3f(100.0f, -10.0f, 1000.0f);
glNormal3f(0.00f, 1.00f, 0.00f); glTexCoord2f(1.0f, 1.0f); glVertex3f(100.0f, -10.0f, -100.0f);
glNormal3f(0.00f, 1.00f, 0.00f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-100.0f, -10.0f, -100.0f);
glEnd();
Code: Select all
GLfloat VERTEX_ARRAY[4 * 3 * 1] = { -100.0f, -10.0f, 100.0f,
100.0f, -10.0f, 100.0f,
100.0f, -10.0f, -100.0f,
-100.0f, -10.0f, -100.0f
};
GLfloat TEXCOORD_ARRAY[4 * 2 * 1] = { 0, 0,
1, 0,
1, 1,
0, 1
};
GLfloat NORMAL_ARRAY[4 * 3 * 1] = { 0, -1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0
};
GLubyte INDEX_ARRAY[4 * 1] = { 0, 1, 2, 3 };
// Bind Array Data //
glNormalPointer(GL_FLOAT, 0, NORMAL_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, TEXCOORD_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, VERTEX_ARRAY);
// Render the Submitted Vertex Data //
glDrawElements(GL_QUADS, 4 * 1, GL_UNSIGNED_BYTE, INDEX_ARRAY);
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
/* Load a PVR texture - located in pvr-texture.c */
extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap);
GLfloat VERTEX_ARRAY[4 * 3 * 1] = { -100.0f, -10.0f, 100.0f,
100.0f, -10.0f, 100.0f,
100.0f, -10.0f, -100.0f,
-100.0f, -10.0f, -100.0f
};
GLfloat TEXCOORD_ARRAY[4 * 2 * 1] = { 0, 0,
1, 0,
1, 1,
0, 1
};
GLfloat NORMAL_ARRAY[4 * 3 * 1] = { 0, -1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0
};
GLubyte INDEX_ARRAY[4 * 1] = { 0, 1, 2, 3 };
static float rx = 1.0f;
void RenderCallback(GLuint texID) {
glRotatef(rx++, 0, 1, 0);
// Bind Array Data //
glNormalPointer(GL_FLOAT, 0, NORMAL_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, TEXCOORD_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, VERTEX_ARRAY);
// Render the Submitted Vertex Data //
glDrawElements(GL_QUADS, 4 * 1, GL_UNSIGNED_BYTE, INDEX_ARRAY);
}
extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
int main(int argc, char **argv) {
int i;
glKosInit();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, vid_mode->width / vid_mode->height, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
/* Load a PVR texture to OpenGL */
GLuint texID = glTextureLoadPVR("/rd/wp001vq.pvr", 0, 0);
// Enable KOS Near Z Vertex Clipping //
glEnable(GL_KOS_NEARZ_CLIPPING);
// Set up Light1 - color it red //
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
float lp[4] = { 0.0, 200.0, 0.0, 0.0 };
float lc[3] = { 1.0f, 0.0f, 0.0f };
glLightfv(GL_LIGHT0, GL_POSITION, lp);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lc);
// Enable 2D Texturing and bind the Texture //
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texID);
while(1) {
// Load Identity and rotate it a bit //
glLoadIdentity();
/* Draw the "scene" */
for (i=0; i<900; i++){
RenderCallback(texID);
}
/* Finish the frame - Notice there is no glKosBegin/FinshFrame */
glutSwapBuffers();
}
return 0;
}