vertex shader textures

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

vertex shader textures

Post by Granyte »

Almost completly i would still need geometry shaders to build the mesh on the gpu and as long as irrlicht is stuck on dx9 that is not happening
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Post Your Irrlicht Screenshots / Render Here.

Post by hendu »

Use OpenGL ;) Vertex textures available, probably transform feedback too via extensions (so you can store the generated mesh in a re-usable buffer, entirely without the CPU).

Irr GL also supports geometry shaders.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Post Your Irrlicht Screenshots / Render Here.

Post by Granyte »

I run a multi-GPU setup so OpenGL runs at half speed on my hardware.

Also i learned HLSL and not yet GLSL but i tryed converting to CG and run on OGL and DX but no luck so far. Also it seem CG hate AMD hardware.....
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Post Your Irrlicht Screenshots / Render Here.

Post by Mel »

No wonder... CG is an NVidia trademark... ^^U

And i am not sure about Open GL vertex textures, they need an extension which Irr seems not to be using
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Post Your Irrlicht Screenshots / Render Here.

Post by hendu »

I whipped a quick demo up, it certainly works here. If vertex textures didn't work, you'd see white instead of pink.

Code: Select all

#ifndef PINK_PNG_H
#define PINK_PNG_H
static const unsigned char pink_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x03, 0x00, 0x00, 0x00, 0x28, 0xcb, 0x34, 0xbb, 0x00, 0x00, 0x00,
0x03, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x56, 0xae, 0xc4, 0x6d, 0x7d, 0x0a,
0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x08, 0xd7, 0x63, 0x60,
0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xe2, 0x21, 0xbc, 0x33, 0x00, 0x00,
0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
};
#endif
 
#include <irrlicht/irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
 
static const char vtex[] =
    "uniform sampler2D tex;"
    "void main() {"
        "gl_Position = ftransform();"
        "gl_FrontColor = texture2DLod(tex, vec2(0.0), 0.0);"
    "}";
 
static const char ftex[] =
    "void main() {"
        "gl_FragColor = gl_Color;"
    "}";
 
int main() {
 
    IrrlichtDevice *dev = createDevice(EDT_OPENGL);
    if (!dev) return 1;
 
    IVideoDriver *drv = dev->getVideoDriver();
    ISceneManager* smgr = dev->getSceneManager();
 
    IReadFile *f = dev->getFileSystem()->createMemoryReadFile((void *) pink_png,
                        sizeof(pink_png), "pink.png");
    ITexture *pink = drv->getTexture(f);
    f->drop();
 
    IMeshSceneNode *n = smgr->addCubeSceneNode();
    smgr->addCameraSceneNode(0, vector3df(0, 0, 20), vector3df(0));
 
    int shader = drv->getGPUProgrammingServices()->addHighLevelShaderMaterial(
                vtex, ftex, (IShaderConstantSetCallBack*) 0);
    if (shader < 0) return 1;
 
    SMaterial &cubemat = n->getMesh()->getMeshBuffer(0)->getMaterial();
    cubemat.Lighting = false;
    cubemat.MaterialType = (E_MATERIAL_TYPE) shader;
 
    n->setMaterialTexture(0, pink);
 
    while (dev->run()) {
        drv->beginScene();
        smgr->drawAll();
        drv->endScene();
    }
 
    dev->drop();
 
    return 0;
}
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Post Your Irrlicht Screenshots / Render Here.

Post by Granyte »

That's nice but in dx9 it tells me that it can't sample in the vertex shader.

Anyway given the geological devlopement rate of irrlicht i should have geometry shader or vertex texture anytime in the next 2 years
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Post Your Irrlicht Screenshots / Render Here.

Post by hendu »

It's a GLSL shader, not HLSL ;) And yes, DX9 can't do it, you need GL if you have XP.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Post Your Irrlicht Screenshots / Render Here.

Post by Granyte »

dx can do vertex texture only irrlicht is using prehistorical time dx version so it can't
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Post Your Irrlicht Screenshots / Render Here.

Post by Mel »

Technically, vertex textures are a pixel shader 3 feature, but they use diferent texture registers, so, materials would need either 4 more texture registers or a way to specify that a texture in the material was used as a vertex texture. But yes, DX9 is capable of using them, is Irrlicht which is not properly programmed to make use of them.

