Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by matty201 · Jul 08, 2015 at 06:11 AM · unity 5shaderstexturingbinary

Double side texture, data retrived from binary file

Hey guys,

I've got loaded image (parsed binary data, byte by byte) into Texture2D object. Also I'm using double side shader which I found somewhere in the Internet. When I'm testing if image is loaded correctly by GUI.DrawTexture(), everything looks right. Sadly to said, Unity renders black color on plane instead of my texture.

Plane class:

 public class Plane
 {
     public Mesh mesh;
 
     public Texture texture;
 ...

Texture setup:

 MeshFilter meshFilter = plane.GetComponent<MeshFilter> () as MeshFilter;
 meshFilter.mesh = planeObj.mesh;
 
 MeshRenderer renderer = plane.GetComponent<MeshRenderer>() as MeshRenderer;
 renderer.material = new Material (Shader.Find ("Custom/DoubleSide"));
 
 if (planeObj.texture != null) {
     renderer.material.mainTexture = planeObj.texture;
     //renderer.material.SetTexture("MainTexture", planeObj.texture);
     renderer.material.shader = Shader.Find ("Custom/DoubleSide");
 }

Shader:

 Shader "Custom/DoubleSide" {
     Properties {
         _Color ("Main Color", Color) = (1,1,1,1)
         _MainTex ("Base (RGB)", 2D) = "white" {}
         //_BumpMap ("Bump (RGB) Illumin (A)", 2D) = "bump" {}
     }
     SubShader {    
         //UsePass "Self-Illumin/VertexLit/BASE"
         //UsePass "Bumped Diffuse/PPL"
        
         // Ambient pass
         Pass {
         Name "BASE"
         Tags {"LightMode" = "Always" /* Upgrade NOTE: changed from PixelOrNone to Always */}
         Color [_PPLAmbient]
         SetTexture [_BumpMap] {
             constantColor (.5,.5,.5)
             combine constant lerp (texture) previous
             }
         SetTexture [_MainTex] {
             constantColor [_Color]
             Combine texture * previous DOUBLE, texture*constant
             }
         }
    
     // Vertex lights
     Pass {
         Name "BASE"
         Tags {"LightMode" = "Vertex"}
         Material {
             Diffuse [_Color]
             Emission [_PPLAmbient]
             Shininess [_Shininess]
             Specular [_SpecColor]
             }
         SeparateSpecular On
         Lighting On
         Cull Off
         SetTexture [_BumpMap] {
             constantColor (.5,.5,.5)
             combine constant lerp (texture) previous
             }
         SetTexture [_MainTex] {
             Combine texture * previous DOUBLE, texture*primary
             }
         }
     }
     FallBack "Diffuse", 1
 }

Can anyone help me? I don't know if this is shader problem or just I'm missing some setting method.

What's weird, that renderer.material.SetTexture("MainTexture", planeObj.texture); makes my plane invisible.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image saschandroid · Jul 08, 2015 at 06:30 AM 0
Share

What about material.SetTexture("_$$anonymous$$ainTex", planeObj.texture); ?

avatar image matty201 · Jul 09, 2015 at 07:26 PM 0
Share

Still nothing. I'm checking material/shader preview, just at the bottom of inspector. That sphere has my texture, but it's rotated about 90degrees. Anyway my plane is still black. I think it's a problem related with my shader.

Is there some fitting/uv mapping needed?

avatar image matty201 · Jul 10, 2015 at 07:55 PM 0
Share

Well, I was right. I didnt setup uvs for my plane. -.-

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Is it more qualitative to calculate light direction manually or using WorldSpaceLightDir(vertex)? 1 Answer

Shader doesn't work when object is inverted by axis 1 Answer

Color changing texture and blending it with another texture 0 Answers

2D Shadow Help 0 Answers

I Installed URP But I Can't Create 2D Shaders 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges