Day 21

Published November 07, 2012
Advertisement
Mirrored from my blog (en, pt-br).

The day 21 was basically a copy of the previous day. What I had in mind to model the gun didn't work, so I ended up spending more time than I should again. In the end I ended up not liking the result, but I'll use it to prototype.

I thought this weekend (20 and 21) I could leave the prototype well underway, but in the end there was not much progress (there was learning, so I'm not sorry to lose this time in modeling the gun).

tumblr_mbk6zesj0r1rxq0qy.jpg

[media]
[/media]

Besides modeling, I lost some time in the "panel" of the gun and with that I learned one of the most interesting things today, which was how to access the textures of a shader using the method SetTexture. SetTexture receives a string that says which texture you want to modify and texture to replace.

The hardest part was finding what is the name given to the texture I needed to modify (in the case was a Illumin Self-Illumin). After searching I ended up finding that on the site of Unity you can download the code of the shaders that comes by default in Unity, and seeing the code you can see the name used.

The code of the Illumin-Diffuse is:

[source lang="java"]Shader "Self-Illumin/Diffuse" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _Illum ("Illumin (A)", 2D) = "white" {} _EmissionLM ("Emission (Lightmapper)", Float) = 0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert sampler2D _MainTex; sampler2D _Illum; fixed4 _Color; struct Input { float2 uv_MainTex; float2 uv_Illum; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); fixed4 c = tex * _Color; o.Albedo = c.rgb; o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a; o.Alpha = c.a; } ENDCG } FallBack "Self-Illumin/VertexLit"}[/source]
At first we can see that, in the Properties block is the names used. In my case _Illum. Then the method would be:
[source lang="java"]obj.render.material.SetTexture("_Illum", texture);[/source]
[size=2]PS: Sorry for the bad english.
Previous Entry Day 20
Next Entry Day 22 - [SinC]
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Day 39

1584 views

Day 38 - Idleness

1203 views

Day 37

1237 views

Day 36

1275 views

Day 34 - College

1055 views

Day 35 - Idleness

1110 views

Day 33 - College

1141 views

Day 32

1309 views

Day 31

1247 views

Day 30

1302 views
Advertisement