Still, given the circumstances, it would be better to have a DX10/DX11 driver (and pray they don't become old before M$ tries to impose their wims on the windows programming again...)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: vertex shader textures

Post by hybrid »

Well, what's the wrong thing about their usage? Is it just the d3dx dll that we link the default version against, or does it not work at all? If simple recompilation can fix this issue, it's basically non-existant. Otherwise we should do something against this problem. dx10 driver will need longer.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: vertex shader textures

Post by Nadro »

I run a multi-GPU setup so OpenGL runs at half speed on my hardware.
Do You use CrossFire? if Yes, please change Your app name to "afr-friendlyogl.exe" (old drivers was case sensitive for this name) if You want to run Your app in CF mode.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Re: Post Your Irrlicht Screenshots / Render Here.

Post by Bl00drav3n »

hendu wrote:I whipped a quick demo up, it certainly works here. If vertex textures didn't work, you'd see white instead of pink.

Code: Select all

#ifndef PINK_PNG_H
#define PINK_PNG_H
static const unsigned char pink_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x03, 0x00, 0x00, 0x00, 0x28, 0xcb, 0x34, 0xbb, 0x00, 0x00, 0x00,
0x03, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x56, 0xae, 0xc4, 0x6d, 0x7d, 0x0a,
0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x08, 0xd7, 0x63, 0x60,
0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xe2, 0x21, 0xbc, 0x33, 0x00, 0x00,
0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
};
#endif
 
#include <irrlicht/irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
 
static const char vtex[] =
    "uniform sampler2D tex;"
    "void main() {"
        "gl_Position = ftransform();"
        "gl_FrontColor = texture2DLod(tex, vec2(0.0), 0.0);"
    "}";
 
static const char ftex[] =
    "void main() {"
        "gl_FragColor = gl_Color;"
    "}";
 
int main() {
 
    IrrlichtDevice *dev = createDevice(EDT_OPENGL);
    if (!dev) return 1;
 
    IVideoDriver *drv = dev->getVideoDriver();
    ISceneManager* smgr = dev->getSceneManager();
 
    IReadFile *f = dev->getFileSystem()->createMemoryReadFile((void *) pink_png,
                        sizeof(pink_png), "pink.png");
    ITexture *pink = drv->getTexture(f);
    f->drop();
 
    IMeshSceneNode *n = smgr->addCubeSceneNode();
    smgr->addCameraSceneNode(0, vector3df(0, 0, 20), vector3df(0));
 
    int shader = drv->getGPUProgrammingServices()->addHighLevelShaderMaterial(
                vtex, ftex, (IShaderConstantSetCallBack*) 0);
    if (shader < 0) return 1;
 
    SMaterial &cubemat = n->getMesh()->getMeshBuffer(0)->getMaterial();
    cubemat.Lighting = false;
    cubemat.MaterialType = (E_MATERIAL_TYPE) shader;
 
    n->setMaterialTexture(0, pink);
 
    while (dev->run()) {
        drv->beginScene();
        smgr->drawAll();
        drv->endScene();
    }
 
    dev->drop();
 
    return 0;
}
Actually the quad didn't show up for me, because the wrong mipmap layer was selected, so disable mipmap creating by adding

Code: Select all

drv->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
before getTexture(). With this it works nicely on my Radeon HD 6950 (OpenGL 4.2). :)
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: vertex shader textures

Post by Granyte »

hybrid wrote:Well, what's the wrong thing about their usage? Is it just the d3dx dll that we link the default version against, or does it not work at all? If simple recompilation can fix this issue, it's basically non-existant. Otherwise we should do something against this problem. dx10 driver will need longer.

i don't know if it's the issue

all i get when i try to use vertex texure is cannot map to vertex shader instruction
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: vertex shader textures

Post by hendu »

@Bl00drav3n

How's the biggest mipmap (0) wrong? Or any mipmap at all, since smaller mipmaps should be the same color, it's a single-color texture ;)

Maybe Catalyst bug?
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Re: vertex shader textures

Post by Bl00drav3n »

Could be a driver bug, but I tested it with Mipmapping first and it showed me a black screen... Don't get me wrong, I also thought it was strange that it was black. xD

Edit: You made me curious, so I double checked it. If mipmapping is enabled, the screen stays black. o_O
Edit2: Okay, I don't get what is happening there. ^^ I put the texture lookup into the fragment shader but it still shows me a black screen. It does seem that there is a problem with generating mipmaps, maybe because it's a 1x1 px texture?
Edit3 (edithell): Yes, apparently everything works fine if I use a 2x2 px texture - is this a driver- or an Irrlicht-bug?
Post Reply