//----------------------------------------------------------------------------- // Filename: Shader.hlsl //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- // Constant Buffer Variables //-------------------------------------------------------------------------------------- cbuffer WindowBuffer // Rarely, if ever, updates { // ViewProjectionMatrix will go here }; cbuffer NodeBuffer // Buffer from attached scene node; shared with other instances { //NodeMatrix will go here }; cbuffer InstanceBuffer // Buffer from instance; one per instance (might make into vertex buffer) { // InstanceMatrix will go here }; cbuffer SomethingSomething { // Something will go here }; cbuffer cbChangesEveryFrame : register(cb0) { matrix WorldViewProjectionMatrix; matrix WorldMatrix; float4 vMeshColor; }; //-------------------------------------------------------------------------------------- // Vertex Shader //-------------------------------------------------------------------------------------- void ColourVS( float1x3 iPosition : POSITION, float1x3 iNormal : NORMAL, float1x2 iUv : TEXCOORD, // output out float3 oNormal : NORMAL, out float2 oUv : TEXCOORD0, out float4 oColor : TEXCOORD1, out float4 oPos : TEXCOORD2, out float4 oPosition : SV_POSITION) { oPosition = mul(float4(iPosition, 1.0f), WorldViewProjectionMatrix); oUv = iUv; oColor = vMeshColor; oNormal = mul(iNormal, WorldMatrix); oPos = oPosition; return; } //-------------------------------------------------------------------------------------- // Textures and Samplers //-------------------------------------------------------------------------------------- Texture2D texDiffuse : register(t0); SamplerState samplerLinear : register(s0); //-------------------------------------------------------------------------------------- // Pixel Shader //-------------------------------------------------------------------------------------- float4 ColourPS( float3 normal : NORMAL, float2 uv : TEXCOORD0, float4 color : TEXCOORD1, float4 position : TEXCOORD2) : SV_Target { float depth = pow(position.z / position.w, 1000); float4 textureColor = texDiffuse.Sample(samplerLinear, uv); float diffuseFactor = dot(float3(1, 0, 0), normal); return float4(normal, 1.0f); //return float4(textureColor.xyz * diffuseFactor, 1.0f); //return float4(depth, depth, depth, 1.0f); }