Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by Jayexbl · May 31, 2012 at 11:59 AM · shaderiosblendercolorvertex

iOS shader with no texture, just vertex colouring and main colour

Hi, I'm using a vertex coloured sky plane model from Blender to create a sky gradient.

I've painted near black at the bottom vertices and near white at the top, and I am controlling the sky colour itself via Playmaker/script.

So I require a mobile shader which can read the vertex colours from my Blender mesh, and it also needs a colour. The only shader I can seem to find that does this is a shader called "Simple Texture" (still has a texture slot), and I'm not sure how fast/slow this is.

It does look extremely simple:

 Shader "Simple Texture" {
    Properties {
       _Color ("Main Color", Color) = (1, 1, 1, 1)
       _MainTex ("Base (RGB)", 2D) = "white"
    }
    SubShader {
       Pass {
          SetTexture [_MainTex] {
             constantColor [_Color]
             Combine texture * constant
          }
       }
    }
 }

Since it fills the whole screen a lot of the time, I'd like to be sure! I have absolutely no idea with shaders I'm afraid! Does iOS play nice without a texture being used, and if that slot is unused, does it affect performance at all?

If you could confirm for me that this is a suitable shader, or know of something better, I'd love to hear it.

Thanks, Jay

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by ScroodgeM · Jul 23, 2012 at 01:14 PM

this shader as simple as possible. uses only vertex color and main color.

Shader "Unity Answers/Mobile with Vertex Color"
{
    Properties
    {
        _Color ("Main Color", Color) = (1, 1, 1, 1)
    }
    SubShader
    {
        Tags { "Queue"="Background" "RenderType"="Background" }
        Cull Off
        ZWrite Off
        Fog { Mode Off }
    Pass
    {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        fixed4 _Color;
        struct appdata
        {
            float4 vertex : POSITION;
            float4 color : COLOR;
        };
        struct v2f
        {
            float4 pos : SV_POSITION;
            fixed4 color : COLOR;
        };
        v2f vert (appdata v)
        {
            v2f o;
            o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
            o.color = v.color;
            return o;
        }
        half4 frag(v2f i) : COLOR
        {
            return i.color * _Color;
        }
        ENDCG
        }
    }
}
Comment
Add comment · Share
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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Vertex colour transparency and Beast lightmapping? 3 Answers

How to add Vertex color to Emission color on this shader? 1 Answer

How much information can you store in vertex color? 2 Answers

Shader Vertex Data Format 2 Answers

Snow scene is a neon blue in an iOS build, but looks normal on the computer 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