-
Notifications
You must be signed in to change notification settings - Fork 25
-
Hello
Is it possible to get access to the glsl shader code generated in shaderpark for rendering. For exemple to use this shader in another software ?
Thanks a lot for this great job/
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Hi,
Yes is it possible.
If you just want to quickly see generated glsl snippets from code on the website you can add
console.log(geoSrc) console.log(colorSrc)
at the end of your shader, which will print glsl to the console.
However if you want to render these snippets somewhere else you will also need the rest of the shader boilerplate code.
The most proper way to generate all the glsl needed is to use the shader-park-core library functions like
sculptToGLSL
, uniformsToGLSL
, *Header
ect.
Using these functions it's actually possible to integrate shader park into any 3D application you want!
You can see examples of this in the targets folder.
These show how to use the library to convert and assemble shaderpark code into all the necessary glsl to make it run in another application.
For example see:
https://github.com/shader-park/shader-park-core/blob/master/targets/minimalRenderer.js#L39
import { sculptToGLSL, baseUniforms, uniformsToGLSL usePBRHeader, useHemisphereLight, sculptureStarterCode, minimalHeader, minimalVertexSource, fragFooter, } from 'shader-park-core' ... function generateFullFragment(source) { const generatedGLSL = sculptToGLSL(source); const fullFrag = minimalHeader + usePBRHeader + useHemisphereLight + uniformsToGLSL(generatedGLSL.uniforms) + 'const float STEP_SIZE_CONSTANT = ' + generatedGLSL.stepSizeConstant + ';\n' + 'const int MAX_ITERATIONS = ' + generatedGLSL.maxIterations + ';\n' + sculptureStarterCode + generatedGLSL.geoGLSL + '\n' + generatedGLSL.colorGLSL + '\n' + fragFooter; return fullFrag; }
Where all glsl pieces are generated and assembled into a final fragment shader.
We would love to have a proper tutorial/documentation for this process in the future!
Beta Was this translation helpful? Give feedback.