Sign in to follow this  
AquaMacker

Applying Phong Lighting, bad trouble !

Recommended Posts

AquaMacker    255
[attachment=7988:??.jpg]

[size=3][font=verdana,geneva,sans-serif]Hi~

Right is normal.
Left is Error !!!

I use..
same X File....
same FX File...
app code is almost same...

Why happen this problem ?[/font][/size]

Share this post


Link to post
Share on other sites
Ashaman73    13715
[quote name='AquaMacker' timestamp='1333274501' post='4927138']
app code is almost same...
[/quote]
That's the reason [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]
On the left you are rendering with flat shading, on the right with smooth shading turned on.

Share this post


Link to post
Share on other sites
AquaMacker    255
[quote name='Ashaman73' timestamp='1333282686' post='4927158']
On the left you are rendering with flat shading, on the right with smooth shading turned on.
[/quote]

First of All, Thanks you very much...

But I can't understand very well...

How change flat shading to smooth shading ?

Flag change ? D3DRS_SHADEMODE ?

I use shader. not FF.

please more...

Share this post


Link to post
Share on other sites
Tom KQT    1704
D3DRS_SHADEMODE has effect also when using shaders, it isn't related only to the fixed-function pipeline like some other render states.
When you set D3DSHADE_FLAT, it won't interpolate COLOR attibutes over triangles, so you'll get flat shading if you're using per-vertex lighting, even when you do it "manually" in shaders. (The situation would be different with per-pixel lighting, because texture coordinates - and thus normals - will still be interpolated normally.)

Share this post


Link to post
Share on other sites
AquaMacker    255
I don't set FLAT...

This problem still unsolved...

But I was helped your wording ( per-vertex lighting, per-pixel lighting )...

Would you get sample code or sample project or URL ?

Share this post


Link to post
Share on other sites
ATEFred    1700
[quote name='AquaMacker' timestamp='1333383810' post='4927539']
I don't set FLAT...

This problem still unsolved...

But I was helped your wording ( per-vertex lighting, per-pixel lighting )...

Would you get sample code or sample project or URL ?
[/quote]

Could it just be that you are using triangle face normals instead of interpolated vertex normals for your lighting?

Can you give us some more information on what you are doing here? (shaders, etc.)

Share this post


Link to post
Share on other sites
AquaMacker    255
I wish speak very detaily....

But English sooooooooooooooooooooooooooooooooooo hard [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]

Share this post


Link to post
Share on other sites
AquaMacker    255
[size=3][font=verdana,geneva,sans-serif]This is part of shader code.

[b]vs[/b]

output.normalW = mul( float4( input.normalL, 0.0f ), mWorldInvTrans ).xyz;

float3 posW = mul( float4( input.posL, 1.0f ), mWorld ).xyz;

output.toEyeW = EyePosW - posW;

output.posH = mul( float4( input.posL, 1.0f ), mWVP );

output.tex0 = input.tex0;


Left and Right use same This shader code...
"interpolated vertex normals" is blendweight normal ?

This is not skininfo object. Not use LoadMeshHierachyFromX() but use LoadMeshFromX().[/font][/size]

Share this post


Link to post
Share on other sites
AquaMacker    255
[size=3][font=verdana,geneva,sans-serif]How do i do ? [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img][/font][/size]

Share this post


Link to post
Share on other sites
Ashaman73    13715
[quote name='AquaMacker' timestamp='1333383810' post='4927539']
I don't set FLAT...

This problem still unsolved...
[/quote]
But do you set SMOOTH either ? I don't know DX in details, but when flat shading is the default setting, you need to explicitly set smooth shading.

Share this post


Link to post
Share on other sites
Tom KQT    1704
[quote name='Ashaman73' timestamp='1333516179' post='4928103']
[quote name='AquaMacker' timestamp='1333383810' post='4927539']
I don't set FLAT...

This problem still unsolved...
[/quote]
But do you set SMOOTH either ? I don't know DX in details, but when flat shading is the default setting, you need to explicitly set smooth shading.
[/quote]
That won't be the problem, the default value for D3DRS_SHADEMODE is D3DSHADE_GOURAUD, not flat shading.

Share this post


Link to post
Share on other sites
AquaMacker    255
[size=3][font=verdana,geneva,sans-serif]@Ashaman73, @Tom KQT[/font][/size]
[size=3][font=verdana,geneva,sans-serif]Thanks for answer...^^a[/font][/size]

[size=3][font=verdana,geneva,sans-serif]I still trying.....[/font][/size]

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