Blender HAIR for Lux

Discussion related to the 'LuxBlend' Blender 2.4+ python exporter script.

Moderators: Ratow, SATtva, coordinators

Blender HAIR for Lux

Postby jensverwiebe » Thu Nov 12, 2009 10:15 am

Hi

I start now an attempt to render Hair-particles in Lux:

Proposal:

Exporter gets strands + values from Blender and after this triangulagion happens along the pathes ( in core for better speed )
Code so far, staring after particle-dups in line 293 ff.

Code: Select all
                ##### HAIR ##### Jens Verwiebe

                if (psys.type == Particle.TYPE['HAIR'] and psys.drawAs == Particle.DRAWAS['PATH']):
                    print("Hair detected, get Material from Slot")
                    try:
                        psys.getMat()
                        pmat = psys.getMat()
                        if pmat.strandBlendUnit:                  #Blender units
                            strandSTART = pmat.strandStart
                            strandEND = pmat.strandEnd
                        else:                                               # pixels
                            strandSTART = pmat.strandStart/100
                            strandEND = pmat.strandEnd/100
                        print("StrandStart-Thickness", strandSTART)
                        print("StrandEnd-Thickness", strandEND)
                    except:
                        # No material in list, set a default value
                        pmat = "default"
                        strandSTART = 0.01
                        strandEND = 0.01
                        print("StrandStart-Thickness-default", strandSTART)
                        print("StrandEnd-Thickness-default", strandEND)
                    loc = psys.getLoc()
                    for path in psys.getLoc():
                        print ("path-length", len(path), loc) # path is 2^render +1, loc the coordinates of segments

etc.

Thats what i have for now. You see what i mean ?

In core i would need support from other dev´s to calculate ( extrude) tris along the pathes.

Found deeper api-doku here: http://www.zoo-logique.org/3D.Blender/scripts_python/API/Material-pysrc.html


Jens
Last edited by jensverwiebe on Thu Nov 12, 2009 4:29 pm, edited 4 times in total.
User avatar
jensverwiebe
Developer
 
Posts: 2358
Joined: Wed Apr 02, 2008 4:34 pm

Re: Blender HAIR for Lux

Postby Dade » Thu Nov 12, 2009 10:31 am

jensverwiebe wrote:In core i would need support from other dev´s to calculate ( extrude) tris along the pathes.


Jens, isn't better to use the Lux's cylinder primitive ? It probably going to be faster to render, better to look and to use even less memory than 2 triangles. We can even thing to a dedicated Shape for this task in order to optimize memory usage and/or rendering speed (I assume Hair support is a quite important feature so it could be worth doing).
User avatar
Dade
Developer
 
Posts: 6021
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: Blender HAIR for Lux

Postby jensverwiebe » Thu Nov 12, 2009 11:02 am

@ Dade

You are right, but LordCRC told me we can´t use cylinder.

A dedicated shape would be a nicer solution then.

Atm, i look how i can generate the pathes for export and
if we need smoohing for such shape.


Jens
User avatar
jensverwiebe
Developer
 
Posts: 2358
Joined: Wed Apr 02, 2008 4:34 pm

Re: Blender HAIR for Lux

Postby jeanphi » Thu Nov 12, 2009 11:54 am

Hi,

Actually it would have to be cones because the diameter can vary (and we have cones). However to get a smooth shape, we need to be able to cut the cylinders/cones with planes that aren't perpendicular to the main axis which isn't possible right now, but the primitives could be improved upon...
The last issue would then be to get smooth normals around the transitions from one segment to the next.
We could also implement a hair primitive, it shouldn't be that hard to do.

Jeanphi
jeanphi
Developer
 
Posts: 7314
Joined: Mon Jan 14, 2008 7:21 am

Re: Blender HAIR for Lux

Postby Lord Crc » Thu Nov 12, 2009 3:03 pm

From the discussion last night Jens said they were extruded along a path. I don't know the limitations of this path, so I assumed they could be curved. In that case it would be hard to use a cylinder/cone shape (well at least more work than just generating tris).
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4932
Joined: Sat Nov 17, 2007 2:10 pm

