Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by minpu · Aug 25, 2017 at 06:18 AM · unity 5

How to render a set of points with colors?

I want to render a set of points with colors in unity and I have followed this example http://www.kamend.com/2014/05/rendering-a-point-cloud-inside-unity/ to generate points and their colors randomly.

 //C#
 public class PointCloud : MonoBehaviour 
 { 
   private Mesh mesh;
   int numPoints = 60000;
 
   // Use this for initialization
   void Start () {
     mesh = new Mesh();
 
     GetComponent<MeshFilter>().mesh = mesh;
     CreateMesh();
   }
 
   void CreateMesh() {
     Vector3[] points = new Vector3[numPoints];
     int[] indecies = new int[numPoints];
     Color[] colors = new Color[numPoints];
     for(int i=0;i<points.Length;++i) {
         points[i] = new Vector3(Random.Range(-10,10), Random.Range (-10,10), Random.Range (-10,10));
         indecies[i] = i;
         colors[i] = new Color(Random.Range(0.0f,1.0f),Random.Range (0.0f,1.0f),Random.Range(0.0f,1.0f),1.0f);
     }
 
     mesh.vertices = points;
     mesh.colors = colors;
     mesh.SetIndices(indecies, MeshTopology.Points,0);
 
   }
 }
 
 // Shader
 Shader "Custom/VertexColor" {
 SubShader
 {
     Pass
     {
         LOD 200
 
         CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag
 
         struct VertexInput 
         {
             float4 v : POSITION;
             float4 color: COLOR;
         };
 
         struct VertexOutput 
         {
             float4 pos : SV_POSITION;
             float4 col : COLOR;
         };
 
         VertexOutput vert(VertexInput v) 
         {
             VertexOutput o;
             o.pos = UnityObjectToClipPos(v.v);
             o.col = v.color;
 
             return o;
         }
 
         float4 frag(VertexOutput o) : COLOR
         {
             return o.col;
         }
 
             ENDCG
         }
     }
 }


Is there anyway to change colors of these points? Since I set colors of these points with a constant values but it does not work.

Comment
Add comment · Show 1
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 FortisVenaliter · Aug 25, 2017 at 03:44 PM 0
Share

Best I can tell, you are setting the colors... to the random values you assign in your array. Why are you asking how to do something you're already doing?

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

136 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What is microsoft visual studio and what does it do exactly ? 1 Answer

Pose of Gameobject cannot be set in World coordinates 0 Answers

Unhandled Exception: System.StackOverflowException when using Switch Statement? 1 Answer

Playing a sprite animation before an object is destroyed 0 Answers

camera falling down when following player!! 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