Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Texture2D ObjTexture;
- SamplerState ObjSamplerState;
- struct Light
- {
- float3 dir;
- float4 ambient;
- float4 diffuse;
- };
- cbuffer cbPerFrame
- {
- Light light;
- };
- cbuffer cbPerObject
- {
- float4x4 WVP;
- float4x4 World;
- };
- struct VS_OUT
- {
- float4 pos : SV_POSITION;
- float2 tex : TEXCOORD;
- float3 normal : NORMAL;
- };
- VS_OUT VS(float4 inPos : POSITION, float2 inTex : TEXCOORD, float3 inNormal : NORMAL )
- {
- VS_OUT output;
- output.pos = mul(inPos, WVP);
- output.tex = inTex;
- output.normal = mul(inNormal, World);
- return output;
- }
- float4 PS(VS_OUT input) : SV_TARGET
- {
- input.normal = normalize(input.normal);
- float4 diffRefl = ObjTexture.Sample(ObjSamplerState, input.tex);
- float3 col;
- col = diffRefl * light.ambient;
- col += saturate(dot(light.dir, input.normal) * light.diffuse * diffRefl);
- return float4(col, diffRefl.a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement