Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Texture2D diffuseTexture : register(t0);
- SamplerState textureSampler : register(s0);
- cbuffer TransformBuffer : register(b0) {
- float4x4 worldMatrix,
- transformMatrix,
- viewProjectionMatrix;
- };
- cbuffer MaterialBuffer : register(b1) {
- float3 materialDiffuseAlbedo;
- float materialSpecularExponent;
- float3 materialSpecularAlbedo;
- bool isTextured,
- isLighted;
- };
- struct vsInput {
- float3 positionLS : POSITION;
- float3 textureLS : TEXTURE;
- float3 normalLS : NORMAL;
- };
- struct vsOutput {
- float4 positionCS : SV_POSITION;
- float2 textureLS : TEXTURE;
- float3 normalWS : NORMAL;
- float3 positionWS : POSITION;
- };
- struct psOutput {
- float4 positionWS : SV_Target0;
- float4 normalWS : SV_Target1;
- float4 diffuseAlbedoWS : SV_Target2;
- float4 specularAlbedoWS : SV_Target3;
- };
- vsOutput VS( in const vsInput _in ) {
- vsOutput _out;
- _out.positionCS = mul(float4(_in.positionLS, 1.0f), mul(transformMatrix, viewProjectionMatrix));
- _out.positionWS = mul(_in.positionLS, (float3x3) worldMatrix);
- _out.normalWS = mul(_in.normalLS, (float3x3) worldMatrix);
- _out.textureLS = (float2)_in.textureLS;
- return _out;
- }
- psOutput PS( in vsOutput _in ) {
- psOutput _out;
- _out.normalWS = float4(normalize(_in.normalWS), materialSpecularExponent);
- float _lightEffectModifier;
- if (isLighted)
- _lightEffectModifier = 1.0f;
- else _lightEffectModifier = 0.0f;
- _out.positionWS = float4(_in.positionWS, _lightEffectModifier);
- _out.diffuseAlbedoWS = float4(materialDiffuseAlbedo, 1.0f);
- if (isTextured)
- _out.diffuseAlbedoWS *= diffuseTexture.Sample(textureSampler, _in.textureLS);
- _out.specularAlbedoWS = float4(materialSpecularAlbedo, 1.0f);
- return _out;
- }
Advertisement
Add Comment
Please, Sign In to add comment