Skip to content

Instantly share code, notes, and snippets.

@onionmk2
Created October 10, 2017 07:35
Show Gist options
  • Save onionmk2/2e7e4f9caddbcb348e3a03bea395ca35 to your computer and use it in GitHub Desktop.
Save onionmk2/2e7e4f9caddbcb348e3a03bea395ca35 to your computer and use it in GitHub Desktop.
use cginc to write hlsl with VisualStudioHLSLTools
// RGBCube.shader
Shader "RGBCube" {
SubShader{
Pass{
CGPROGRAM
#include "Assets\RBGCube\RGBCube_cginc.cginc"
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}
// RGBCube_cginc.cginc
struct vertexOutput
{
float4 pos : SV_POSITION;
float4 col : TEXCOORD0; //Texture coordinates
};
vertexOutput vert(float4 vertexPos : POSITION)
{
vertexOutput output;
output.pos = UnityObjectToClipPos(vertexPos);
output.col = vertexPos + float4(0.5, 0.5, 0.5, 0.0);
return output;
}
float4 frag(vertexOutput input) : COLOR
{
return input.col;
}
@onionmk2
Copy link
Author

In RGBCube_cginc.cginc, If you write

#include {Unity Path}\Editor\Data\CGIncludes\UnityCG.cginc

IDE can autocomplete ``UnityObjectToClipPos`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment