Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

export shader file #73

Cdriko started this conversation in Ideas
Discussion options

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/

You must be logged in to vote

Replies: 1 comment

Comment options

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!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /