図0005a
#include "INCStructs.hlsli"
cbuffer ConstantBuffer : register(b0)
{
row_major float4x4 MatrixTransform : packoffset(c0);
float4 Emissive : packoffset(c4);
float4 Diffuse : packoffset(c5);
};
PSPTInput main(VSPTInput input)
{
PSPTInput result;
result.position = mul(input.position, MatrixTransform);
result.tex = input.tex;
return result;
}
#include "INCStructs.hlsli"
cbuffer ConstantBuffer : register(b0)
{
row_major float4x4 MatrixTransform : packoffset(c0);
float4 Emissive : packoffset(c4);
float4 Diffuse : packoffset(c5);
};
Texture2D g_texture : register(t0);
SamplerState g_sampler : register(s0);
float4 main(PSPTInput input) : SV_TARGET
{
//テクスチャとディフューズからライティングを作成
float4 Light = g_texture.Sample(g_sampler, input.tex) * saturate(Diffuse);
//エミッシブを足す
return saturate(Light + Emissive);
}
void SquareSprite::OnDraw() { auto Dev = App::GetApp()->GetDeviceResources(); auto pD3D11DeviceContext = Dev->GetD3DDeviceContext(); auto RenderState = Dev->GetRenderState(); //中略 //ブレンドステート if (m_Trace) { //透明処理 pD3D11DeviceContext->OMSetBlendState(RenderState->GetAlphaBlendEx(), nullptr, 0xffffffff); } else { //透明処理しない pD3D11DeviceContext->OMSetBlendState(RenderState->GetOpaque(), nullptr, 0xffffffff); } //デプスステンシルステート pD3D11DeviceContext->OMSetDepthStencilState(RenderState->GetDepthNone(), 0); //ラスタライザステート pD3D11DeviceContext->RSSetState(RenderState->GetCullBack()); //テクスチャとサンプラーの設定 pD3D11DeviceContext->PSSetShaderResources(0, 1, m_TextureResource->GetShaderResourceView().GetAddressOf()); ID3D11SamplerState* pSampler = RenderState->GetLinearClamp(); pD3D11DeviceContext->PSSetSamplers(0, 1, &pSampler); //描画 pD3D11DeviceContext->DrawIndexed(m_SquareMesh->GetNumIndicis(), 0, 0); //後始末 Dev->InitializeStates(); }