Skip to content

Commit a013f36

Browse files
Cubemap Rotation Assets
1 parent 6a77ea8 commit a013f36

File tree

8 files changed

+135
-0
lines changed

8 files changed

+135
-0
lines changed

CubeMap_Rotation/Cubemap_Image.jpg

240 KB
Loading

CubeMap_Rotation/Cubemap_Image.jpg.meta

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
4.13 KB
Binary file not shown.

CubeMap_Rotation/Plane_Material.mat.meta

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Shader "Reflective/Specular2" {
2+
Properties {
3+
_Color ("Main Color", Color) = (1,1,1,1)
4+
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
5+
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
6+
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
7+
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
8+
_Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
9+
}
10+
SubShader {
11+
LOD 300
12+
Tags { "RenderType"="Opaque" }
13+
14+
CGPROGRAM
15+
#pragma surface surf BlinnPhong
16+
17+
sampler2D _MainTex;
18+
samplerCUBE _Cube;
19+
20+
fixed4 _Color;
21+
fixed4 _ReflectColor;
22+
half _Shininess;
23+
24+
uniform float4x4 _Rotation;
25+
26+
struct Input {
27+
float2 uv_MainTex;
28+
float3 worldRefl;
29+
};
30+
31+
void surf (Input IN, inout SurfaceOutput o) {
32+
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
33+
fixed4 c = tex * _Color;
34+
o.Albedo = c.rgb;
35+
o.Gloss = tex.a;
36+
o.Specular = _Shininess;
37+
38+
fixed4 reflcol = texCUBE (_Cube, mul(_Rotation, float4(IN.worldRefl,0)));
39+
reflcol *= tex.a;
40+
o.Emission = reflcol.rgb * _ReflectColor.rgb;
41+
o.Alpha = reflcol.a * _ReflectColor.a;
42+
}
43+
ENDCG
44+
}
45+
46+
FallBack "Reflective/VertexLit"
47+
}

CubeMap_Rotation/Reflect-Glossy.shader.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CubeMap_Rotation/SetRotation.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
public class SetRotation : MonoBehaviour {
5+
public int angle = 30;
6+
public int speed = 2;
7+
// Use this for initialization
8+
void Start () {
9+
10+
}
11+
12+
// Update is called once per frame
13+
void Update () {
14+
//for fixed rotation uncomment the line below:
15+
//Quaternion rot = Quaternion.Euler (0, angle, 0);
16+
17+
//for animated cubemap:
18+
Quaternion rot = Quaternion.Euler (0, (Time.time * speed), 0);
19+
Matrix4x4 m = new Matrix4x4 ();
20+
m.SetTRS(Vector3.zero, rot,new Vector3(1,1,1) );
21+
renderer.material.SetMatrix ("_Rotation", m);
22+
}
23+
}

CubeMap_Rotation/SetRotation.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)