• Advertisement
Sign in to follow this  

Loading Mesh with Specular Level

This topic is 1863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the D3D9 lighting equation, the materials specular value is multiplied with the lights specular value so if either of them is black, you don't get any specular effect.

The lighting is up to you to decide. Typically, a directional light is used to give lighting effect of a distant light source such as sun or moon.

Since it is a directional light, the position doesn't have any effect on the lighting. So practically you don't need to touch the lights position when the player is moving.

Otherwise, a directional light source isn't the best way to light indoor environments, it works the best at outdoors.

Best regards!

Share this post


Link to post
Share on other sites
Advertisement
Very good info! I thought that the sun light is a point light.

I'm trying to make each mesh specular level same as in 3Ds Max, so I tried putting some values, but couldn't get it to work, I have the mesh specular level set to 20 in 3Ds Max, I thought I could give light.Specular (1.0f, 1.0f, 1.0f) so when it get multiplied the result become the same as the specular level in the mesh.

As you can see in the screenshot, the specular level is too high even I'm setting it's value in 3Ds Max to 20 only.

I would appreciate if you could tell me how can I change this code to get a result at least close to the value that I put in 3Ds Max to the specular level.


D3DLIGHT9 light;
ZeroMemory(&light, sizeof(light));
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 0.1f;
light.Diffuse.g = 0.1f;
light.Diffuse.b = 0.1f;


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

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


// Set the direction that this light will generate light from
D3DXVECTOR3 vDir( 100.0f, -100.0f, 100.0f );


// Normalize the light direction
D3DXVec3Normalize ((D3DXVECTOR3*) &light.Direction, &vDir);
Edited by Medo3337

Share this post


Link to post
Share on other sites
Can you provide a screenshot of 3DS MAX to give some reference about the image?

There is a possibility that 3DS MAX is using per-pixel lighting for the preview screen which gives more accurate specular high lights.

I think that you should also increase the lights diffuse value. Typically most of lighting comes from the diffuse part of the lighting equation.

Yes, sun could be modeled with point light, but then it's relative position to the scene needs to be quite far (which is true in the real world too).
As the point light source gets further and further away, the light direction starts to get uniform. For that reason, a directional light is used often to model sun light. It could be considered as optimization, since directional lights can skip attenuation calculations and the light direction vector is same for all position on screen. The attenuation difference between the closest and the farthest point of earth to the sun is quite small.

A point light needs to calculate the light direction vector and attenuation for each fragment / vertex.

Best regards!

Share this post


Link to post
Share on other sites
Your light source definetely lacks diffuse lighting component. Otherwise, you'll need to get exactly the same point of view to compare the specular component, since it is view point relative.

To achieve the quality of a rendered 3DS MAX image may not be possible with D3D9 fixed function pipeline.

Best regards!

Share this post


Link to post
Share on other sites
I have update my exporter today because I found glossiness in 3ds max is the power, not the specular level... so if you want to ajust power, please redownload the plugin.
Now the power/glossiness you get is beteen 0 to 100, just what you see in 3ds max.

Share this post


Link to post
Share on other sites
@Alin: I don't see the update, I downloaded v1.8.2 few days ago and on the website I still see the same version http://www.cgdev.net/download.php

Additionally, I have few suggestions:
- I would suggest you to make "Add animation" open a new window to add animation instead of editing from the animation list, when I double click on the animation item to edit it, it's not showing edit mode easily.

- When you change the settings in the export window, it doesn't save which waste alot of time later when you try to export again since you have to add the same settings again including animations, etc...

- A progress bar while writing the .x file would be great.

- Hitting 'Enter' button to start exporting would be better. Edited by Medo3337

Share this post


Link to post
Share on other sites
I dont change the version v1.8.2 to v1.8.3 because this version simply change back to export glossiness as specular power... so your download 3 days ago is a special build for you. The next version I will add support for saving the settings of animations.
Thanks for your feedback

Share this post


Link to post
Share on other sites
@Alin: It looks like there is a bug with your exporter, I tried Panda Exporter and it's working perfectly with the specular effect, but had troubles with your exporter, when I set the specular level to 10 (As you see in the attached screenshot) I see a very high specular level when I use your exporter while when I use Panda exporter it's working perfectly.

Also, when I don't use specular in 3Ds Max and export the mesh with your exporter, I still see specular effect in the program even I didn't set it in Max, while when I use Panda Exporter it's not showing specular effect which is the accurate result.

The attached pictures show the same mesh with the same specular level and same everything, the only difference is the exporter.

Share this post


Link to post
Share on other sites
Thanks for your feedback, I have just released v1.8.3 for this bug. The new version also support saving settings of animation list.

Share this post


Link to post
Share on other sites
@Alin: Thanks for your cooperation!

One thing you might need to correct: Hitting 'Enter' on the keyboard doesn't start exporting.

I also would like to thank kauna for helping me to resolve this issue.

Share this post


Link to post
Share on other sites
Wow

what a long repies...

Max's spec level is just a float 100% is 1 ..

You must multiply it to specular value..

I tested it with my own software renderer 15years ago ^^

I can't help about X file's structure but I hope my knowledge help to writing shader :)

happy days Edited by GeniusPooh

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement