Anyone know how to change the size of a point with a vertex shader?
Anyone know how to change the size of a point with a vertex shader?
Here is the shader
 Shader "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 = mul(UNITY_MATRIX_MVP, v.v);
             o.col = v.color;
             return o;
         }
          
         float4 frag(VertexOutput o) : COLOR {
             return o.col;
         }
  
         ENDCG
         } 
     }
  
 }
 
               I have tried adding size to the vertex but it had no effect
 Shader "Custom/VertexColorTest" {
     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;
             float4 size : PSIZE;
         };
          
         VertexOutput vert(VertexInput v) {
          
             VertexOutput o;
             o.pos = mul(UNITY_MATRIX_MVP, v.v);
             o.col = v.color;
             o.size = 10.0;
             return o;
         }
          
         float4 frag(VertexOutput o) : COLOR {
             return o.col;
         }
  
         ENDCG
         } 
     }
  
 }
 
               Any help getting these points a little bigger would be awesome!
Answer by Namey5 · Sep 08, 2016 at 07:28 AM
I unaware of a PSIZE semantic, but you should be able to scale vertices like so;
 v.vertex.xyz *= size;
 
              Please forgive my noobness as I am not the most familiar with shaders. Where in the shader code do I add 'v.vertex.xyz *= size'? I have tried many places but it keeps throwing errors.
Thanks!
I don't know much about shaders, but i'm pretty sure that line only scales the coordinates, not the size of the displayed pixels.
Its ok if the size itself doesn't change. What I am really looking for is a way to make the points visibly bigger. A single point is very difficult to see at the size of 1 pixel. There may be millions of points so it needs to be a lightweight method. Although, this vertex.xyz thing does look pretty easy if I could get it to work.
Your answer