Fix OpenGL stencil clear hack. Improve example stencil reflection
This commit is contained in:
parent
76e64a985d
commit
084346bd5f
|
@ -163,6 +163,15 @@ void init() {
|
||||||
})"
|
})"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
nxt::ShaderModule fsReflectionModule = CreateShaderModule(device, nxt::ShaderStage::Fragment, R"(
|
||||||
|
#version 450
|
||||||
|
layout(location = 2) in vec3 f_col;
|
||||||
|
out vec4 fragColor;
|
||||||
|
void main() {
|
||||||
|
fragColor = vec4(mix(f_col, vec3(0.5, 0.5, 0.5), 0.5), 1.0);
|
||||||
|
})"
|
||||||
|
);
|
||||||
|
|
||||||
auto inputState = device.CreateInputStateBuilder()
|
auto inputState = device.CreateInputStateBuilder()
|
||||||
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32G32B32, 0)
|
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32G32B32, 0)
|
||||||
.SetAttribute(1, 0, nxt::VertexFormat::FloatR32G32B32, 3 * sizeof(float))
|
.SetAttribute(1, 0, nxt::VertexFormat::FloatR32G32B32, 3 * sizeof(float))
|
||||||
|
@ -278,7 +287,7 @@ void init() {
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
.SetStage(nxt::ShaderStage::Fragment, fsReflectionModule, "main")
|
||||||
.SetInputState(inputState)
|
.SetInputState(inputState)
|
||||||
.SetDepthStencilState(reflectionStencilState)
|
.SetDepthStencilState(reflectionStencilState)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
@ -294,8 +303,8 @@ void frame() {
|
||||||
static const uint32_t vertexBufferOffsets[1] = {0};
|
static const uint32_t vertexBufferOffsets[1] = {0};
|
||||||
|
|
||||||
cameraData.view = glm::lookAt(
|
cameraData.view = glm::lookAt(
|
||||||
glm::vec3(10.f * std::sin(glm::radians(s.b * 360.f)), 2.f, 10.f * std::cos(glm::radians(s.b * 360.f))),
|
glm::vec3(8.f * std::sin(glm::radians(s.b * 360.f)), 2.f, 8.f * std::cos(glm::radians(s.b * 360.f))),
|
||||||
glm::vec3(0.0f, -1.0f, 0.0f),
|
glm::vec3(0.0f, 0.0f, 0.0f),
|
||||||
glm::vec3(0.0f, 1.0f, 0.0f)
|
glm::vec3(0.0f, 1.0f, 0.0f)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ namespace opengl {
|
||||||
|
|
||||||
void HACKCLEAR() {
|
void HACKCLEAR() {
|
||||||
glClearColor(0, 0, 0, 1);
|
glClearColor(0, 0, 0, 1);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glStencilMask(0xff);
|
||||||
glClearStencil(0);
|
glClearStencil(0);
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(void* (*getProc)(const char*), nxtProcTable* procs, nxtDevice* device) {
|
void Init(void* (*getProc)(const char*), nxtProcTable* procs, nxtDevice* device) {
|
||||||
|
|
Loading…
Reference in New Issue