Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

3. May 2018


Unity 2018.1 was just released and one of the major new features is Shader Graph, a new visual programming language for creating shaders.  In this article we are going to look at how to enable and use Shader Graph.  There is also a video of this tutorial available here or embedded below.


First off, to get started using Shader Graph, be sure to be using Unity 2018.1 or later. 

Next, start Unity and create a new project.  I used the following settings:

image

Shader Graph is fully compatible with the new light weight render pipeline.  For the record, Shader Graph does NOT work with the current HD pipeline, this feature is under development. There is no need to add any new packages… yet.  Once ready, click Create Project.  Once your project is loaded, go ahead and create a new scene.

image


We need some kind of object to apply our shader to, simply right click the newly created scene in the Hierarchy view, select Create->Sphere.

image


Now we need to enable Shader Graph functionality in Unity.  Click Window, then select Package Manager.

image


In the resulting window, select All, then Shadergraph, then Install.  This will take a few seconds.

image


Now that Shadergraph is enabled, let’s create one.  In the Project panel, I created a new folder called Shaders.  Right click the newly created folder and select Create->Shader->PBR Graph.

image


I called mine MyShader, name yours whatever you want.  Except Dilbert; that’s a stupid name for a shader!

image


One more small bit of setup before we start creating shaders!  We need to create a material that we will attach our shader to and ultimately apply to our sphere mesh.  Right click the Materials folder and select Create->Material.

image


I called mine MyMaterial, again, name yours whatever you want… even Dilbert.  Make sure your shader is selected and showing in Inspector, then simply drag and drop your newly created shader on it.

ApplyingShader


Finally drag your material to the Sphere you created earlier.  Phew… ok, time to create our shader.  Simply double click the shader and the Shader Graph editor will be create.  A new project should look something like this:

image

You can zoom the design surface in and out using the mouse wheel, hold down the middle mouse button to pan the surface around.


The PBR Master can be thought of as the ultimate output of the shader.  You have a choice between Metallic and Specular by dropping down the workflow tab.  The blackboard is the section to the top left and can be used to configure parameters as we will see in a moment.  The bottom right region is a preview of the shader, this window can be resized.


Create a shader is now a matter of creating a network of nodes and connecting them together.  Let’s show a simple example of connecting a texture map to the Albedo channel.  Right click an empty point on the canvas, select Create Node->Input->Texture 2D Asset.

CreatingATextureNode


Now click on the red circle to the right of out and drag to an empty portion on the canvas.  Select Input->Sample Texture 2D, then connect the RGBA out pin to the Albedo in pin on the PBR node, like so:

ConnectingTheTexture


At this point, we have the equivalent of a diffuse texture defined in our shader, now head back to the Texture 2D Asset, click the little circle to the right of the texture field and select a texture to apply.  Pick a compatible texture from your project. 

image


You shader preview should now show the updated texture:

image


Now what if you wanted the texture to be defined as a parameter in the editor instead?  This is where the Blackboard comes in.  In the Blackboard, click the + icon to the right side, then select Texture.

image


Name it however you want, I called it SourceTexture in my case.  Also optionally provide a default texture value using the example same process we just did above.

image


Now let’s replace our hard coded texture with a parameter instead.  You can remove a node by left clicking it and hitting the delete key.

ConfigureAProperty


Now this parameter can be defined in the editor.  Select the Sphere we created then applied our material too in the Hierarchy view.  In the Inspector under the Material, you will now see a new parameter matching the name you just provided:

image


You can also easily see the source code generated by a shader by right clicking the output node and selecting Copy Shader.

image


The HLSL code of the shader will have just been copied to your clipboard.


So, that’s the basics of using Shader Graph.  Now it’s mostly a matter of creating the appropriate input nodes, modifying them and connecting them to the appropriate in pins on the PBR Master output node.  Getting into the details of how this works is beyond the scope of this tutorials, shader programming is a VAST subject and could fill many books.  I’m not going to just leave you hanging though…  now that you know how to enable and use the tools to create Shader Graphs it would be an ideal time to get your hands on some samples and dig deeper.  Thankfully Unity have provided exactly that, available for download here on Github.


The Video

Art, Design

2. May 2018


The beginner friendly game engine AppGameKit just received a new update.  For the most part it’s a relatively small update with only minor new features as well as some fixes and tweaks.  The biggest part of this new release is that the IDE has been localized supporting French, Italian, Spanish and German in addition to English.


