Open LeeMcQueen opened 3 years ago
■grasses.h
■grasses.cpp grasses.update() 里面直接插入 grassShadowMap
■grassesComputerShader
■grassesVertexShader
首先需要实验的就是 layout(set = 0, binding = 0) uniform CameraBufferObject { mat4 view; mat4 proj; } camera; 传输
■grassesFragmentShader
■main 需要给shader传输 1.光相机的viewMatrix 2.光相机的OrthoMatrix 3.ShadowFBO的阴影遮罩图
1&2 设定
unsigned int lightCameraUniformBuffer = 0; glGenBuffer(1, &lightCameraUniformBuffer); glBindBuffer(GL_UNIFORM_BUFFER, lightCameraUniformBuffer); glBufferData(GL_UNIFORM_BUFFER, 128, nullptr, GL_STATIC_DRAW); glBindBufferBase(GL_UNIFORM_BUFFER, 4, lightCameraUniformBuffer);
1&2 循环内运行 glm::mat4 grassLightViewMatrix = shadowMapCamera.getViewMatrix(); glm::mat4 grassLightProjectionMatrix = masterRenderer.getProjectionMatrix(false);
glBindBufferBase(GL_UNIFORM_BUFFER, 0, lightCameraUniformBuffer); glBindBuffer(GL_UNIFORM_BUFFER, lightCameraUniformBuffer); glBufferSubData(GL_UNIFORM_BUFFER, 0, 64, &grassLightViewMatrix); glBufferSubData(GL_UNIFORM_BUFFER, 64, 64, &grassLightProjectionMatrix);
■grasses.h
■grasses.cpp grasses.update() 里面直接插入 grassShadowMap
■grassesComputerShader
■grassesVertexShader
首先需要实验的就是 layout(set = 0, binding = 0) uniform CameraBufferObject { mat4 view; mat4 proj; } camera; 传输
■grassesFragmentShader
■main 需要给shader传输 1.光相机的viewMatrix 2.光相机的OrthoMatrix 3.ShadowFBO的阴影遮罩图
1&2 设定
unsigned int lightCameraUniformBuffer = 0; glGenBuffer(1, &lightCameraUniformBuffer); glBindBuffer(GL_UNIFORM_BUFFER, lightCameraUniformBuffer); glBufferData(GL_UNIFORM_BUFFER, 128, nullptr, GL_STATIC_DRAW); glBindBufferBase(GL_UNIFORM_BUFFER, 4, lightCameraUniformBuffer);
1&2 循环内运行 glm::mat4 grassLightViewMatrix = shadowMapCamera.getViewMatrix(); glm::mat4 grassLightProjectionMatrix = masterRenderer.getProjectionMatrix(false);
glBindBufferBase(GL_UNIFORM_BUFFER, 0, lightCameraUniformBuffer); glBindBuffer(GL_UNIFORM_BUFFER, lightCameraUniformBuffer); glBufferSubData(GL_UNIFORM_BUFFER, 0, 64, &grassLightViewMatrix); glBufferSubData(GL_UNIFORM_BUFFER, 64, 64, &grassLightProjectionMatrix);