Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!






Day 21 – Blender, Prototype and SetTexture

Posted by Alex.SilR, in General, SinC 06 November 2012 · 211 views

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).

Posted Image

http://www.youtube.com/watch?v=vUazccWNsOw&feature=player_embedded

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]
PS: Sorry for the bad english.




May 2015 »

S M T W T F S
     12
3456789
10111213141516
17181920212223
2425 26 27282930
31      

Recent Entries

PARTNERS