Commit Graph

12014 Commits

Author SHA1 Message Date
Sergey Sharybin 3d36489672 OpenSubdiv: Commit of OpenSubdiv integration into Blender
This commit contains all the remained parts needed for initial integration of
OpenSubdiv into Blender's subdivision surface code. Includes both GPU and CPU
backends which works in the following way:

- When SubSurf modifier is the last in the modifiers stack then GPU pipeline
  of OpenSubdiv is used, making viewport performance as fast as possible.

  This also requires graphscard with GLSL 1.5 support. If this requirement is
  not met, then no GPU pipeline is used at all.

- If SubSurf is not a last modifier or if DerivesMesh is being evaluated for
  rendering then CPU limit evaluation API from OpenSubdiv is used. This only
  replaces the legacy evaluation code from CCGSubSurf_legacy, but keeps CCG
  structures exactly the same as they used to be for ages now.

This integration is fully covered with ifdef and not enabled by default
because there are several TODOs to be solved first:

- Face varying data interpolation is not really cleanly implemented for GPU
  in OpenSubdiv 3.0. It is also not implemented for limit evaluation API.

  This basically means we'll have really hard time supporting UVs.

- Limit evaluation only works with adaptivly subdivided meshes so far, which
  basically means all the points of CCG are pushed to the limit. This gives
  different result from old code.

- There are some serious optimizations possible on the topology refiner
  creation, which would speed up initial OpenSubdiv mesh creation.

- There are some hardcoded asumptions in the GPU and DerivedMesh areas which
  could be generalized.

  That's something where Antony and Campbell can help, making it so the code
  is structured in a way which is reusable by all planned viewport projects.

- There are also some workarounds in the dependency graph to make sure OpenGL
  buffers are only freed from the main thread.

Those who'll be wanting to make experiments with this code should grab dev
branch (NOT master) from

  https://github.com/Nazg-Gul/OpenSubdiv/tree/dev

There are some patches applied in there which we're working on on getting
into upstream.
2015-07-20 22:29:26 +02:00
Sergey Sharybin 2466c4f8ce OpenSubdiv: Add OpenSubdiv files which are related on the CCGSubSurf and GPU
Those files are still not in use (SCons will tyr to compile new CCGSubSurf files
but no code will be in use at all because those new files are fully wrapped by
ifdef WITH_OPENSUBDIV check).
2015-07-20 22:29:25 +02:00
Sergey Sharybin ccc3c2dbda CCGSubSurf: Split file into several smaller ones
This is a preparation commit for having OpenSubdiv integrated into Blender
and new layout is the following:

- CCGSubSurf.c contains implementation of common functions used by both
  legacy subdivisions code and by the new code in the future.

- CCGSubSurf_inline.h contains internal functions which are to be inlined
  due to the performance reasons. Those functions are only ment to be used
  bu CCGSubSurf* files.

- CCGSubSurf_intern.h contains declarations of private functions and data
  structures used by CCGSubSurf module.

- CCGSubSurf_legacy.c contains legacy implementation of subdivision algorithm.

- CCHSubSurf_util.c contains utility functions which are not directly related
  on the subdivision code (i.e. debug functions, hash implementation etc).

There should be no functional changes so far.
2015-07-20 22:29:25 +02:00
Bastien Montagne a4a3d5650d Minor optimization in CustomData_update_typemap(). 2015-07-20 17:28:29 +02:00
Bastien Montagne 9ee1f96a0f Fix (unreported) potential serious bug in CustomData_merge().
It was always only using the flags from the first source layer of a given type, not from
the layer actually being handled.

This was (probably) more or less harmless for the CD_FLAG_NOCOPY test,
but could be really bad when checking CD_FLAG_NOFREE, and when
copying the flags over to new copied data!
2015-07-20 16:25:01 +02:00
Antonis Ryakiotakis cb6fc9d141 Use abstraction to unbind buffers, should avoid crashes in systems that
don't support VBOs.

Exposed by initialization error in GLEW, which should be fixed
seperately.
2015-07-20 12:12:28 +02:00
Campbell Barton 05ee9d2dd0 Minor edits for consistency 2015-07-20 17:07:40 +10:00
Campbell Barton e58d788340 Cleanup: style
Also 'com' as abbreviation for center-of-mass is a bit confusing, rename to 'center'.
2015-07-20 05:30:08 +10:00
Antonis Ryakiotakis 23a4f547e7 Convert rigidbody conversion to looptri.
Patch D1417 by Martin Felke, with minor edits thanks!
2015-07-19 19:10:41 +02:00
Antonis Ryakiotakis a597a380bb Properly fix T45477
Code was actually skipping setting color selection indices and previous
commit actually broke mask selection in texture painting.
All should work now.
2015-07-19 18:35:09 +02:00
Sergey Sharybin 9b40616249 Cycles: Point density texture support
This commit implements point density texture for Cycles shading nodes.

It's done via creating voxel texture at shader compilation time, Not
totally memory efficient, but avoids adding sampling code to kernel
(which keeps render time as low as possible), In the future this will
be compensated by using OpenVDB for more efficient storage of sparse
volume data.

Sampling of the voxel texture is happening at blender side and the
same code is used as for Blender Internal's renderer.

This texture is controlled by only object, particle system and radius.
Linear falloff is used and there's no turbulence. This is because
falloff is expected to happen using Curve Mapping node. Turbulence
will be done as a distortion on the input coordinate. It's already
possible to fake it using nose textures and in the future we can add
more proper turbulence distortion node, which then could also be used
for 2D texture mapping.

Particle color support is done by Lukas, thanks!
2015-07-18 22:49:10 +02:00
Campbell Barton 2ad3a1d41e Use gpu-buffers for UV-edge drawing 2015-07-18 23:51:44 +10:00
Campbell Barton ecb3e0fe73 Cleanup: whitespace & break placement 2015-07-18 19:03:22 +10:00
Campbell Barton 3e83a0d92d Cleanup: ws 2015-07-18 06:01:38 +10:00
Campbell Barton 32f7b4a358 Avoid getting the original index if its not needed 2015-07-18 04:57:58 +10:00
Antonis Ryakiotakis e6711119f2 Absent-mindedness...Remove testing code 2015-07-17 19:13:22 +02:00
Antonis Ryakiotakis 712098b1c8 Fix GLSL code not working correctly for Macs without VBO, again report
by scorpion81 on irc
2015-07-17 19:12:24 +02:00
Bastien Montagne c1290e441e Fix T45469: Vertex Group weight = 0.0 in scene 2. 2015-07-17 18:49:58 +02:00
Antonis Ryakiotakis 3a15ec337e Fix issue reported by scorpion81 on irc: material mode + flat shading
artifacts in cycles textured mode.
2015-07-17 18:30:40 +02:00
Campbell Barton d4c0617496 Avoid accessing MTFace drawing subsurf 2015-07-17 23:52:41 +10:00
Antonis Ryakiotakis 955c13d614 Fix another index error, made multimaterial mapped meshes draw
incorrectly.
2015-07-17 15:15:53 +02:00
Antonis Ryakiotakis 7c06167982 Change winding of looptris in subsurf so they point to the same
direction as the surface.
2015-07-17 14:56:10 +02:00
Campbell Barton e1606e8c87 Don't create MFace's when calculating normals
Instead only create MFace layer when its requested
2015-07-17 21:59:07 +10:00
Antonis Ryakiotakis c23d29c58e Fix T45465
Easy one, we don't draw quads anymore. Also normal
didn't use polygon index
2015-07-17 13:27:46 +02:00
Antonis Ryakiotakis 1b8e0d03d4 Fix no longer being possible to display a suzanne with 8 levels of
subdivision.

Classic integet overflow/size_t substitution case. Machines are getting
powerful enough to easily expose these kinds of error now.
2015-07-17 12:25:44 +02:00
Bastien Montagne 37017d149e Let's use proper helpers for debug-only vars... 2015-07-17 12:19:57 +02:00
Sergey Sharybin 4052384be3 Make strict flags happy in release builds 2015-07-17 09:54:21 +02:00
Campbell Barton 40936307dd Remove MTFace DM_paint_uvlayer_active_get func 2015-07-17 04:26:17 +10:00
Campbell Barton 67acde92bb Fix for error in looptri commit
Sculpting w/ subsurf crashed
2015-07-17 04:22:24 +10:00
Campbell Barton 9d090c4717 Split ray_face_intersection into quad/tri versions
Since many callers only need a single triangle
2015-07-17 04:15:24 +10:00
Campbell Barton 595a491e63 Add tessellation data to DerivedMesh (LoopTri)
This stores loop indices into the loop array giving easier acess
to data such as vertex-colors and UV's,
removing the need to store an MFace duplicate of custom-data.

This doesn't yet move all internal code from MFace to LoopTri just yet.

