Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8176437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:10:47+00:00 2026-06-06T23:10:47+00:00

EDIT: IT seems like the only problem left now is that the light comes

  • 0

EDIT: IT seems like the only problem left now is that the light comes from the opposite direction if i use the calculation with a normal map. If i only use:

n = normalize(Input.NorView);

it seems to be fine.

I am starting to learn some HLSL Shading with DirectX10 and I have tried to use a normal map to calculate my phong lightning.
First off here is an example of how far I have come:

https://i.stack.imgur.com/IFAo4.jpg

I am not quite sure if this is what im looking to accomplish with this normal map:
https://i.stack.imgur.com/moQvf.jpg

I dont know..shouldn’t this look more 3Dish? Maybe I have just an false understanding of the usage of a normal map, but in my mindset a normal map is used to make a model more detailed by adding shadows based on the normal map, so its looks more 3D ish.

And here is my shading code:
Vertex Shader:

T3dVertexPSIn MeshVS(T3dVertexVSIn Input) {
    T3dVertexPSIn output = (T3dVertexPSIn) 0;
    float4 tempVar;

    output.Pos = mul(float4(Input.Pos.xyz, 1).xyzw, g_WorldViewProjection);

    output.Tex = Input.Tex;

    tempVar = mul(float4(Input.Pos.xyz, 1).xyzw, g_WorldView);
    output.PosView = tempVar.xyz;

    tempVar = mul(float4(Input.Nor.xyz, 0).xyzw, g_WorldViewNormals);
    output.NorView = tempVar.xyz;
    output.NorView = normalize(output.NorView);

    tempVar = mul(float4(Input.Tan.xyz, 0).xyzw, g_WorldViewNormals);
    output.TanView = tempVar.xyz;
    output.TanView = normalize(output.TanView);

    return output;
}

Pixel Shader:

float4 MeshPS(T3dVertexPSIn Input) : SV_Target0 {
    float4 output = (float4)0; //output color

    float3 N = normalize(Input.NorView);

    float3 T = Input.TanView;

    T = normalize(T - N * dot(N,T));
    float3 B = cross(T,N);

    column_major float3x3 mTBN= {T, B, N};
    float4 matDiffuse = g_Diffuse.Sample(samAnisotropic, Input.Tex);
    float4 matSpecular = g_Specular.Sample(samAnisotropic, Input.Tex);
    float4 matGlow = g_Glow.Sample(samAnisotropic, Input.Tex);
    float4 colLight = float4(1,1,1,1);
    float4 colLightAmbient = float4(1,1,1,1);
    float3 n = mul(g_Normal.Sample(samAnisotropic, Input.Tex).rgb * 2.0 - 1.0, mTBN);
    //float3 n = mul(float3x3(T,B,N), nT);
    //float3 n = normalize(Input.NorView);
    float4 I = g_LightDirView;
    float3 r = reflect(-I.xyz, n);
    float3 v = normalize(-Input.PosView);

    float cd = 0.5f, cs = 0.3f, ca = 0.1f, cg = 0.3f;



    output = cd*matDiffuse*saturate(dot(n,I.xyz))*colLight
            +cs*matSpecular*pow(saturate(dot(r.xyz,v)),10)*colLight
            +ca*matDiffuse*colLightAmbient
            +cg*matGlow;


    return output;
}

I also have the feeling that the lightning is changing direction when im using the normal map.but I am not sure.
Maybe someone can explain this matter to me a little bit.
Thanks in advance for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:10:49+00:00Added an answer on June 6, 2026 at 11:10 pm

    Seems like i was calculating the normal incorrect and some textures also got the wrong normal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like such a simple question. I have several Edit boxes on my
EDIT : I completely re-wrote the question since it seems like I was not
Edit: [Solved] : It seems that the getTableCellRendererComponent of the CustomTableCellRenderer is called every
Which algorithms or data structures are used in auto-suggest features? It seems that edit-distance
PLEASE SEE THE EDIT BELOW, THE REPORT SEEMS TO USE CACHED DATA? I cant
It seems to be a bug or problem when I use PHP PDO fetchOject
I am totally stumped on what seems like a simple problem. Maybe I'm just
[edit] So it seems my code works fine, another piece of code + tiredness
It seems it allows you to edit the content of an element, but what
[EDIT] Based on feedback yes, VS2010 seems to support SL4 Library TDD despite a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.