Commit Graph

3738 Commits

Author SHA1 Message Date
52e5a15bab - Separates displace from Var slider. Added Disp Slider to
control how the intensity channel affects displacement.  Nor
	  slider still controls how Nor channel affects displacement.

	- Scaled Nor displacement to make Nor slider more usable.

	- Removed Data scale from displacement routines.  Made
	  sliders unusable for objects scaled in editmode.  Displacement
	  now relative to unit sized object.  Displace still tracks
	  with object scale, so scale out of editmode if you want a
	  large object with deep displacement.
2004-01-15 04:06:24 +00:00
5190faf513 - fix for speedup raytracing, which gave errors in very simple scenes
(1 lamp, shadow). The 'coherence' check gets reset now for each new
  pixel rendered, which remains efficient for oversampling.
- small cleanups in code, prototype added, less globals.
2004-01-14 20:13:41 +00:00
3e84e66078 fix for tracker report on crashing border render in unified render.
it is related to the fix for 2.31, wich disabled hackish feature of
 inserting the previous render outside border. i forgot the unified has
 this code entirely duplicated, something to get rid of one day...
2004-01-14 14:30:59 +00:00
0d6533a48f fix for bug that caused transparant shadow change how a texture
rendered itself. this happened when transparent shadow ray hit a face
 with same material as where ray started.

 is this understandable? i guess not! :P
 the actual fix is just a few lines, to store material locally before
 going to trace transp shadow.
2004-01-13 22:49:11 +00:00
fac8a7027d - fix for cubemap, rendered without render face available.
currently only for preview render and displaylist. It then uses the
  provided texture coordinate itself...
  Solution is not perfect... disadvantage of not having globals! then
  you have to fix all mess! :)
2004-01-11 22:15:24 +00:00
63f1e17fe5 - tex->nor was not reset to zero for lamp texture. this caused weird thing
to happen when you use lamp textures with material textures.
  Bug provided by aphex, thanks!
2004-01-11 20:58:12 +00:00
bbe7d8d08e - Better fake for displace preview. 2004-01-11 00:39:17 +00:00
3406d3a939 - Displacement now allows use of either Var or Nor slider. Nor uses
texture's Nor channel, Var uses intensity channel.
2004-01-10 23:00:52 +00:00
b5071f367d Improved method to calculate normals for procedural textures such as
Marble, wood, clouds. Instead of the retarded (but faster :) old method
it now derives the normal based on displacement of a 'nabla' vector;
sampling the texture additionally with three little offsets in x, y and z.

Code provided by Eeshlo, and gratefully accepted!
2004-01-10 12:41:47 +00:00
aba8ca4440 From Eeshlo: fixed bug with dupliverted lamps not exporting. Also now it
skips envmaps, octree and radiosity when yafray is enabled.
2004-01-09 08:31:23 +00:00
71597eb061 - Corrected scale factor to be independant of object
rotation.  (Still not right, but better).
2004-01-08 14:19:25 +00:00
f0821decff Left over work from localizing renderdata!
- when quads get split before render, the vertexcolors and texture face
  (UV) info has to be corrected as well. This happens runtime during
  render, no new data is created. The code was in previous versions, but
  with raytrace and other new features it needed a rewrite
- this now also should work for the new smart split code from robert!
2004-01-07 21:44:09 +00:00
f2f514d1d4 Fix for cube map error subsurf.
- cubemap relied on pointer to MFace, which is only available for Mesh
  when directly converted to renderfaces.
  It then checked the 'puno' flag where also bits were set to indicate
  the optimal projection for a face (XY, XZ or YZ).
- I found out the renderface also has a puno flag, so the mface pointer
  in a renderface is redundant. Is removed now
- added code in texture cubemap call, which checks on a projection flag
  in 'puno'. If not set, it uses the orco's to calculate one.
- this means, that cubemap now also works for other objects than meshes,
  provided they have an orco block while render.
- if no orco block available, it uses the 'global' projection to find which
  of the cube sides map.

I couldnt find other errors with subsurf & orco though...
2004-01-07 20:29:21 +00:00
d54699bb45 - Added UV mapping to displacement. 2004-01-07 14:31:58 +00:00
e4d0d9cc44 - decided to use a new variable for the new exposure option, instead of
re-using old one. New one = 'exp'.
- at first I used the old 'exposure' value, and just mapped it to 0. this
  causes a problem with upward compatibility, old blenders then render a
  black picture. is too confusing!
- warning; exposure values saved with commit of last week will get lost.
2004-01-06 20:25:50 +00:00
deafae4286 - displacement 'map to' channel now has three values, to allow to negate
the effect as well.
2004-01-05 23:33:22 +00:00
cea53c6473 - previewrender with mapping type "Cube" didnt show correctly.
added fake 'face normal' for this case
2004-01-05 21:18:47 +00:00
1170f5f6ed Displacement map
- changed code to make use of actual textures, not the hackish
  'externtex', which is only for tools
- added a 'displacement' vector in ShadeInput, and moved calculation of
  displacement vector to texture.c itself. So it works with stencil, but
  also for options as 'add', 'mult' and 'sub'.
- for RGB textures it uses the brightness value of color for displace
- for stucci, and plugin textures returning a normal, it uses that

- Also: wrote call in end of preparing renderfaces, to split non-flat
  quad faces in triangles. gives a lot fewer errors in displace textures,
  but also raytracing irregular subsurfs goes better now.

- texture mapping that works for displace: orco, sticky, global, obj, normal.
  UV not yet. Reflection-displace? uhh! :)
2004-01-05 20:25:07 +00:00
a017282b62 Tweaks to get yafray stuff working with Makefiles
Kent
2004-01-05 17:42:07 +00:00
092c6fd1bb Yafray export code moved to source/blender/yafray to keep blender/src pure C
code. Now all the cpp code is in intern under yafray and the api include
file is just plain C

Also changed old include in initrender.c and updated Makefiles.am and configure.ac
so the new dirs are taken into account.
2004-01-05 14:53:56 +00:00
eff07b8329 Basic initial yafray integration by Eeshlo.
Materials are exported the best we can do by now. It will look almost as in
blender except for the missing procedural textures and some minor issues.
You have to tweak normal modulation amount to get the desired result cause
is not the same in yafray.

We added a panel in render space to adjust some yafray settings (GI and so)

Also we export transparency and reflection using new raytracing settings,
but that will be changed and improved soon.

Remember that you have to set YFexport path in user defaults and yafray must
be on path (version 0.0.6)

We added the "yafray" button to activate all this stuff in the render window.
Panel and settings are only shown when checked.

So now when activated the code calls yafray export instead of the internal
renderer and finally the resulting image is loaded back into render window's
buffer. So animation is also possible and results can be saved using blender
usual scheme.
2004-01-04 22:10:36 +00:00
dbce416607 - oren nayar call didnt return float value... but still worked on my
system, and gcc refuses to see it as warning. weirdos!
  this caused previewrender to show black for oren nayar.
2004-01-04 21:32:50 +00:00
03fe244b58 - changed calculus for area light to use double precision. Using float
already gave noise with area size of 0.1.
  Limited buttons to minimum value of 0.01 for area light. For people
  who want smaller they can scale it down in 3d, effectively reducing
  the energy then as well.
2004-01-04 13:27:18 +00:00
d8b21b01c3 Added improved exposure calculation
- based at 1.0-exp(-color) trick in Yafray. But to guarantee backwards
  compatibility, and some more control, Stefano Selleri hacked a useful
  formula for it.
- We now have 2 values to set:
  - "exp": the exponential correction value (0-1)
  - "range": the light range that maps on color 1.0 (0-5)
- Using exp(x) (is e^x) we can much better prevent overflows from render,
  which are currently hard-clipped in Blender. Setting a small 'exp' value
  wil efficiently smooth out high energy and map that back to a color for
  display.
- total formula:
  newcol= linfac*(1.0-exp(col*logfac))
    col, newcol are colors
  linfac= 1.0 + 1.0/((2.0*wrld.exp +0.5)^10)
  logfac= log( (linfac-1.0)/linfac )/wrld.range
    wrld.exp and wrld.range are the button values
- default setting: exp=0.0 and range=1.0 give results extremely close to
  previous rendering.
- graph: http://www.selleri.org/Blender/buffer/Image1.png  for 'exp' setting
  ranging from 0-1, and with 'range'=2

Thanks Stefano for the help!
2003-12-30 18:03:37 +00:00
7d7fd069fc - fix for area light versus oren-nayer shading.
oren-nayer was of course of not built for area-lights... so probably
  Cessen will kill me for this hack. Nice challenge for him to come with
  better solution. Visually it works & looks fine.
2003-12-30 00:04:22 +00:00
cf9ce09074 - forgot to clip negative values coming from arealight formula.
- excluded 'dist' factor calculus from arealamps, which caused too much
  distance sensitivity
2003-12-29 21:32:03 +00:00
5004432333 - fixed crashing texture plugin, caused by not checking the tex->nor
pointer.
  Now variables are localized, this is not always set anymore.
2003-12-29 20:05:15 +00:00
3ce1dc9065 Area lights and more...
- New lamp type added "Area". This uses the radiosity formula (Stoke) to
  calculate the amount of energy which is received from a plane. Result
  is very nice local light, which nicely spreads out.
- Area lamps have a 'gamma' option to control the light spread
- Area lamp builtin sizes: square, rect, cube & box. Only first 2 are
  implemented. Set a type, and define area size
- Button area size won't affect the amount of energy. But scaling the lamp
  in 3d window will do. This is to cover the case when you scale an entire
  scene, the light then will remain identical
  If you just want to change area lamp size, use buttons when you dont want
  to make the scene too bright or too dark
- Since area lights realistically are sensitive for distance (quadratic), the
  effect it has is quickly too much, or too less. For this the "Dist" value
  in Lamp can be used. Set it at Dist=10 to have reasonable light on distance
  10 Blender units (assumed you didnt scale lamp object).
- I tried square sized specularity, but this looked totally weird. Not
  committed
- Plan is to extend area light with 3d dimensions, boxes and cubes.
- Note that area light is one-sided, towards negative Z. I need to design
  a nice drawing method for it.

Area Shadow

- Since there are a lot of variables associated with soft shadow, they now
  only are available for Area lights. Allowing spot & normal lamp to have
  soft shadow is possible though, but will require a reorganisation of the
  Lamp buttons. Is a point of research & feedback still.
- Apart from area size, you now can individually set amount of samples in
  X and Y direction (for area lamp type 'Rect'). For box type area lamp,
  this will become 3 dimensions
- Area shadows have four options:
  "Clip circle" : only uses a circular shape of samples, gives smoother
  results
  "Dither" : use a 2x2 dither mask
  "Jitter" : applys a pseudo-random offset to samples
  "Umbra" : extra emphasis on area that's fully in shadow.

Raytrace speedup

- improved filling in faces in Octree. Large faces occupied too many nodes
- added a coherence check; rays fired sequentially that begin and end in
  same octree nodes, and that don't intersect, are quickly rejected
- rendering shadow scenes benefits from this 20-40%. My statue test monkey
  file now renders in 19 seconds (was 30).

Plus:

- adjusted specular max to 511, and made sure Blinn spec has again this
  incredible small spec size
- for UI rounded theme: the color "button" displayed RGB color too dark
- fixed countall() function, to also include Subsurf totals
- removed setting the 'near' clipping for pressing dot-key numpad
- when you press the buttons-window icon for 'Shading Context' the context
  automaticilly switches as with F5 hotkey

Please be warned that this is not a release... settings in files might not
work as it did, nor guaranteed to work when we do a release. :)
2003-12-29 16:52:51 +00:00
da0e131b16 - improved filling in faces in octree, resulting in less nodes and
branches. Especially larger faces give result. Rendering times go down
  with an average of 10%. My reference testfile went down from 30.4 to
  27.9 seconds.
2003-12-24 19:05:38 +00:00
b3911687ee - only cosmetic stuff; result of going over the output of mipspro cc
compile round. Wrong prototypes, unused variables, zealot const usage,
  and in action.c fixed insane & unreadable function call syntax.
2003-12-24 11:44:57 +00:00
8fbff1a3b7 - Fresnel V4.0
Based on feedback (thnx phase!) I found a big disadvantage of the 'real'
fresnel formula. It doesnt degrade to 0.0, causing 2-3 times too many
rays being fired compared to the previous one. So; a lot slower.

Now committed is a hybrid which allows (close to) real, and nice artistic
freedom, *and* it really goes to 0.0 and 1.0, assisting nicely in optimal
render times.
A real doc how it works (with pics) will be made before real release.

- Fixed bug in raytrace: the first renderpass didn't use fresnel for mirror.
- Fixed bug in previewrender, now it closer matches how fresnel renders
2003-12-23 22:31:48 +00:00
454166026a - another fresnel improvement. :)
At last irc meeting, eeshlo pointed to an error in the code. It didn't
  use the IOR value correctly. This has been solved. So how it works now:
  - the IOR button value influences (very subtle) the fresnel effect.
    Only for realism diehards.
  - the Fresnel value (slider) now denotes the power in the function
    rf + (1-rf) * (1-c)^5
    where rf= rf = ((ior-1)/(ior+1))^2
    and c the dot-product ray/normal.
  - so, set the slider at '5' and you have real fresnel. Lower values
    for interesting artistic effects.

- put back the forgotten code for gaussian corrected sampling during
  antialising render. Normally, each sub-pixel sample in Blender counts
  equally, and together make up the pixel color.
  With 'Gauss' option set (F10 menu) each sub-pixel sample creates a small
  weighted mask with variable size, which (can) affect neighbouring pixels
  as well. The result is smoother edges, less sensitive for gamma, and
  well suited to reduce motion-aliasing (when things move extreme slow).
  This is result of *long* period of research in NeoGeo days, and based on
  every scientific sampling/reconstructing theory we could find. Plus a
  little bit of our selves. :)

- I should write once how blender constructs Jitter tables for sub-sampling.
  this is a very nice method, and superior to normal block filter or random
  jittering... time!
2003-12-22 22:27:51 +00:00
ec99255c27 Phew, a lot of work, and no new features...
Main target was to make the inner rendering loop using no globals anymore.
This is essential for proper usage while raytracing, it caused a lot of
hacks in the raycode as well, which even didn't work correctly for all
situations (textures especially).

Done this by creating a new local struct RenderInput, which replaces usage
of the global struct Render R. The latter now only is used to denote
image size, viewmatrix, and the like.

Making the inner render loops using no globals caused 1000s of vars to
be changed... but the result definitely is much nicer code, which enables
making 'real' shaders in a next stage.
It also enabled me to remove the hacks from ray.c

Then i went to the task of removing redundant code. Especially the calculus
of texture coords took place (identical) in three locations.
Most obvious is the change in the unified render part, which is much less
code now; it uses the same rendering routines as normal render now.
(Note; not for halos yet!)

I also removed 6 files called 'shadowbuffer' something. This was experimen-
tal stuff from NaN days. And again saved a lot of double used code.

Finally I went over the blenkernel and blender/src calls to render stuff.
Here the same local data is used now, resulting in less dependency.
I also moved render-texture to the render module, this was still in Kernel.
(new file: texture.c)

So! After this commit I will check on the autofiles, to try to fix that.
MSVC people have to do it themselves.
This commit will need quite some testing help, but I'm around!
2003-12-21 21:52:51 +00:00
0060be6603 More render stuff:
- added 'Mapping to" channel "RayMirror", to control mirror with texture
- fixed bug in using mirror-rgb as texture channel... this is cumbersome
  because it is abused by Envmap in a not nice way. Fixing the abuse will
  cause compatibility errors, which can be fixed when we up release # to
  2.32.

- added "Translucency", which is nothing else than allowing another
  shading pass for the backside of a face (with normal inverted). This
  is interesting for all kinds of situations where you want light from
  behind to 'shine through'. Also works to reduce dark areas in
  unlighted parts of rendering transparent faces. Light from behind on
  transparent red window should make it glowing some, right?!
- added texture channel for this as well

- Reorganized Material Panels to reveil some consistancy where buttons
  can be found. Not perfect yet, but at least all options for Shaders and
  options for Mirror & Transparency now are together.
  This gives some space in Shader Panel for nice expansion.
2003-12-19 15:23:12 +00:00
cb20f1cdb4 another trace commit
- implemented tracing of transparency for shadows. This is a material
  option, in the new RayTrace panel.
  it only traces color and alpha, not shading. So the results of some
  transparant colored unlit faces can look odd. I will look onto that.
- changed fresnel formula (got hint from eeshlo!). this simplifies the UI,
  now only one button needed. The fresnel value "should" be identical as
  the refraction index, but that is booooring! So i added a special fresnel
  refraction slider for both mirroring and transparency. By setting all 3
  sliders equal, you get 'realism'.
- fresnel for transparancy works for Ztra rendering too. Same for transpa-
  rent shadow. But then you need to set 'ray' on in F10 menu.
- uploaded new monkey_glass blend in download.blender.org/demo/test/

Next stage: killing the globals from render, and implement "translucency"
which is effectively allowing faces being lit from behind, as paper or
cloth.
2003-12-18 21:34:48 +00:00
064297009c - shadeless rendering fixed!
error was due to new localized render result code... and of course only
  shading and tracing was tested :)
2003-12-16 16:07:46 +00:00
97d4dbc9c3 Another commit for raytracing, now with glass refraction & fresnel!
Changelog:

- enable refraction with button "Ray Transp" in Material buttons.
- set "Angular Index" value for amount of refraction.
- use the "Alpha" value to define transparency.
- remember to set a higher "Depth" too... glass can bounce quite some
  more than expected.
- for correct refraction, 3D models MUST have normals pointing in the
  right direction (consistently pointing outside).
- refraction 'sees' the thickness of glass based on what you model. So
  make for realistic glass both sides of a surface.

- I needed to do some rewriting for correct mirroring/refraction,
  especially to prevent specularity being blended away.
  Solved this with localizing shading results in the rendercore.c.
  Now specularity correctly is added, and reduces the 'mirror' value.
- Localizing more parts of the render code is being planned. The old
  render heavily relies on struct Render and struct Osa to store globals.
  For scanline render no problem, but recursive raytracing dislikes that.

- done test with gamma-corrected summation of colors during tracing, is
  commented out still. But this will give more balanced reflections. Now
  dark reflections that are reflected in a bright surface seem incorrect.

- Introduced 'Fresnel' effect for Mirror and Transparency. This
  influences the amount of mirror/transparency based at viewing angle.
  Next to a new Fresnel slider, also a 'falloff' button has been added to
  define the way it spreads.
- Fresnel also works for Ztransp rendering

- created new Panel for Raytrace options
  I have to evaluate still where it all should be logically located.
- material preview shows fake reflection and fake refraction as well.
2003-12-16 14:12:01 +00:00
d0159a9879 - another fix, to make sure radio colors work local during tracing...
this will be quite a lot of reconstruction, if i want to go for
  refraction, caustics, pathlights, etc... :/
2003-12-12 23:40:35 +00:00
b2357b5bc6 - fix for error caused by last commit... colors changed by textures
during raytracing were 'hanging' and showing up in the first rendered
  material.
2003-12-12 23:04:05 +00:00
55c3082c6b - fix for AA of mirroring.
It appeared that the Osa vectors for view vector, and for rendered coord
  had an opposite sign...
