fix shader issue on mac

This commit is contained in:
samcake 2015-06-27 06:34:58 -07:00
parent 61ea59d63b
commit 1b69b38835
3 changed files with 23 additions and 23 deletions

View file

@ -12,27 +12,27 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
varying vec2 varTexcoord;
void main(void) {
const vec4 UNIT_QUAD[4] = vec4[4](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4(1.0, -1.0, 0.0, 1.0),
vec4(-1.0, 1.0, 0.0, 1.0),
const vec4 UNIT_QUAD[4] = vec4[4](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4(1.0, -1.0, 0.0, 1.0),
vec4(-1.0, 1.0, 0.0, 1.0),
vec4(1.0, 1.0, 0.0, 1.0)
);
vec4 pos = UNIT_QUAD[gl_VertexID];
// standard transform but applied to the Texcoord
vec4 tc = vec4((pos.xy + 1) * 0.5, pos.zw);
TransformObject obj = getTransformObject();
<$transformModelToWorldPos(obj, tc, tc)$>
gl_Position = pos;
varTexcoord = tc.xy;
// standard transform but applied to the Texcoord
vec4 tc = vec4((pos.xy + 1) * 0.5, pos.zw);
TransformObject obj = getTransformObject();
<$transformModelToWorldPos(obj, tc, tc)$>
gl_Position = pos;
varTexcoord = tc.xy;
}

View file

@ -129,7 +129,7 @@ uniform mat4 transformCamera_viewInverse;
<$worldPos$> = (<$objectTransform$>._model * <$modelPos$>);
}
<@else@>
<$worldPos$> = vec3(transformObject_model * <$modelPos$>);
<$worldPos$> = (transformObject_model * <$modelPos$>);
<@endif@>
<@endfunc@>

View file

@ -644,12 +644,12 @@ void DeferredLightingEffect::render(RenderArgs* args) {
model.postRotate(spotRotation);
model.postTranslate(glm::vec3(0.0f, 0.0f, -light->getMaximumRadius() * (1.0f + SCALE_EXPANSION * 0.5f)));
float base = expandedRadius * glm::tan(light->getSpotAngle());
float base = expandedRadius * glm::tan(light->getSpotAngle());
float height = expandedRadius;
model.postScale(glm::vec3(base, base, height));
batch.setModelTransform(model);
auto& mesh = getSpotLightMesh();
auto mesh = getSpotLightMesh();
batch.setIndexBuffer(mesh->getIndexBuffer());
@ -935,11 +935,11 @@ void DeferredLightingEffect::setGlobalSkybox(const model::SkyboxPointer& skybox)
}
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
if (!_spotLightMesh) {
_spotLightMesh.reset(new model::Mesh());
int slices = 32;
int stacks = 1;
if (!_spotLightMesh) {
_spotLightMesh.reset(new model::Mesh());
int slices = 32;
int stacks = 1;
int vertices = (stacks + 2) * slices;
int baseTriangles = slices - 2;
int indices = 6 * slices * stacks + 3 * baseTriangles;