Jump to content

Smoothing polygons / phong angle


Flomotion
 Share

Recommended Posts

Hi,

I've created a box that should have flat shading (see box-good). But it displays in babylon as a shaded box.

The model is distorted by bones.

I tried

mesh.convertToFlatShadedMesh();

but there's no difference. Are there any other ways to get rid of the shaded polygons? Or is there a way to adjust the phong angle in babylonjs?

I really really hope so.. because the model is useless now.

Thanks!

box-shaded.jpg

box-good.jpg

Link to comment
Share on other sites

I don't know how to load an external file into the playground.. I use

BABYLON.SceneLoader.ImportMesh("", "http://flomotion.nl/cloudlab/cup/assets/", "cup.babylon", scene, function (newMeshes) {
        // Set the target of the camera to the first imported mesh
        camera.target = newMeshes[0];
    });

but nothing happens. It's stuck at 'loading assets..

Link to comment
Share on other sites

Hello 

I have absolutely no idea whats the answer to your question is.

First of all you have to allow Crossorgin at your server. 

I created a playground for you for experimenting just to get started.
I use googledrive coz i get used to it, but you can use any sharing service.(whit crossorgin)

You should also check from time to time if your browser gives you some error messages. Press F12 (red text - not good).

http://www.babylonjs-playground.com/#1BCGCE#2

Have Fun

P.S 3,86Mb for a single cup -  is a full playable game level. 

crossorgin.JPG

Link to comment
Share on other sites

test this source that use shaderbuilder :

mesh.material = new BABYLONX.ShaderBuilder()
			.Light({phonge:1.5,direction:'vec3(100.)',normal:BABYLONX.Normals.Flat})
            .InLine('float l1 = length(result.xyz);')
			.Map({ path:'/textures/ground.jpg' })
			.InLine('result = vec4(result.xyz*max(.2,l1),1.);')
			.BuildMaterial(scene); 

http://www.babylonjs-playground.com/#4XFH7#0  with light : x:100,y:100,z:100

http://www.babylonjs-playground.com/#4XFH7#1 for light from camera position

 

this should be work 

Link to comment
Share on other sites

8 hours ago, Flomotion said:

I don't know how to load an external file into the playground.. I use

BABYLON.SceneLoader.ImportMesh("", "http://flomotion.nl/cloudlab/cup/assets/", "cup.babylon", scene, function (newMeshes) {
        // Set the target of the camera to the first imported mesh
        camera.target = newMeshes[0];
    });

but nothing happens. It's stuck at 'loading assets..

didn't work for me.

also i want not so spend too much of my time on this, reload the file to my website was, the fastest solution.

Best

@adam send me a link with a good tutorial how to share files on one drive so their are accessible to the playground. i have tried it, but it didn't work. i think i have 5gb left.

Link to comment
Share on other sites

@Flomotion

Hello

You have to add (at least) one loop cut at your model. 

See my 100kB example, if you convert the mesh to flatshadet (see code: chage to "useFlatShading":true) you will notice their are 2lines, mostly not visible, but they are their.

Press Debug Layer you see i have 900 vertices, if i want not get rid of the 2 lines, i have to add more loopcuts this will look much better, but i will run the same model (shape) at 10200 vertices (mean: much more computer power).

 As long this element is only a subelement, i can live with those two lines. also if i add color or textures, nobody will recognize those two lines. But still at some vertices count no graphic engine will ever gives you more then you put it. less in, less out.

So i hope to share my experience, will help u.

Best   

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