• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Medo Mex

Loading Mesh with Specular Level

36 posts in this topic

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?

[attachment=12651:0.png]
0

Share this post


Link to post
Share on other sites
Are you rendering the mesh using a custom shader? Does your shader support specular highlites?

Cheers!
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
No, I was not setting D3DRS_SPECULARENABLE to true, now I tried to set it to true by using:
[CODE]device->SetRenderState(D3DRS_SPECULARENABLE, TRUE);[/CODE]

but still no specular. Edited by Medo3337
0

Share this post


Link to post
Share on other sites
Another thing to check is that your Light structure has some meaningful value for the specular color.

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

Cheers!
0

Share this post


Link to post
Share on other sites
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:

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

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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

[img]http://img152.imageshack.us/img152/1400/tinyspec.jpg[/img] Edited by Anddos
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
According to the .x file specification, the material data should contain the specular color and power values.

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

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!
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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 [url="http://www.cgdev.net/download.php"]axe free edition[/url] :)
0

Share this post


Link to post
Share on other sites
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:
[CODE]m_d3dDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
m_d3dDevice->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
m_d3dDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
mesh->DrawSubset(i);[/CODE]

I still don't see the specular level.
0

Share this post


Link to post
Share on other sites
Do you extract the power from x file ahd set the material? like this:
D3DMATERIAL9 mtl;
mtl.Power = 78;
...
m_pd3dDevice->SetMaterial( &mtl );
...
0

Share this post


Link to post
Share on other sites
When I set the specular level to 100 in 3Ds Max, I can see that [i]material.Power[/i] 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.
0

Share this post


Link to post
Share on other sites
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!
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
I have attached a screenshot of the mesh.

Now, do I have to create light for every mesh with specular so I can have more realistic mesh? what light settings should I supply to D3DLIGHT so I can see something similar to 3Ds Max?

Regards!

[attachment=12752:world.png]
0

Share this post


Link to post
Share on other sites
Well the screenshot lacks also diffuse and ambient lighting on the model so that kind of confirms that the missing light is a problem.

You don't need to include a light source with your models. You may create a light source in your program.

I guess that the default light source in MAX could be a directional light. [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb172566(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb172566(v=vs.85).aspx[/url] Check here for the variables for the D3DLIGHT9 structure.

For a directional light, it's probably ok just to provide the Type, Diffuse, Specular, Ambient and Direction values.

Cheers!
1

Share this post


Link to post
Share on other sites
Still couldn't adjust the light correctly in the scene to see specular highlights.

The airstrike is located at the position (X: 0.0f, Y: 0.0f, Z: 0.0f).

[CODE]
D3DLIGHT9 light;
ZeroMemory(&light, sizeof(light));
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;

light.Ambient.r = 1.0f;
light.Ambient.g = 1.0f;
light.Ambient.b = 1.0f;

light.Specular.r = 1.0f;
light.Specular.g = 1.0f;
light.Specular.b = 1.0f;

light.Position.x = 0.0f;
light.Position.y = 100.0f;
light.Position.z = -100.0f;

light.Direction.x = 0.0f;
light.Direction.y = 0.0f;
light.Direction.z = 0.0f;
light.Range = 550.0f;
m_d3dDevice->SetLight(0, &light);
m_d3dDevice->LightEnable(0, TRUE);
m_d3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
m_d3dDevice->SetRenderState( D3DRS_SPECULARENABLE, TRUE );
m_d3dDevice->SetRenderState( D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL );
m_d3dDevice->SetRenderState( D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL );
m_d3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );

m_d3dDevice->SetMaterial(&material[i]);
[/CODE]
0

Share this post


Link to post
Share on other sites
Directional light needs a direction. (0,0,0) doesn't point anywhere. The direction parameter is a normalized light direction. The position parameter doesn't have any effect when using a directional light.

Best regards! Edited by kauna
1

Share this post


Link to post
Share on other sites
Okay, thanks! getting somewhere very close to do exactly what I want, one more important point, to make all the meshes have specular highlights in FPS game, should I create a directional light and update it's position according to the player position? maybe I should make the directional light position always over the player?

I also notice that when I don't set light.Specular it doesn't work, I have already set specular for the mesh material, do I have to set it for the light too? Edited by Medo3337
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0