Skip to content

Commit

Permalink
Merge pull request #267 from AnalyticalGraphicsInc/ao-shader-fix
Browse files Browse the repository at this point in the history
Fix AO shader
  • Loading branch information
mramato authored Apr 13, 2017
2 parents 6914f5f + 5928501 commit a371945
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Change Log
==========

### 0.1.0-alpha12 - 2017-04-13
* Fixed issue with ambient occlusion not working correctly with other stages.

### 0.1.0-alpha11 - 2017-03-07
* Added `compressTextures` stage to compress input textures to a variety of compressed texture formats.
* Optimized `mergeBuffers` to avoid repeated copies, drastically improving performance when there are lots of buffers to merge.
Expand Down
10 changes: 5 additions & 5 deletions lib/bakeAmbientOcclusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ function extractInstructionWithFunctionCall(options) {
var functionName = options.functionName;
var functionArguments = options.functionArguments;
var functionArgumentsLength = functionArguments.length;
var sourceString = options.shader.extras._pipeline.source.toString();
var sourceString = options.shader.extras._pipeline.source;
var instructions = sourceString.trim().split(/~|;|{|}/); // split not by whitespace but by ;, {, and }
var instructionCount = instructions.length;

Expand Down Expand Up @@ -515,7 +515,7 @@ function injectGlslAfterInstructionContaining(options) {
var lines = options.lines;
var snippet = options.snippet;

var sourceString = shader.extras._pipeline.source.toString();
var sourceString = shader.extras._pipeline.source;
var sourceStringLength = sourceString.length;
// Locate the instruction containing the snippet. Find the nearest `;`
var snippetIndex = sourceString.indexOf(snippet);
Expand All @@ -531,7 +531,7 @@ function injectGlslAfterInstructionContaining(options) {
newSourceString += sourceString.substring(instructionEndIndex, sourceStringLength);

// Repack into source
shader.extras._pipeline.source = new Buffer(newSourceString);
shader.extras._pipeline.source = newSourceString;
}

function editShader(options) {
Expand All @@ -540,7 +540,7 @@ function editShader(options) {
var mainNewName = options.mainNewName;
var commandsForNewMain = options.commandsForNewMain;

var sourceString = shader.extras._pipeline.source.toString();
var sourceString = shader.extras._pipeline.source;
// Wrap main
sourceString = ShaderSource.replaceMain(sourceString, mainNewName);
var newSourceString = '';
Expand All @@ -555,7 +555,7 @@ function editShader(options) {
newSourceString +='}';

// Repack into source
shader.extras._pipeline.source = new Buffer(newSourceString);
shader.extras._pipeline.source = newSourceString;
}

////////// adding to the gltf by texture //////////
Expand Down
2 changes: 1 addition & 1 deletion specs/lib/bakeAmbientOcclusionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ describe('AmbientOcclusion', function() {
};

injectGlslAfterInstructionContaining(options);
var newSource = shader.extras._pipeline.source.toString();
var newSource = shader.extras._pipeline.source;
expect(newSource).toEqual('function(arg0, arg1, arg2, arg3, innerArg0) {' +
'command(arg3);' +
'otherCommand(arg0);' +
Expand Down
2 changes: 1 addition & 1 deletion specs/lib/processModelMaterialsCommonSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ describe('processModelMaterialsCommon', function() {
var program = gltfClone.programs[technique.program];
expect(program.attributes.indexOf('a_batchid') > -1).toBe(true);

var vertexShaderSource = gltfClone.shaders[program.vertexShader].extras._pipeline.source.toString();
var vertexShaderSource = gltfClone.shaders[program.vertexShader].extras._pipeline.source;
expect(vertexShaderSource.indexOf('a_batchid') > -1).toBe(true);
});

Expand Down

0 comments on commit a371945

Please sign in to comment.