fix the color blending on Mac

This commit is contained in:
samcake 2015-05-11 17:27:22 -07:00
parent e6bba04151
commit 449ca6df6d
2 changed files with 24 additions and 22 deletions

View file

@ -53,7 +53,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
static gpu::BufferPointer theBuffer; static gpu::BufferPointer theBuffer;
static gpu::Stream::FormatPointer theFormat; static gpu::Stream::FormatPointer theFormat;
static gpu::BufferPointer theConstants; static gpu::BufferPointer theConstants;
const int SKYBOX_CONSTANTS_SLOT = 3; int SKYBOX_CONSTANTS_SLOT = 0; // need to be defined by the compilation of the shader
if (!thePipeline) { if (!thePipeline) {
auto skyVS = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(Skybox_vert))); auto skyVS = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(Skybox_vert)));
auto skyFS = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(Skybox_frag))); auto skyFS = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(Skybox_frag)));
@ -61,12 +61,15 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
gpu::Shader::BindingSet bindings; gpu::Shader::BindingSet bindings;
bindings.insert(gpu::Shader::Binding(std::string("cubeMap"), 0)); bindings.insert(gpu::Shader::Binding(std::string("cubeMap"), 0));
bindings.insert(gpu::Shader::Binding(std::string("skyboxBuffer"), SKYBOX_CONSTANTS_SLOT));
if (!gpu::Shader::makeProgram(*skyShader, bindings)) { if (!gpu::Shader::makeProgram(*skyShader, bindings)) {
} }
SKYBOX_CONSTANTS_SLOT = skyShader->getBuffers().findLocation("skyboxBuffer");
if (SKYBOX_CONSTANTS_SLOT == gpu::Shader::INVALID_LOCATION) {
SKYBOX_CONSTANTS_SLOT = skyShader->getUniforms().findLocation("skyboxBuffer");
}
auto skyState = gpu::StatePointer(new gpu::State()); auto skyState = gpu::StatePointer(new gpu::State());
thePipeline = gpu::PipelinePointer(gpu::Pipeline::create(skyShader, skyState)); thePipeline = gpu::PipelinePointer(gpu::Pipeline::create(skyShader, skyState));

View file

@ -15,25 +15,24 @@
<$declareStandardTransform()$> <$declareStandardTransform()$>
struct Skybox { struct Skybox {
vec4 _color; vec4 _color;
}; };
<@if GPU_FEATURE_PROFILE == GPU_CORE @> <@if GPU_FEATURE_PROFILE == GPU_CORE @>
uniform skyboxBuffer { uniform skyboxBuffer {
Skybox _skybox; Skybox _skybox;
}; };
Skybox getSkybox() { Skybox getSkybox() {
return _skybox; return _skybox;
} }
<@else@> <@else@>
uniform vec4 skyboxBuffer[1]; uniform vec4 skyboxBuffer[1];
Skybox getSkybox() { Skybox getSkybox() {
Skybox _skybox; Skybox _skybox;
_skybox._color = skyboxBuffer[0]; _skybox._color = skyboxBuffer[0];
return _skybox;
return _skybox; }
}
<@endif@> <@endif@>
varying vec3 normal; varying vec3 normal;