Other new features of this release include:


New features
  • Added SetRawTouchMoveSensitivity to adjust the distance a touch event has to move before it gets classed as a drag event
  • Added missing dependency to the Tier 2 Google Android project causing it to fail to compile
  • Spriter images can now have their position, angle, scale, and ZOrder animated in addition to bones
  • Added FixSpriteToSkeleton2D to attach a sprite to a skeleton bone and have it move with the skeleton
  • Added Move3DPhysicsCharacterController command that takes an X and Z component for the direction
Fixes and tweaks
  • Fixed CreateZip creating an invalid zip file on 32-bit Android devices
  • Fixed SetMusicVolumeOGG failing to set the correct volume on 32-bit Android devices
  • Fixed touch coordinates on Windows devices being offset slightly from their actual position
  • On Windows pressing any mouse button will capture the mouse cursor until that button is release, previously only the left button would capture the pointer
  • Fixed spacebar on Raspberry Pi registering as key code 65 instead of 32
  • Tapping near the end of an edit box string which extends beyond the edge of the edit box will now shift the text to make more of it visible
  • Fixed the IDE crashing when loading an existing project if one of the source files is an invalid text file
  • Fixed a shader error message when setting SetObjectLightMode to 0 on an animated object with SetFogMode set to 1
  • Fixed Z order changes in Spriter files causing the animation to become corrupt
  • Fixed incorrect translations in the IDE

If you are interested in learning more about AppGameKit, be sure to check out our Closer Look review, or our recent video showing how to use AR in AppGameKit.

GameDev News

2. May 2018


Unity just released version 2018.1 and it’s probably the most significant release in a very long time.  The biggest features of this release include:

  • new C# programable graphics pipelines
    • high definition pipeline implementationimage
    • lightweight render pipeline implementation
    • three new project templates using the above new pipelines
  • new visual shader creation kit, Shader Graph
  • ECS, entity component system (preview)
  • Job system for parallel tasks (preview)
  • LLVM backend high performance “Burst” compiler (preview)


In addition to these core new features there are a number of other new features in this release such as:

  • Post processing stack out of beta
  • Dynamic resolution support on PS4
  • GPU instancing supporting Global Illumination(GI)
  • Improved Physics2D performance
  • 2D SpriteShape in preview form
  • 2D bone based animation system (preview)
  • Particle system improvements
  • Animation improvements
  • Probuilder Tools fully integrated at packages
  • Package Manager improvements
  • Cinemachine/Timeline improvements
  • Resonance Audio support


For more details of this release be sure to check the full Unity blog post for details or watched the video below.

GameDev News

30. April 2018


OGRE3D just released version 1.11.  OGRE (Object Oriented Rendering Engine) is an open source rendering framework written in C++.  The 1.11 release codenamed “Rhagorthua” was heavily focused on cleaning up the underlying code base to improve future development.  This includes tasks like switching to C++11 STL containers when possible, reduced memory consumption and a new scene loading API, SceneLoaderManager.  You can download OGRE 1.11 here.


