Initial transfer of larger repo from git. IF full history and branches are needed must go to github at https://github.com/DulcisL/CCUCoding.git
This commit is contained in:
commit
c09ce40be0
4048 files changed
+603256
No files matched your search
+49
@@ -0,0 +1,49 @@
|
||||
import { Return, VariableDeclaration, Accessor } from './AST.js';
|
||||
import GLSLDecoder from './GLSLDecoder.js';
|
||||
|
||||
class ShaderToyDecoder extends GLSLDecoder {
|
||||
|
||||
constructor() {
|
||||
|
||||
super();
|
||||
|
||||
this.addPolyfill( 'iTime', 'float iTime = time;' );
|
||||
this.addPolyfill( 'iResolution', 'vec2 iResolution = screenSize;' );
|
||||
this.addPolyfill( 'fragCoord', 'vec3 fragCoord = vec3( screenCoordinate.x, screenSize.y - screenCoordinate.y, screenCoordinate.z );' );
|
||||
|
||||
}
|
||||
|
||||
parseFunction() {
|
||||
|
||||
const node = super.parseFunction();
|
||||
|
||||
if ( node.name === 'mainImage' ) {
|
||||
|
||||
node.params = []; // remove default parameters
|
||||
node.type = 'vec4';
|
||||
node.layout = false; // for now
|
||||
|
||||
const fragColor = new Accessor( 'fragColor' );
|
||||
|
||||
for ( const subNode of node.body ) {
|
||||
|
||||
if ( subNode.isReturn ) {
|
||||
|
||||
subNode.value = fragColor;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
node.body.unshift( new VariableDeclaration( 'vec4', 'fragColor' ) );
|
||||
node.body.push( new Return( fragColor ) );
|
||||
|
||||
}
|
||||
|
||||
return node;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ShaderToyDecoder;
|
||||
Reference in new issue
Block a user