Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
HLSL-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
////////////////////////////////////////////////////////////////// //Includes #include"Constants.fx" #include"Sampler.fx" #include"Textures.fx" #include"Lighting.fx" ////////////////////////////////////////////////////////////////// //Layout struct VSInput { uint IID : SV_InstanceID; float3 vPosition : POSITION0; float3 vNormal : NORMAL0; float3 vTangent : TANGENT0; float2 vTextureCoord : TEXCOORD0; }; struct PSInput { uint IID : INSTANCEID; float4 vPosition : SV_Position; float3 vWorldPosition : POSITION0; float3 vNormal : NORMAL0; float3 vTangent : TANGENT0; float3 vBinormal : BINORMAL0; float2 vTextureCoord : TEXCOORD0; }; struct PSOutput { float4 Color : SV_Target0; }; //VertexShader PSInput VertexShaderProc(VSInput In) { PSInput Out; Out.IID= In.IID; float4 vWorldPosition= mul(float4(In.vPosition, 1.0), Instance[In.IID].mWorld); Out.vPosition= mul(vWorldPosition, mViewProjection); Out.vWorldPosition= vWorldPosition.xyz; float3 vNormal= mul(In.vNormal, (float3x3)Instance[In.IID].mWorld); Out.vNormal= vNormal; Out.vTangent= mul(In.vTangent, (float3x3)Instance[In.IID].mWorld); Out.vBinormal= cross(Out.vTangent, Out.vNormal); Out.vTextureCoord= In.vTextureCoord; return(Out); } //PixelShader PSOutput PixelShaderProc(PSInput In) { PSOutput Out; //NormalMapping column_major float3x3 mTBN= {In.vTangent, In.vBinormal, In.vNormal}; float3 vNormal= mul(TexNormalHeight.Sample(TextureSamplerWrap, In.vTextureCoord).rgb * 2.0 - 1.0, mTBN); //Illumination float3 SpecularLight= float3(0, 0, 0); float3 vViewDir= float3(mView._31, mView._32, mView._33); LightSource Light; uint LightIndex; //Light #0 (Directional) LightIndex= Instance[In.IID].aLightIndices[0].LID; if(LightIndex != 0xFFFFFFFF) { Light= aLights[LightIndex]; SpecularLight+= DirectionalLightSpecular(Light, vNormal, MatSpecularColorPower.a, vViewDir); } //Color-Sources float4 ColorAlpha= MatColorAlpha; float4 SpecularColorPower= MatSpecularColorPower; float4 EmissiveAmbient= MatEmissiveAmbient; float4 MirrorColorSaturation= MatMirrorColorSaturation; ColorAlpha*= TexColorAlpha.Sample(TextureSamplerWrap, In.vTextureCoord); Out.Color= float4(0, 0, 0, 1); Out.Color.rgb+= AmbientLight.rgb * EmissiveAmbient.a * ColorAlpha.rgb; Out.Color.rgb+= SpecularLight * SpecularColorPower.rgb; return(Out); } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »BlazeX« (13.11.2010, 17:47)
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »dot« (13.11.2010, 21:29)
transformiere das licht in den tangent space, dazu ist er schliesslich da. die matrix dafür hast du ja im vertex-shader.
ansonsten hast du beachtet, dass die normalen mit der inversen-transponierten weltmatrix transformiert werden sollte?
Warum soll ich die Normalen mit der inv. transp. WorldMatrix multiplizieren?
dot: du sagtest "eine Matrix aus Worldspace (!) Tangente, Bitangente und Normale bauen"
Müsste meine TBN-Matrix im PixelShader nicht so eine Matrix sein? Normale, Binormale und Tangente habe ich im VertexShader mit der WorldMatrix multipliziert. Im PixelShader setze ich diese nur noch zun TBN-Matrix zusammen.
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »dot« (13.11.2010, 22:05)
Werbeanzeige