Jump to content

  • Log In with Google      Sign In   
  • Create Account


Loading Mesh with Specular Level


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
36 replies to this topic

#1 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 07 December 2012 - 09:10 AM

I create a mesh in 3Ds Max, sometimes I apply specular level in the materials window which make the mesh appears more realistic, I export the mesh to .x file and load it using DirectX 9 and C++, the problem is that I don't see the specular level that I have applied in 3Ds Max.

How can I load .x file in DirectX 9/C++ with specular level according to the material applied in 3Ds Max?

0.png

Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2169

Like
0Likes
Like

Posted 07 December 2012 - 09:26 AM

Are you rendering the mesh using a custom shader? Does your shader support specular highlites?

Cheers!

#3 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 07 December 2012 - 10:43 AM

No, I'm not using shader, I'm just loading the mesh using D3DXLoadMeshFromX() and D3DXLoadMeshHierarchyFromX()

#4 kauna   Crossbones+   -  Reputation: 2169

Like
0Likes
Like

Posted 07 December 2012 - 11:00 AM

Well have you enabled specular highlights for your rendering? Ie. setting D3DRS_SPECULARENABLE to true?

You don't give much of information about the rendering code so this is just guessing.

Cheers!

Edited by kauna, 07 December 2012 - 11:01 AM.


#5 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 07 December 2012 - 01:27 PM

No, I was not setting D3DRS_SPECULARENABLE to true, now I tried to set it to true by using:
device->SetRenderState(D3DRS_SPECULARENABLE, TRUE);

but still no specular.

Edited by Medo3337, 07 December 2012 - 01:42 PM.


#6 kauna   Crossbones+   -  Reputation: 2169

Like
0Likes
Like

Posted 07 December 2012 - 02:54 PM

Another thing to check is that your Light structure has some meaningful value for the specular color.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb172566(v=vs.85).aspx

Cheers!

#7 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 07 December 2012 - 03:05 PM

I'm not creating any light using DirectX, I'm just using 3Ds Max to set the specular level as you see in the above screenshot, then I use the following code to render the mesh after loading the mesh from .x file:

device->SetRenderState( D3DRS_LIGHTING, TRUE );
device->SetRenderState( D3DRS_SPECULARENABLE, TRUE );
device->SetRenderState( D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL );
// Code to draw the mesh here...


#8 kauna   Crossbones+   -  Reputation: 2169

Like
0Likes
Like

Posted 07 December 2012 - 03:35 PM

Well is there a light source in the scene? Does your diffuse lighting work as intended?

Can you confirm that the exported x-file contains lights and that your rendering code sets the lights?

A screenshot of your program with the model would help also.

Cheers!

Edited by kauna, 07 December 2012 - 03:35 PM.


#9 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 07 December 2012 - 03:57 PM

In 3Ds Max, I'm only changing Specular level value, I don't add any other light, when I load the .x file into DirectX Viewer, I don't see the specular as well, I'm trying to use Panda DirectX Exporter to export from 3Ds Max, I'm not sure if it export information about the specular level that I set in the material window.

Edited by Medo3337, 07 December 2012 - 03:59 PM.


#10 Anddos   Members   -  Reputation: 474

Like
0Likes
Like

Posted 08 December 2012 - 08:07 AM

ive never tried adding specular in 3dsmax to a mesh, but i know how to add a specular on a model with .fx which gives off a nice effect like this

Posted Image

Edited by Anddos, 08 December 2012 - 09:08 AM.

:)

#11 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 08 December 2012 - 09:13 AM

The main question is: Does .x file export specular level from 3Ds Max? If not, then what is the solution for exporting specular information? Maybe I should use another .x file exporter or read it from effects file.

#12 kauna   Crossbones+   -  Reputation: 2169

Like
0Likes
Like

Posted 08 December 2012 - 01:11 PM

According to the .x file specification, the material data should contain the specular color and power values.

MSDN spesifications on the .x file.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb147174(v=vs.85).aspx

Other question is that if your exporter supports them, although they are rather basic for typical lighting models.

Are you able to look in to the data and see if the materials have specular values?

Cheers!

#13 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 08 December 2012 - 02:47 PM

I think the exporter support them, I tried to calculate the MD5 hash for .x file with specular level and another .x file with the same mesh and same everything except different specular level and it's showing different MD5 hash, the attached file is a sphere that I added a specular level to it, you can check it out and let me know if it has specular level and how can I render it in DirectX with it's specular level.

Attached Files



#14 Alin   Members   -  Reputation: 391

Like
0Likes
Like

Posted 10 December 2012 - 02:17 PM

Hi, My directx exporter has make a update. Now it can export the power of specular and support 3ds Max 2013 ! The following is the result from my x file exporter:

Material _01_-_Default {
0.388235;0.411765;0.576471;1.000000;;
0.780000; //specular power
0.900000;0.900000;0.900000;;
0.000000;0.000000;0.000000;;
}
Mesh Sphere001 {
482;
...
If you want to use my exporter, download the axe free edition :)

#15 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 10 December 2012 - 05:13 PM

Hi Alin,

What render state should I use before the line mesh->DrawSubset(); so I can have the mesh drawn with specular level?

I tried to export using your exporter and draw the mesh using the following code:
m_d3dDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
m_d3dDevice->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
m_d3dDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
mesh->DrawSubset(i);

I still don't see the specular level.

#16 Alin   Members   -  Reputation: 391

Like
0Likes
Like

Posted 11 December 2012 - 08:11 AM

Do you extract the power from x file ahd set the material? like this:
D3DMATERIAL9 mtl;
mtl.Power = 78;
...
m_pd3dDevice->SetMaterial( &mtl );
...

#17 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 11 December 2012 - 09:19 AM

When I set the specular level to 100 in 3Ds Max, I can see that material.Power value is 1.0, I tried setting the material using m_pd3dDevice->SetMaterial( &material ); but can't see the specular level.

Also, I'm only loading the mesh, I don't use D3DLIGHT in the scene.

#18 kauna   Crossbones+   -  Reputation: 2169

Like
0Likes
Like

Posted 11 December 2012 - 10:02 AM

I'm still wondering how do you see the model if there isn't any light sources. Can you get a screen shot of your screen to show the output of your program.

Specular high lights are strongly dependent on the light source position / direction so I'm not sure what you expect to get if you don't have a light source in the scene.

Cheers!

#19 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 11 December 2012 - 10:05 AM

I want to see the mesh exactly as I see it when I render it in 3Ds Max, I'm not adding any light in 3Ds Max, just changing the specular level, so I want it to appear exactly as I see it in 3Ds Max.

Edited by Medo3337, 11 December 2012 - 10:09 AM.


#20 kauna   Crossbones+   -  Reputation: 2169

Like
0Likes
Like

Posted 12 December 2012 - 07:16 AM

And how do you suppose MAX is able to show the mesh with specular highlights if there isn't a light source in the scene?

The answer is : 3DS MAX has a light source in the scene (called Default Light) which will disappear when you place the first light source in the scene.

So to answer your question in a short way : you'll need a light source which has the same properties as the MAX default light in order to see the model lit as in 3DS MAX.

Best regards!

PS. I have asked a screenshot of your program 2-3 times now. I don't make such request without a reason. Looking at an image gives a lot more information than one person telling what he is doing or not doing or what he wishes that his program would do.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS