Shadows

  • Uploaded by: maria
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Shadows as PDF for free.

More details

  • Words: 2,525
  • Pages: 16
SUNFLOW SHADERS and MODIFIERS The Sunflow raytracer has many shaders, and here I'll explain a little bit about accessing these shaders through manually editing the .sc file. A shader block looks like this shader { name shadername type } 'shader' tells the renderer that this is a shader. The shader is contained in the following '{ }' Where the purple text is, is where the shader's name is defined. It is up to the user to choose a name for the shader. 'type' defines the shader type. After this, but before the last '}' are other parameters the vary depending on the shader type. Now below is an object block. object { shader shadername type generic-mesh name "Plane" points 8 -4.25819396973 -4.8784570694 5.70054674149 -5.13696432114 -5.61583280563 4.06224298477 -6.422539711 -4.08374404907 4.06224298477 -5.54376888275 -3.34636831284 5.70054721832 triangles 2 012 023 } Right after 'shader' it says 'shadername'. This means it's linked to the shader thats named 'shadername'. So there, you would put the name of the shader you wish to link to your mesh object. Now for the shader types and how are they specified in Blender to be exported.

SHADER

CONDITION TO BE EXPORTED

Diffuse

Material's name start with “sfdiffuse”

AO (Ambient Occlusion)

Material's name start with “sfambocc”

Glass

Material's name start with “sfglass” and Raytransp button ON

Mirror

Material's name start with “sfmirror” and Raymirror button ON

Phong

Material's name start with “sfphong”

Ward

Material's name start with “sfward”

Shiny

Material's name start with “sfshiny”

Constant Janino

Material's name start with “sfconstant” Doesn't export from Blender (yet)

In case you forget to call your material a Sunflow meaningful name, or you call it “sfglass_01” and forget to turn “Raytransp button” ON, your shader is exported as a constant green color with some luminosity, for better visual help.

DIFFUSE Below is an example of what the Diffuse shader looks like.

And here is what the shader block looks like. shader { name shadername type diffuse diff 1 .5 .5 } To access this shader, input 'diffuse' into the shader type. This is a simple shader. Just a soft, single colored, material. Just like what you have in blender, by default, only without specularity. Specularity is just a simulation of the light sources reflection, and because Sunflow is aiming at realism, this just wont do. This shader doesn't have many options. Just color, which is controlled by the 3 digits after 'diff'. 1 being a color value of 255, or FF in hexadecimal, and 0 being 000 or 00 in hexadecimal. and the digits control RED GREEN and BLUE, in that order. So '1 .5 .5' is 100% red and 50% green and blue. This would give us a red, similar to the middle one in the example picture above. It is wise to keep the colors below 1. If you do go above 1, it may get brighter than needed. As an example, see the last column of spheres in the example picture. Notice how the green one is almost a solid color, with no shading at all. If this is what you want, however, there are better ways to go about doing this. I'll cover that later.

Blender export implementation: name: a material name started with “sfdiffuse” diff: this values are the Blender diffuse RGB color values

AO (Ambient Occlusion) Below is an example of what the AO shader looks like

And what the shader block looks like shader { name shadername type amb-occ2 bright 1 0 1 dark 0 0 0 samples 200 dist 2 } To access, simply set the shader type to 'amb-occ2' , or 'amb-occ', they both make the same shader. 'bright' adjusts the color. In the code above, it would create a magenta object, like the floor in the example picture. 'dark' is the shadow color. In this case, black. 'samples' control the quality of AO. As you can see, the ground is quite smooth at 200 samples. But the sphere on top is quite grainy with samples at 2. 'dist' is best described with pictures. The floor in the above picture, 'dist' is at 2. Lets drop it down to 1 and see what happens...

Now look at the shadows on the ground. The shadows aren't as spread out as in the first image. This isn't all that noticeable, so lets put 'dist' down farther. Lets try .4.

Now the effect is more noticeable. 0 'dist' doesn't remove the shadow, but this:

As you might have guessed, this shader looks like Blenders AO. Although this AO shader has many advantages. For one, its a shader. That means you can apply it to only a single object, rather than a lighting setup that effects everything. Another thing is the ability to choose the colors. Especially the shadow colors. As the picture below shows, by setting the 'dark' to a brighter color that 'bright', you get some interesting effects.

All I did, was switch 'bright' with 'dark'. Although, if you wanted to, you could have a lime green shadow, with a red color.

Blender export implementation: name: a material name started with “sfambocc” bright: this values are the Blender diffuse RGB color values (just as values) dark: this values are the Blender specular RGB color values (just as values) samples: 32 by default (you'll have to change in the exported .sc file) dist: 0.0 by default (you'll have to change in the exported .sc file) You can also specify a global AO in the “AO override” separator in the Exporter window. This shader replaces all of the shaders in all of the meshes.

GLASS Below is an example of what the glass shader looks like

And what the shader block looks like shader { name shadername type glass eta 1.5 color 1 1 1 } Simply type in 'glass' as the shader type. In this shader 'eta' sets the Index of Refraction (IOR) or the object. The lower the eta, the lower the refractive value. As well as the reflectivity. See the red sphere at the top, its neither refractive, or reflective. Its eta is set to 1. Again, try to keep the color below 1, otherwise it'll get too bright, like below.

Common glass would have an IOR from around 1.5 to 1.9. Water at 20°C is 1.333 and ice is 1.31. These may come in handy most of the time, but here's a better list (http://en.wikipedia.org/wiki/List_of_indices_of_refraction) So what would some of these look like in sunflow? Well, just take a look at the image below.

Light red - silicon - eta 4.01 Green - water (20°C) - eta 1.33 Light blue - diamond - eta 2.419 Yellow - ethanol - eta 1.36 Purple - glass - eta 1.5 Blue - glass - eta 1.9 Orange - cubic zerconia - eta 2.15 Cyan - ? - eta 6 ( example of higher eta value ) White - ? - eta 20 ( example of very high eta value )

Blender export implementation: name: a material name started with “sfglass” and “Ray transp” button ON eta: the IOR parameter of “Ray transp” color: RGB diffuse color values

MIRROR Below is an example of what the mirror shader looks like

And what the shader block looks like shader { name shadername type mirror refl 1 1 1 } Set shader type to 'mirror' to use this. The numbers after 'refl' adjust the reflectivity of the object. As there are 3 digits, the color can also be defined. 1 1 1 will give you a perfect mirror. As seen in the top middle sphere, it reflects the color of it's surroundings with perfect accuracy. As you can see, the first column of spheres are tinted darker. This is the result of refl values below 1. The very first one has a refl of '.4 .4 .4'. A value above 1 in any of the three digits will result in an overly bright reflection, as seen in the third column of spheres. This should be avoided for realistic results.

Blender export implementation: name: a material name started with “sfmirror” and “Ray mirror” button ON refl: the RGB diffuse color values

PHONG Below is an example of what the phong shader looks like

And what the shader block looks like shader { name shadername type phong diff 1 1 1 spec 1 1 1 5 samples 4 } Set shader type to 'phong' to use this. When an object isn't a perfect reflector, the surface scatters the reflection giving it a blurry look, thats what this shader does. 'diff' controls the color, and the first three numbers in 'spec' control the reflection color. The darker the spec, the less reflective it is. Basically the same thing as the mirror shader But the last digit in 'spec' controls the reflections hardness, or blurriness. The lower the value, the blurrier it is. The examples above aren't the best, so lets have a look at a more detailed model. An HDR image was used.

Again, if color values are above 1, then the object may get too bright. ( see last column of spheres in example ) This shader is great for a floor while showing off your model. Heres one with a hardness value of 20.

You can see that there is a faint reflection on the ground, and that the reflection is sharper when the object is closer. Let's try again and set the hardness to 150.

The reflections are a bit more defined.

Heres another one with hardness way up there at 1000. The reflections are very sharp now, but still a bit blurry as the object gets farther away. But it all depends on the effect you want, so experiment.

Blender export implementation: name: a material name started with “sfphong” diff: the RGB diffuse color values spec: the RGB specular color values, the last value is from the Specular CookTorr “Hard” value samples: 4 by default (you'll have to change in the exported .sc file)

WARD Below is an example of what the ward shader looks like

And what the shader block looks like shader { name shadername type ward diff 1 1 1 spec 1 1 1 rough 1 2 samples 4 } Set shader type to 'ward' to use this. This is Sunflow's anisotropic shader. It almost the same as phong, but you can set the reflections blurriness along the x and\or y direction by changing the numbers at the end of 'rough'. Also, the blurrier it is, the more grainy it seems too be, unlike in the phong shader Also note that with ward, the higher the number the blurrier it is. Just the opposite of phong. So 0.01 in any or all of the 2 rough parameters will give you a nice sharp reflection. 0.5 will get you a nice blur to work off of.

Blender export implementation: name: a material name started with “sfward” diff: the RGB diffuse color values spec: the RGB specular color values rough: 0.2 / 0.01 by default (you'll have to change in the exported .sc file) samples: 4 by default (you'll have to change in the exported .sc file)

SHINY Below is an example of what the shiny shader looks like

And what the shader block looks like shader { name shadername type shiny diff 1 1 1 refl 1 } Set shader type to 'shiny' to use this. 'diff' controls the color and 'refl' controls the amount of reflectivity. The higher the 'refl' value, the more reflective the object will be. 1 is as high as you would need in almost all cases. If set to 0, then there is no reflection and looks similar to the diffuse shader. This shader adds a reflection onto a diffuse color, unlike the mirror shader, which makes it highly reflective with some color variations. Here is another example using a more detailed object.

Blender export implementation: name: a material name started with “sfshiny” diff: the RGB diffuse color values refl: the “RayMir” Blender value

CONSTANT Below is an example of what the constant shader looks like

And what the shader block looks like shader { name shadername type constant .8 .8 .8 } Set shader type to 'constant' to use this. Like with Blender's 'shadeless' option, this shader has no shading, but is a solid color. A good use for this shader would be lights. If the color values are above 1 then it will give off larger amounts of indirect light ( if GI in enabled ).

If you have a sphere surrounding your scene that has a constant shader applied, you can get nice ambient light. ( with GI on )

Blender export implementation: name: a material name started with “sfconstant” color: the RGB diffuse color values

JANINO Below is an example of what the 'janino' shader block like shader { name shadername type janino } What the janino shader does, is compile user scripted shaders. It takes the code withing the 'code' tags and compiles it into a shader. Of course, knowledge of Java would be needed for this. So here I've collected some shaders that experienced users have coded.

Triangle Wireframe---Christopher Kulla (fpsunflower) shader { name triangle_wire type janino import org.sunflow.core.RenderState; import org.sunflow.image.Color; import org.sunflow.math.Vector3; private Color lineColor = new Color(0.05f, 0.05f, 0.05f); private Color fillColor = new Color(0.95f, 0.95f, 0.95f); private float width = 0.02f; public Color getRadiance(RenderState state) { float cos = 1 - (float) Math.pow(1 - Math.abs(Vector3.dot(state.getNormal(), state.getRay().getDirection())), 5); float u = state.getU(); float v = state.getV(); float w = 1 - u - v; return ((u < width || v < width || w < width) ? lineColor : fillColor).copy().mul(cos); } public void scatterPhoton(RenderState state, Color power) {} } override triangle_wire true Orange text - Sets the color of the lines Green text - Sets the overall color. Cyan text - Sets line width. Purple text - This isn't really part of the shader, but it tells sunflow to use the shader "triangle_wire" on all objects. "triangle_wire" can be adjusted to whatever the shader name happens to be. This line is optional.

Blender export implementation: (not yet)

MODIFIERS BUMPMAP and NORMALMAP: To export a Bump Map or a Normal Map from Blender, you have to apply the image as a texture in slot 1 (2nd) of the material texture channels. Next, if it's a Bump Map, the texture name as to start with “bump”, if it's a Normal Map with “normal”. Normal maps just use the image, so, it's just necessary to UV-map your object for Sunflow to recognize the map. Bump maps, just like in Blender, have a variable value that give the intensity of the effect. So, you have to enable “Nor” in the “Map to” options in Blender (positive or negative) and give a value in “Nor slider”.

TEXTURE SHADERS If you want to apply an image texture to your material, you have to apply in slot 0 (1st). If you name your material starting with “sfambocc”, it will be an Ambient Occlusion Texture Shader. If you name your material starting with “sfdiffuse”it will be a Diffuse Texture Shader. Don't forget that you have to UV-map your image. More texture shaders will come.

Related Documents

Shadows
May 2020 14
Shadows
November 2019 24
Shadows
November 2019 25
Shadows
December 2019 32
Shadows
December 2019 33
Java Shadows
June 2020 16

More Documents from "teatro de sombras"