Jump to content

Unity3D to Babylon Exporter and skybox/cubemaps...


exc_html5
 Share

Recommended Posts

Howdy Babylonians! 

When I used the unity3d to babylon exporter it currently takes my cubemap and exports it out to a series of JPGs for the different faces of the cubemap. I would like to have use PNG files instead. I can fix this on the exporter side fairly easily by switching the command to from 

File.WriteAllBytes(faceTexturePath, tempTexture.EncodeToJPG());

to 

File.WriteAllBytes(faceTexturePath, tempTexture.EncodeToPNG());

and then also changing the output naming convetion from

  case CubemapFace.NegativeZ:
                            faceTexturePath += "_nz.jpg";

to 

  case CubemapFace.NegativeZ:
                            faceTexturePath += "_nz.png";

When I change these it makes the PNG and names them correctly, but the exported BJS scene doesn't read in the reflection textures correctly. Here is what it looks like when I export the JPG version:

reflections_correct.png

What it looks like when I switch everything over to PNGs 

reflections_wrong.png

When I load the scene into the babylon sandbox it says " [15:15:49]: Error while trying to load texture: file:ReflectionProbe-0_pz.jpg "

So it's still looking for the jpgs insted of the PNGs. Here are the settings for the shader:

{
			"name" : "babylonjs_sample_material_reflection",
			"id" : "fb8dec12-8352-4e22-8ec5-83008b1780c1",
			"backFaceCulling" : true,
			"wireframe" : false,
			"ambient" : [1, 1, 1],
			"diffuse" : [0, 0, 0, 1],
			"specular" : [1, 1, 1, 1],
			"emissive" : [0, 0, 0, 1],
			"specularPower" : 53.588665,
			"alpha" : 1,
			"diffuseTexture" : null,
			"diffuseFresnelParameters" : null,
			"ambientTexture" : null,
			"opacityTexture" : null,
			"opacityFresnelParameters" : null,
			"reflectionTexture" : {
				"name" : "ReflectionProbe-0",
				"level" : 1,
				"hasAlpha" : false,
				"getAlphaFromRGB" : false,
				"coordinatesMode" : 3,
				"isCube" : true,
				"uOffset" : 0,
				"vOffset" : 0,
				"uScale" : 1,
				"vScale" : 1,
				"uAng" : 0,
				"vAng" : 0,
				"wAng" : 0,
				"wrapU" : 1,
				"wrapV" : 1,
				"coordinatesIndex" : 0,
				"isRenderTarget" : false,
				"renderTargetSize" : 0,
				"mirrorPlane" : null,
				"renderList" : null,
				"animations" : null
			},
			"reflectionFresnelParameters" : null,
			"emissiveTexture" : null,
			"emissiveFresnelParameters" : null,
			"specularTexture" : null,
			"bumpTexture" : null
		}

Is there a way I can adjust the unity exporter code to have it look for the PNGs that were created instead? Or if not is there a way to alter the shader settings after the fact to have it look for the PNGs?

Link to comment
Share on other sites

Hey!

unfortunately we try to load jpg only by default:

https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/Textures/babylon.cubeTexture.ts#L32

BUT there is a good news :D

You can add the extensions you want to use in the .babylon file:

https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/Textures/babylon.cubeTexture.ts#L79

So add a "extensions" property under your reflectionTexture entry in your json file and set its value to: ["_px.png", "_py.png", "_pz.png", "_nx.png", "_ny.png", "_nz.png"]

 

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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