2003-12-12 15:03:01 +00:00
7ea1d94032 - removed call to bzero, replaced with memset
(bzero seems to be old, not supported anymore, also not for windows)
- think I fixed the error compiling in Irix, for a correct cast now
  (added parentheses around the subject for cast)
- changed call to ray_mirror, now included in the shading loop, just
  before the addition happens for specular. That way specular is added
  over mirroring. This changes the appearance quite some!
2003-12-12 11:28:33 +00:00
71770977f2 - fix for error in octree traverse code, as appeared in sample provided
by Ztonzy. Error happened when:
  - ray intersects in first node of traversal
  - next ray should intersect in same first node as well
  - no other nodes were accessed inbetween
  It's a bit hard to explain! But the reason is in the optimize code
  in top of ocread() function, where binary XOR magic speeds up. Here
  some static variables needed a reset.
2003-12-11 16:28:04 +00:00
1bfa43da53 Fixes in ray.c for linking under windows (seems lie bzero doesn't exist).
Shouldn't affect other platform if I did it correctly.
2003-12-11 04:08:49 +00:00
a18cc02374 - Xmas special: shiny mirroring bells & whistles!
This is a revision of the old NeoGeo raytracer, dusted off, improved quite
a lot, and nicely integrated in the rest of rendering pipeline.
Enable it with F10-"Ray", and set either a 'ray-shadow' lamp or give the
Material a "RayMirror" value.
It has been added for 2 reasons:
- get feedback on validity... I need artists to play around with it if it's
  actually useful. It still *is* raytracing, meaning complex scenes will
  easily become slow.
- for educational purposes. All raytracing happens in ray.c, which can be
  quite easily adjusted for other effects.

When too many disasters pop up with this, I'll make it a compile #ifdef.
But so far, it seems to do a decent job.

Demo files: http://www.blender.org/docs/ray_test.tgz
An article (tech) about how it works, and about the new octree invention
will be posted soon. :)

Note: it doesn't work with unified render yet.
2003-12-10 20:41:53 +00:00
e9d9a7282e All related to unified render:
- fixed bug in halo rendering combined with spothalo
- fixed bug in no antialiasing with sky with spothalo
- cleaned some weird usage of gamma for spothalo and sky
  (when rendering sky + spothalo, sky got gamma corrected
- removed old test code and #ifdefs for code readability

On test scenes here unified render looks much better. still some minor
issues with antialiasing... cant pin that down yet.
2003-11-12 20:43:01 +00:00
3a7dc92cd6 - bug fix: alpha wrong in unified render halos with lines or rings 2003-11-12 15:07:04 +00:00
7be1d02919 - bug fix #304
Wire rendering gave errors with parts.
  This due to the fact the lines are clipped exactly at the pixel
  centers of the image edge. For polys (triangles) that works fine, but
  in wireframe you see the lines ending at the edge.

  Solved by adjusting clipping routine for wires just a tinsy bit.
2003-11-08 16:57:23 +00:00
96403dc309 - fix bug #294
removed some code of someone in NaN who tried to fix
  prototypes... just solved by introducing a correct cmat[3][3] instead
  of using weird new matrix code.
2003-11-08 14:41:56 +00:00
c04eb56983 - removed hack in initrender code that allowed 'border render' in a
previously rendered image. it was just screwing up memory in some cases.
  for it to work quite more elaborate coding is needed.
- when selecting border in camera view (SHIFT+B) the associated render
  option is set automatic
- fixed some mallocs to become callocs in renderloop, to prevent garbish
  when border rendering
- also enables closing bug #179
2003-11-08 12:50:40 +00:00
21c2e8f74f - fixed bugreport intrr about shadeless UV texture face having wrong
brightness... it had one multiplication too many...

- found 3 month old error: the fix i committed for ESC during render
  was undone partially by a commit from guignot one week later. I already
  *thought* ESC reacted so slow... but i had fixed it, not!? :-)

  Now its still fast and instantly reacts to ESC again.
2003-11-07 19:23:13 +00:00