本文整理汇总了C++中VertexShader::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexShader::Load方法的具体用法?C++ VertexShader::Load怎么用?C++ VertexShader::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexShader
的用法示例。
在下文中一共展示了VertexShader::Load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateTestData
void Engine::CreateTestData()
{
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0,
D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R16G16_UNORM, 0,
D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R16G16_UNORM, 0,
D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0,
D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
Vector<StringByte> shaderSource;
// g-buffer write
FileSystem::Get()->Read("data/shaders/default.vsh", shaderSource);
vertexShader.Load(shaderSource.data(), layout, util::SizeOfArray(layout));
FileSystem::Get()->Read("data/shaders/default.psh", shaderSource);
pixelShader.Load(shaderSource.data());
FileSystem::Get()->Read("data/shaders/grid.psh", shaderSource);
gridPixelShader.Load(shaderSource.data());
// deferred composite
FileSystem::Get()->Read("data/shaders/identity.vsh", shaderSource);
identityVertexShader.Load(shaderSource.data(), layout, util::SizeOfArray(layout));
FileSystem::Get()->Read("data/shaders/composite.psh", shaderSource);
compositePixelShader.Load(shaderSource.data());
FileSystem::Get()->Read("data/shaders/texture.psh", shaderSource);
texturePixelShader.Load(shaderSource.data());
const int GridWidth = 21;
const int HalfGridWidth = GridWidth / 2;
F32 heightMap[GridWidth][GridWidth];
Vertex floorVertices[GridWidth * GridWidth * 6];
for (U32 yIndex = 0; yIndex < GridWidth; yIndex++)
{
for (U32 xIndex = 0; xIndex < GridWidth; xIndex++)
{
float x = xIndex + 0.5f - GridWidth/2.0f;
float y = yIndex + 0.5f - GridWidth/2.0f;
auto height = glm::simplex(glm::vec2(x, y) / 8.0f);
height += glm::simplex(glm::vec2(x, y) / 3.75f) * 0.6f;
heightMap[yIndex][xIndex] = height;
}
}
auto index = 0u;
for (U32 yIndex = 0; yIndex < GridWidth; yIndex++)
{
for (U32 xIndex = 0; xIndex < GridWidth; xIndex++)
{
float x = xIndex + 0.5f - GridWidth/2.0f;
float y = yIndex + 0.5f - GridWidth/2.0f;
auto p = Vec3(x, 0.0f, y);
auto p1 = p + Vec3(0.5f, 0.0f, -0.5f);
auto p2 = p + Vec3(-0.5f, 0.0f, -0.5f);
auto p3 = p + Vec3(-0.5f, 0.0f, 0.5f);
auto p4 = p + Vec3(0.5f, 0.0f, 0.5f);
auto PushBack = [&](Vec3 pf)
{
auto h = [&](float x, float z)
{
return heightMap
[math::Clamp(static_cast<S32>(floor(z)), -HalfGridWidth, HalfGridWidth) + HalfGridWidth]
[math::Clamp(static_cast<S32>(floor(x)), -HalfGridWidth, HalfGridWidth) + HalfGridWidth];
};
pf.y = h(pf.x, pf.z);
float deltaX = h(pf.x + 1, pf.z) - h(pf.x - 1, pf.z);
float deltaZ = h(pf.x, pf.z + 1) - h(pf.x, pf.z - 1);
Vec3 normal = glm::normalize(Vec3(-deltaX, 2, -deltaZ));
auto col = Vec4(
(pf.x + HalfGridWidth) / static_cast<float>(GridWidth),
1.0f,
(pf.z + HalfGridWidth) / static_cast<float>(GridWidth),
1.0f);
Vertex vertex;
vertex.position = pf;
vertex.SetNormal(normal);
vertex.colour = col;
floorVertices[index] = vertex;
index++;
};
//.........这里部分代码省略.........