Re: Blender HAIR for Lux

Postby jensverwiebe » Thu Nov 12, 2009 3:16 pm

Just for info, here´s a console print from 1 hair 1 segment:
Code: Select all
Hair detected, get Material from Slot
('StrandStart-Thickness', 1.5641282796859741)
('StrandEnd-Thickness', 0.5473865270614624)
('path-length', 2, [[(-0.053809907287359238, -0.059643018990755081, 0.51084423065185547), (-0.60408580303192139, -2.6486234664916992, -0.065362453460693359)]])


..so thats what you would get out by this:

Another: same but rendersteps/segments set to 3 ( 2^3 + 1 ):
Code: Select all
('StrandStart-Thickness', 1.5641282796859741)
('StrandEnd-Thickness', 0.5473865270614624)
('path-length', 9, [[(-0.053809907287359238, -0.059641499072313309, 0.51084423065185547), (-0.30756962299346924, -0.35764396190643311, 0.82123219966888428), (-0.51753664016723633, -0.64408713579177856, 1.0686863660812378), (-0.61057412624359131, -1.1320774555206299, 1.1000545024871826), (-0.42567461729049683, -1.4386444091796875, 0.79477345943450928), (-0.29232412576675415, -1.6803159713745117, 0.52809661626815796), (-0.52830749750137329, -2.1318032741546631, 0.54858756065368652), (-0.85768139362335205, -2.3174984455108643, 0.78347140550613403), (-1.1904432773590088, -2.4722509384155273, 1.0353869199752808)]])


Clear ?

Jens
User avatar
jensverwiebe
Developer
 
Posts: 2358
Joined: Wed Apr 02, 2008 4:34 pm

Re: Blender HAIR for Lux

Postby jeanphi » Thu Nov 12, 2009 3:21 pm

Hi,

The added benefit of using triangles is that you'll automatically get a hierarchy of bounding boxes instead of a single huge bounding box.

Jeanphi
jeanphi
Developer
 
Posts: 7314
Joined: Mon Jan 14, 2008 7:21 am

Re: Blender HAIR for Lux

Postby Atom » Thu Nov 12, 2009 3:26 pm

Have you seen this link?
http://blenderartists.org/forum/showthr ... ve+to+mesh

I stumbled across this the other day while trying to get Lux to export groups instead of just object. The Effects api has been depreciated and moved into the Particle object.
http://www.blender.org/documentation/24 ... odule.html
Lux v1.0 OpenCL (64 Bit)
Blender 2.49.2
Python 2.6.3
Windows XP64Bit SP2, nVidia 460GTX 1Gb
User avatar
Atom
 
Posts: 362
Joined: Wed Jun 17, 2009 8:34 pm
Location: Ohio

Re: Blender HAIR for Lux

Postby e_jackson » Thu Nov 12, 2009 4:19 pm

Hi everyone!

@jensverwiebe:
How do you going to handle the following problem: if alpha is going to zero, then |A_2 C_2|/|A_1 C_1| tends to infinity.
Angle.jpg
e_jackson
 
Posts: 58
Joined: Thu Jul 03, 2008 5:44 pm
Location: Kyiv, Ukraine

Re: Blender HAIR for Lux

Postby Dade » Thu Nov 12, 2009 4:45 pm

We could use a paraboloids or hyperboloids for segments and a sphere on each conjunction between segment and segment (faster to render, less memory usage, etc.).

We can could introduce a new shape "Hair" that accept directly the information posted by Jens and refine that object in hyperboloids/spheres (or whatever we want). I'm talking of using the Shape::Refine method (we don't need to implement any new intersection code or whatever).

P.S. Paraboloids/Hyperboloids are some of the most unused primitive ever but we got them from PBRT (PBRT book pag. 118).
User avatar
Dade
Developer
 
Posts: 6021
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Next

Return to LuxBlend (Blender Exporter)

Who is online

Users browsing this forum: No registered users and 1 guest