how do i scale a parallax texture?
-
- Posts: 34
- Joined: Thu Aug 17, 2006 10:32 pm
how do i scale a parallax texture?
normal scaling doesnt work with parallax type..
I've always used material.getTextureMatrix(0).setTextureScale
Now that I am experimenting with parallax mapping, that doesnt do the trick. What am I missing?
FYI I need a repeating pattern on an object to be the same size in the world on an object that will be different at each run time.
Thanks!
I've always used material.getTextureMatrix(0).setTextureScale
Now that I am experimenting with parallax mapping, that doesnt do the trick. What am I missing?
FYI I need a repeating pattern on an object to be the same size in the world on an object that will be different at each run time.
Thanks!
Fashizzle
-
- Posts: 34
- Joined: Thu Aug 17, 2006 10:32 pm
damn
so there is no way to do this at runtime? seems pretty odd. This is very disappointing to my project
Thanks for the information, if anyone else has something to add please do.
Thanks!
Thanks for the information, if anyone else has something to add please do.
Thanks!
Fashizzle
-
- Posts: 34
- Joined: Thu Aug 17, 2006 10:32 pm
-
- Posts: 34
- Joined: Thu Aug 17, 2006 10:32 pm
well...
so if the texture coords are making it tile 3 times by default...can I modify the texture coords to make it repeat more like I need? Sorry, I dont know much about texture coords in Irr...I know what they are but never played with them.
So in summary can I edit texture coords to control my diffuse and parralax maps?
Thanks!
So in summary can I edit texture coords to control my diffuse and parralax maps?
Thanks!
Fashizzle
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Yes, that's possible. You have to access the vertices of the underlying Mesh structure (hopefully an SMesh, otherwise it becomes complicated). The vertices hold the texture coords, you can set them to [0..1] for non-repeating and [-n..m] for repeating textures in both U and V direction (where the span [0..10] means that the texture will repeat ten times).
-
- Posts: 34
- Joined: Thu Aug 17, 2006 10:32 pm
more help...sorry
Code: Select all
/////////////////////////////////////////////////////////////////////////////////////////
S3DVertex Vertices[4];
SMeshBuffer* mbuf = new SMeshBuffer();
for( int p = 0; p < 2000; p++ )
{
{
Vertices[0] = S3DVertex( p ,0 ,0 ,0,-1,0, SColor(255,255,255,255), 1, 0 );
Vertices[1] = S3DVertex( p+12 ,0 ,0 ,0,-1,0, SColor(255,255,255,255), 1, 1 );
Vertices[2] = S3DVertex( p+12 ,0 ,100 ,0,-1,0, SColor(255,255,255,255), 0, 1 );
Vertices[3] = S3DVertex( p ,0 ,100 ,0,-1,0, SColor(255,255,255,255), 0, 0 );
u16 indices[6] = { 0,1,2 ,0,2,3 };
mbuf->Vertices.set_used( p * 4 );
for( int i = 0; i < 4; i++ )
mbuf->Vertices.push_back( Vertices[i] );
mbuf->Indices.set_used( p * 6 );
for( int i = 0; i < 6; i++ )
mbuf->Indices.push_back( indices[ i ] + p );
}
}//end poly loop
SMesh* wall_mesh = new SMesh;
SAnimatedMesh* wallmesh = new SAnimatedMesh;
wall_mesh->addMeshBuffer( mbuf );
wallmesh->addMesh( wall_mesh );
smgr->getMeshManipulator()->makePlanarTextureMapping( wall_mesh, 0.001f );
scene::ISceneNode* wall = 0;
ITexture* colorMap = driver->getTexture("panel_color.jpg");
ITexture* normalMap = driver->getTexture("panel_height.jpg");
driver->makeNormalMapTexture(normalMap, 5.0f);
scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents( wall_mesh );
scene::IMeshManipulator *manipulator = smgr->getMeshManipulator();
wall = smgr->addMeshSceneNode(tangentMesh);
wall->setMaterialTexture(0, colorMap);
wall->setMaterialTexture(1, normalMap);
wall->getMaterial(0).SpecularColor.set(255,220,220,220);
wall->setMaterialFlag(video::EMF_FOG_ENABLE, true);
wall->setMaterialType( video::EMT_PARALLAX_MAP_SOLID );//EMT_NORMAL_MAP_SOLID or video::EMT_PARALLAX_MAP_SOLID or video::EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA
wall->getMaterial(0).MaterialTypeParam = .01; // adjust height for parallax effect
// drop mesh because we created it with a create.. call.
tangentMesh->drop();
wall->setScale(vector3df(0.03,0.03,0.03));
wall->setPosition(vector3df(4.5,0.5,4));
video::IMaterialRenderer* renderer = driver->getMaterialRenderer( video::EMT_PARALLAX_MAP_SOLID );//video::EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA
//room->setMaterialTexture( 0, wall_texture );
wall->getMaterial(0).setFlag( video::EMF_LIGHTING, true );
//room->getMaterial(0).setFlag( video::EMF_ANISOTROPIC_FILTER, true );
//room->getMaterial(0).setFlag( video::EMF_BILINEAR_FILTER, true );
wall->getMaterial(0).setFlag( video::EMF_BACK_FACE_CULLING, false );
//room->addShadowVolumeSceneNode( -1,true,10000 );
//room->setMaterialType(video::EMT_SOLID_2_LAYER dx only
/////////////////////////////////////////////////////////////////////////////////////////
scene::ILightSceneNode* light = smgr->addLightSceneNode(0, vector3df( 1000,1000,1000 ),
SColorf( 0.5f, 0.5f, 0.5f, 1.0f ), 2000 );
light->getLightData().CastShadows = true;
light->getLightData().AmbientColor.set(0.4,0.4,0.4);
light->getLightData().DiffuseColor.set(0.8,0.8,0.8);
light->getLightData().SpecularColor.set(1,1,1,1);
smgr->setShadowColor( video::SColor(50,0,0,0) );
u32 frames=0;
while(device->run())
{
driver->beginScene(true, true, video::SColor(0,100,100,100));
light->setPosition( maincam->getPosition() );
smgr->drawAll();
driver->endScene();
wchar_t tmp[255];
swprintf(tmp,255,L"%i, %i",driver->getPrimitiveCountDrawn(), driver->getFPS() );
device->setWindowCaption(tmp);
}
But when the scale starts to get right, up towards 1 instead of .001, my framerate goes to crap. Which is strange considering theres only a couple thousand polys. I have ran 40k+ on here at much better FPS with lighting and shadows.
What am I doing wrong with the texture coordinates? I have tried different values and the outcome is the same.
Fashizzle
-
- Posts: 34
- Joined: Thu Aug 17, 2006 10:32 pm
https://photos-2.getdropbox.com/i/l/Xgs ... 4_zZFX6k#6
https://photos-3.getdropbox.com/i/l/uj4 ... E_BzSAlE#7
in the first image, I acheived this look by changing the makePlanarTextureMapping resolution to 0.5. This is the look I want.
The other image is with the default of 0.001. As you can see in the title bar the first one is 8 FPS and second is 16FPS both of which are too slow, slows down the whole computer and mouse etc. I must be doing something wrong because irrlicht usually runs fast on this machine. The parralax demo runs great on this machine, so surely I am screwing something up.
But I need to scale the texture the right way, I have a feeling changing that resolution is not the right way!
https://photos-3.getdropbox.com/i/l/uj4 ... E_BzSAlE#7
in the first image, I acheived this look by changing the makePlanarTextureMapping resolution to 0.5. This is the look I want.
The other image is with the default of 0.001. As you can see in the title bar the first one is 8 FPS and second is 16FPS both of which are too slow, slows down the whole computer and mouse etc. I must be doing something wrong because irrlicht usually runs fast on this machine. The parralax demo runs great on this machine, so surely I am screwing something up.
But I need to scale the texture the right way, I have a feeling changing that resolution is not the right way!
Fashizzle
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
I ddin't really looked at your code so far, but there are many *major* (havok, insane, you get it?) problems as I can see:
* You're creating S3DVertex nodes, while parallax mapping needs S3DVertexTangents, you should use the correct type from start.
* You're creating 2000*4 nodes, which are almost all upon each other, the structure makes absolutely no sense
* Using set_used this was is absolutely wrong: Either use set_used and direct access or use reallocate and push_back!
* Doing the reallocate in a loop kills performance, you know the number of vertices from the start
* makePlanarMapping makes no sense, you can define the texture coords in the vertices
Fixing all thses issues should at least deliver a much better mesh, maybe all the problems are fixed by then.
* You're creating S3DVertex nodes, while parallax mapping needs S3DVertexTangents, you should use the correct type from start.
* You're creating 2000*4 nodes, which are almost all upon each other, the structure makes absolutely no sense
* Using set_used this was is absolutely wrong: Either use set_used and direct access or use reallocate and push_back!
* Doing the reallocate in a loop kills performance, you know the number of vertices from the start
* makePlanarMapping makes no sense, you can define the texture coords in the vertices
Fixing all thses issues should at least deliver a much better mesh, maybe all the problems are fixed by then.
-
- Posts: 34
- Joined: Thu Aug 17, 2006 10:32 pm
thanks
thank you for the info hybrid. I will fix some of the things you mentioned. Some of the things will stay however, this was a test app for my project in which I will be importing poly coordinates from an autocad dwg file, I wont know the number of polys at runtime, hence the push. I realize this mesh makes no logical sense, but it will have to be this way in my project.
I will try using S3DVertexTangents instead and take out the makePlanarMapping. I will also take out the set_used.
Thanks for your help!
I will try using S3DVertexTangents instead and take out the makePlanarMapping. I will also take out the set_used.
Thanks for your help!
Fashizzle