Only applies to:
- opengl drawing
- sculpting (pbvh)
- vertex/weight paint

Thanks to @psy-fi for review, fixes and improvements to drawing!
2015-07-17 03:55:14 +10:00
Bastien Montagne 2fe9224375 Fix T45459: Edge Length with Separate Units Displayed As 1m 100cm.
Our 'unit epsilon' was too small, given the fact we only display up to four digits usually...
2015-07-16 17:45:51 +02:00
Sergey Sharybin 4feef7d4f8 Fix for the previous commit: overallocation of an array 2015-07-16 17:26:20 +02:00
Sergey Sharybin 247d922ce5 Fix T45446: Crash when baking a certain object
Issue was caused by deform vert layer existing in the mesh.
Solved in quite simple way, but it still might be missing
some other layers.

Any custom data experts around to check if it's correct?
2015-07-16 17:25:13 +02:00
Antonis Ryakiotakis 3e3e7ee41c Sculpt draw code:
Remove legacy code completely, now dyntopo, multires et al even work on
GL 1.1 for really hardcore users :p

Real purpose here though is to be able to have fast multires drawing
even with VBO off, since it requires using indices for vertex buffers.

Also made own code elf puke an eaten normal update function which
made multires not update normals in solid mode...sorry.
2015-07-16 17:12:03 +02:00
Antonis Ryakiotakis 13c39e90b3 VBO offscreen selection drawing, cdderivedmesh
Get rid of legacy drawing, it's only used for selection,
    in which case we can prepare a temporary color buffer and draw
    at once. Code is not complete here because we still redundantly
    set the draw color in the draw function and don't ommit hidden
    faces automatically. Still it works 100% without immediate mode
    now.
2015-07-15 18:50:02 +02:00
Antonis Ryakiotakis 32c6d92cb0 Fix T45439 crash with subsurf when many materials present.
Silly oversight on the viewport patch
2015-07-15 14:58:10 +02:00
Campbell Barton 4143b8a6c7 Fix autosmooth with recent DM optimizations
Also avoid multiple float->short conversions for the same normal.
2015-07-15 14:34:56 +10:00
Campbell Barton 72c7e12a5d DerivedMesh: minor changes to callback use
- use void instead of float for array arg (cast in the switch statement)
- remove unused args
- use const for poly-mapping and user_data args
2015-07-15 12:42:41 +10:00
Campbell Barton 7407ed7637 Cleanup: ws 2015-07-15 12:08:32 +10:00
Campbell Barton 52fa5b12e1 Cleanup: ws 2015-07-15 11:43:23 +10:00
Antonis Ryakiotakis dfd383ca00 Fix overdrawing and errors with textured and mapped drawing 2015-07-14 23:49:03 +02:00
Antonis Ryakiotakis 107e34407d Display optimizations part 1.
This patch changes the way we draw meshes by introducing
indexed drawing. This makes it possible to easily
upload and rearrange faces ad lib according to any criteria.

Currently we use material sorting but textured sorting and
hiding will be added to optimize textured drawing and skip
per face testing.

It also adds support for vertex buffers for subsurf
modifiers (Except from GLSL drawing), making drawing of
subsurf much faster without need for bogus modifiers.

Tests show that we gain approximately 20-25% performance
by that for solid mode drawing with up to 50% gains for
material drawing. Textured drawing should also have a
small performance gain, but more substantial optimizations
are possible there.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D1406
2015-07-14 16:48:23 +02:00
Campbell Barton 1b8b9063f8 Correct last commit 2015-07-14 23:37:11 +10:00
Campbell Barton 0918461d61 Move from MTFace to MTexPoly w/ texture checks
Part of moving away from MFace.
2015-07-14 22:36:00 +10:00
Campbell Barton 2cffd6649b Match face tessellation order in edimode
add a negated version of axis_dominant_v3_to_m3
2015-07-14 22:29:31 +10:00
Bastien Montagne 6ba4a917a3 Data Transfer: very minor cleanup... 2015-07-14 11:13:56 +02:00
Sergey Sharybin 85004461ea Workaround for non-bleeding edge compilers and const cast of pointer arrays. 2015-07-14 09:56:00 +02:00
Campbell Barton b7c42ef93e Cleanup: use ascii as suffix (as with utf8) 2015-07-14 09:17:00 +10:00
Campbell Barton 2de497eee0 BKE_deform: assert on invalid args
Will phase these out eventually
2015-07-14 08:41:15 +10:00