中级Shader教程05 2D雪花

这篇中级Shader教程详细讲解了如何在Unity中创建2D雪花效果,涵盖空间划分、添加随机值、uv偏移等技术点,通过代码实现雪花的下落动画,并模拟了透视和空间分布的随机性。
摘要由CSDN通过智能技术生成

layout: post
title: “中级Shader教程05 2D雪花”
date: 2018-03-27 16:09:03
author: Jiepeng Tan
categories:

  • shader tutorial
    tags: shader_tutorial snow grid shader
    img_path: /assets/img/blog/ShaderTutorial2D/Snow
    mathjax: true

Shader 视频教程

本篇主要技术点有:

  1. grid 空间划分
  2. 2D模拟3D中"分层"的概念
  3. 透视模拟

1.原理:

前面中介绍了2D模拟3D中的一些小技巧,这里用到了透视以及空间划分的概念,这里将不再重复:

2.分析:

ps:后面()中的数字表示前面透视中的特点
根据 中级Shader教程02 基本图形2D中介绍了相应的一些概念
将上述知识具体到观察下雪这各场景中:

  1. 雪花前面的大点(1)
  2. 雪花前面的少点(2)
  3. 雪花前面的亮点(3)

其他的特点有:

  1. 整体是向下降落,因为透视关系后面的下降速度慢点(2)
  2. 现实中的雪花的薄厚程度不一
  3. 雪花的空间分布比较随机
  4. 雪花的下落过程的可能会左右移动

3.代码实现:

1.空间划分
uv *=10;//将uv放大后frac
uv = frac(uv);
uv-=0.5
2.添加随机值
fixed2 Rand22(fixed2 co){
   
	fixed x = frac(sin(dot(co.xy ,fixed2(122.9898,783.233))) * 43758.5453)
Shadero Sprite is a real time node-based shader tool for Unity 5, 2017 and 2018 NEW! Forum : https://forum.vetasoft.store/ Discuss with us about Shadero Sprite and more ! Description Shadero Sprite is a real time node-based shader editor. Shadero was made to be a real production time saver. Beautiful and fast, it creates many astonishing effects with the several premade and fully optimized node effects. Shadero will increase the number of the premade effects in every update. No code required. Features - Ultimate tools for 2D Shader Editor - Node based editor - Real time preview - Source code included - Load/Save project - Optimised shader - Fog Support - HDR Support - Visual selection node preview - Light Support - Blend Mode support - Normalmap with light Support - Preview directly the scene - Works with Unity UI - Many premade effects (+100) - Help Tutorial in editor - Project examples - Unity 5 and 2017 and 2018 compatible - Support Anima 2D - Support Render Texture - Support Mesh Renderer - Generate a Sprite - Create Morphing - And much much more ! http://www.shadero.com New version 1.7.0 see version history Version 1.1 - Add Node: UV > FX (UV) > Sprite Sheet Animation - Add Node: UV > FX (UV) > Pixel - Add Node: UV > FX (UV) > Fish Eye - Add Node: UV > FX (UV) > Pinch - Add Node: UV > FX (UV) > Kaleiodoscope - Add Node: Generate > Shape > XRay - Add Node: Generate > Shape > Donuts - Add Node: Generate > Shape > Lines - Add Node: Generate > Shape > Noise - Add Node: RGBA > Color > Turn Metal - Add Node: RGBA > Color > Turn Gold - Add Node: RGBA > Color > Turn Transparent - Add Node: RGBA > Color > HDR Control Value - Add Node: RGBA > Color > HDR Create - Add Force Change Parameters to the Build Shader Node (Experimental) - Add Lightning Support - Fix Node: UV > FX (UV) > Pixel XY precision - Fix new Shader Project that keep the preview material issue - Fix Auto variable order issue when you add the same node Any Feedback, error reports, questions or suggestions, please contact us at support@vetasoft.com If you like Shadero Sprite you can rate it on the asset store, it would be very helpful. Any idea or suggestions to improve Shadero Sprite? Feel free to contact us at : support@vetasoft.com
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JiepengTan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值