lizhao21st / jsc3d

Automatically exported from code.google.com/p/jsc3d
0 stars 0 forks source link

How can i add more lightness to the obj render result (obj+mtl) #99

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. loading a obj file with mtl (mtl all using colors Kd value instead of using 
textures(jpg, png)
2. no mater how i modify mtl params, can not see apparent lightness changes.
3. even set Kd in mtl to  1 1 1 , render result in "texture flat" still grey 
color;

What is the expected output? What do you see instead?
   Expected output should become lighter when i set params of mtl to bigger value;
   when debuging, 
   I set most mtl parameter to 1,  
   ka ks kd all to 1 1 1, Ns 1000, illum mode test from 0 - 10 
   in "textureflat" mode, no lightness effect (even kd 1 1 1 render in grey color instead of pure white color in other 3d IDEs. )

What version of the product are you using? On what operating system?
current version download from jsc3d website

Please provide any additional information below.

Can u give some hints to add lightness of the material. 

i tried adding all possible parameters under each material file (not working)
newmtl 1
Ka 1.00000 0.85490 0.06275
Kd 1.00000 0.85490 0.06275
Ks 0.00000 0.00000 0.00000
#adding new parameters
Ns 1000.00000
illum 3   #0 to 10 
Ks 1 1 1  #override
Tf 1 1 1

Original issue reported on code.google.com by haibo...@solstice.sg on 13 Aug 2014 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago
// additional information, below is the js part setting  when i load the obj, 
// there must be some light control instead of changing the mtl Kd value right?

    var canvas = document.getElementById('cv');
    var viewer = new JSC3D.Viewer(canvas);
    viewer.setParameter('SceneUrl', 'myobj.obj');
    viewer.setParameter('InitRotationX', 0);
    viewer.setParameter('InitRotationY', 0);
    viewer.setParameter('InitRotationZ', 0);
    //viewer.setParameter('ModelColor', '#CAA618');
    //viewer.setParameter('ModelColor', '#ffffff');
    viewer.setParameter('BackgroundColor1', '#B9EBFF');
    viewer.setParameter('BackgroundColor2', '#DFF6FF');
    viewer.setParameter('RenderMode', 'textureflat');
    viewer.setParameter('MipMapping', 'on');
    viewer.setParameter('Renderer', 'webgl');
    viewer.init();
    viewer.update();

Original comment by haibo...@solstice.sg on 13 Aug 2014 at 4:10

GoogleCodeExporter commented 9 years ago
As you can see in current implementation of the mtl parser 
http://code.google.com/p/jsc3d/source/browse/trunk/jsc3d/jsc3d.js#5273, only 
'Kd' commands are effective. Both 'Ka' and 'Ks' are simply ignored. If Kd was 
set to 1 1 1, the affected facets will be completely white when they are facing 
the viewing directin unbiasedly. Otherwise, the facest will be gray. The final 
color of a fragment equals to the material color multiplied by the transformed 
z value of its normal vector.

I'm afraid there's no way to control the lighting. In fact, there's not a 
'light' in the rendering pipeline. The final colors are computed from the 
material colors, the texel colors and the normal vectors.  The result may looks 
slightly different from that from other tools. That's what it is.

Original comment by Humu2...@gmail.com on 14 Aug 2014 at 3:00

GoogleCodeExporter commented 9 years ago
Thank you for your immediate reply. 
Great Author, i really like reading the way you explain to every post.
Thank you so much anyway, That greatly saved my time on trying those invalid 
parameters, and now I will try all possible methods you mentioned. 

by the way is there any plugin js that can be fully compatible to integrate 
with jsc3d so as to control lighting features? (the attached file has option 
that loads jsc3d obj)

Original comment by haibo...@solstice.sg on 14 Aug 2014 at 3:37

Attachments:

GoogleCodeExporter commented 9 years ago
My pleasure :-)

At this moment Jsc3d just adopts a very basic rendering pipeline. After all, it 
begins with software only rendering that is expected to work on some old 
browsers with acceptable performance. Though it is not difficult to implement 
advanced features with WebGL and shader tricks, the compatibility with software 
rendering is considered to be important for this project.

As far as I know, the project you mentioned only uses parts of Jsc3d, to be 
exact, the obj loader and the mesh structure. The author wrote his own 
implementation for the rendering pipeline with several impressive features such 
as ray tracing, etc.

Original comment by Humu2...@gmail.com on 14 Aug 2014 at 4:28