Jump to content

[SOLVED] - Embedding ShaderMateral Programs in .babylon


Recommended Posts

IF ITS NOT ALREADY IN BABYLON.JS (and i just don't see it)

Can we embed vertex and fragment programs in the .babylon file on the 'materal' object of the material customType="BABYLON.ShaderMaterial"


			"customType" : "BABYLON.ShaderMaterial",
			"name" : "Items",
			"id" : "dadbe3ae-445f-4fe4-b83f-000b27b2b8d4",
			"backFaceCulling" : true,
			"wireframe" : false,
			"alpha" : 1,
			"shaderPath" : "Items",
			"options" : {
				"attributes" : [
				"uniforms" : [
				"needAlphaBlending" : false,
				"needAlphaTesting" : false,
				"samplers" : [],
				"defines" : []
			"textures" : {},
			"floats" : {},
			"floatArrays" : {},
			"colors3" : {},
			"colors4" : {},
			"vectors2" : {},
			"vectors3" : {},
			"vectors4" : {},
			"matrices" : {},
			"matrices2x2" : {},
			"matrices3x3" : {}

Can we add somewhere in a 'base64' encoded string for the shader programs... Something like:

"vertexBase64" : "*** BASE64 ENCODED VERTEX PROGRAM ***",

"fragmentBase64" : "*** BASE64 ENCODED FRAGMENT PROGRAM ***",

Then in the client side Material parser... If we got base64 parsdedMaterial data with our programs already there... no need to make TWO separate server trips to get our shader programs... plus the shader programs are then cached when storing .babylon files in indexedDB. Also it can easily work with sandbox and just drag that single .babylon file to sandbox (ONCE sandbox get the PR fix to use BABYLON.ShaderMaterial vertexBase64 and fragmentBase64) then folks custom shaders will work on the sandbox... Right now if you have BABYLON.ShaderMaterial defined in your .babylon file (and don't use a qualified path) the server will never find or use them (unless you know where those files end up after posting to server and are available ... still would hard code sandbox path to shader program in your .babylon file.).. For some reason if don't use path and just name... it looks in '/src/Sharder/myShader.vertex.fx'

Anyways I'm going to play with the github Material.Parse stuff to use material.vertexBase64 and fragmentBase63 IF PRESENT... After i had them to the ShaderMaterial class...

Hope you guys like this idea ... That last one to get metadata added seems like a tough sell... I hope you consider this...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...