Full details of this release from the changelog:

  • Main
    • RenderTexture: complete and fix PF_DEPTH usage
    • Support bulk convert and get sub volume of a slice of a compressed texture
    • Add errors for too many or too litle braces in scripts Closes #701.
    • Adds KTX (ETCCodec) support for loading mipmapped textures
    • Adds support for PVRTC pixel format in KTX containers
    • clang-tidy: fix performance-faster-string-find
    • clang-tidy: fix performance-type-promotion-in-math-fn
    • Fixed crash in RenderSystem::shutdown due to the notifications being sent to already destructed render targets
    • fix several gcc8/ clang7/ MSVC warnings
    • DataStream::readLine - fix out of bounds read (ret = 0)
    • generate a deprecation warning on "lod_distances" usage
    • Image - undeprecate 2D loading overloads
    • improve ResourceGroupManager documentation
    • ParticleSystem::fastForward - use round to avoid float iteration
    • Root - skip FrameListeners that are removed during event dispatch
    • SceneManager - explicitly disable mip filtering for depth map
    • SceneManager - flag GPV_GLOBAL on setAmbientLight
    • ScriptCompiler - improve error messages
    • SubEntity - add quotes to name strings
    • MeshLodGenerator: fix wrong stream eof() usage
    • InstancedEntity: Take scale into account when culling objects.
    • [Win32] Register Ogre log files to be collected by Windows Error Reporting and eventually passed to developer (would not happen under debugger)
    • Main: StringConverter - use empty newlocale on MinGW
  • Bites
    • ApplicationContext - fix reading shader cache and log on failure
    • ApplicationContext - forward fullscreen option to SDL (#658)
  • CMake
    • allow overriding OGRE_WARNING_FLAGS
    • Dependencies - propagate CMAKE_GENERATOR_PLATFORM
    • specify minimal required SWIG version
    • update dependencies
    • warn on deprecated true/ false settings
  • EXRCodec: Fix VS2017 error C2872: 'FLOAT': ambiguous symbol. (#723)
  • D3D11: D3D11Mappings - map DXGI_FORMAT_R8_UNORM to PF_R8
  • D3D9: fix compilation with MinGW
  • GL*:
    • log shader compile errors output as LML_CRITICAL
    • Fix for VAO leakage in ~GLVertexArrayObject
    • removed mRenderTargets destruction from ~GLxxxRenderSystem() as it's already done in RenderSystem::shutdown() method
    • do not force-enable shader cache
  • GL3+
    • FBOs are not shared between contexts, should be used and destroyed on the proper one
    • Fixed bugs on attempt to download non-zero miplevel; support for depth > 1
    • fix loading monolithic program from cache and log on failure
    • GL3PlusTextureBuffer: Ability to download to the non-consecutive PixelBox, useful for tiled rendering of very large images, atlasing, etc. GL RS already could do this
    • gl3w - update get_proc for APPLE from upstream
    • GLSLShader - workaround gl_ClipDistance on Intel Windows Driver
    • auto upgrade shaders to version 150 on OSX
    • Do not unbind VAO at the end of _render() to significantly increase performance of multi-pass rendering, at least on OSX
    • fixed GL_MAP_UNSYNCHRONIZED_BIT usage
    • Exclude glsl130 and glsl140 profiles unsupported in OSX Core profile
  • GL3+/ GLES2
    • enable primitive restart when available
    • GLxxxFBORenderTexture,GLxxxFBOMultiRenderTarget::getCustomAttribute() should return GL context to switch to before rendering
    • Optionally recreate FBO in GLXxxFrameBufferObject::bind(bool recreateIfNeeded) if unusable with current context
  • GLES2
    • do not automatically activate, as no other RS does this
    • If VAOs are supported: do not unbind VAO at the end of render(), do not clear scratch VAO #0 if not corrupted, explicitly bind scratch VAO #0 when required. Caching removed as it is not VAO ready, and will always miss in current usage scenario.
  • GL: drop OSX Mavericks HBL_DISCARD workaround
  • GLSupport:
    • do not attempt to set external windows full-screen
    • fix layout qualifier parsing
    • GLX - implement minBufferSize
    • GLX - support creating core 4.6 context
    • OSX - make sure contextProfile is correctly forwarded
    • Fix crash when embedding OgreOSXCocoaWindow in external window
  • RTShaderSystem: fix compile error when using double precision (#622)
  • Overlay
    • Scripts - add support for ogrescript syntax
    • warn about incompatibility with new script compiler
    • Accept opening '{' on the same line as the Overlay definition in a .overlay script
  • Samples
    • Browser - avoid double free on OSX
    • PBR - precision statement should in GLSLES only
    • python - update raw sample to deprecation-less API
    • Sample - const correctness
    • shadows.glsl enable upgrading to GLSL150
    • Terrain - use "General" resource group instead of "Terrain"
  • Tests:
    • General - do not try loading shared plugins in static build
    • Terrain - actually test something
  • Docs
    • describe how to use the fixed-function Pass options in shaders
    • Overlay/ Fontdef - improve parameter formatting
    • update css for Doxygen 1.8.13
    • update Overlays section and update GUI library references

GameDev News

30. April 2018


ShaderForge, on of the more popular extensions on the Unity Asset store, was just released completely free and open source today by it’s developer.  The developer made the following tweet this morning:

image


The source code and associated assets are now available on Github under the liberal MIT open source license.  The developer opted to make it free and open source because they no longer intend to continue development and Unity 2018 has currently broken ShaderForge due to it’s new shader model. 

ShaderForge is a visual graph based shader authoring tool that makes creating shaders a great deal easier.  Similar functionality to this is now be including in Unity 2018 and earlier, so this release is really only relevant to people using Unity 2017 or earlier, or people that are interesting in diving in to the source code.

GameDev News

Month List

Popular Comments