+1
W trakcie analizy
ComputeShader Output Rendering with SF
This is a very complex problem but I'm hoping my team and I can get some help with it.
We are working with a computeShader that generates tons of stars in 3 dimensions from a texture we read for voxel density values. We are looking for some way to use ShaderForge to make our companion shader which actually renders the stars more artist friendly.
Here's the HLSL code for the output shader that we'd like to somehow get into shaderforge. We were hoping to be able to reference our structured buffers and cginc files in a code node. Is this feasible in SF?
Shader "Custom/StarShaderTemp" {
float4 _Color;
struct v2f
We are working with a computeShader that generates tons of stars in 3 dimensions from a texture we read for voxel density values. We are looking for some way to use ShaderForge to make our companion shader which actually renders the stars more artist friendly.
Here's the HLSL code for the output shader that we'd like to somehow get into shaderforge. We were hoping to be able to reference our structured buffers and cginc files in a code node. Is this feasible in SF?
Shader "Custom/StarShaderTemp" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color(" Color", Color) = (1, 0.5, 0.5, 1)
}
SubShader
{
Pass
{
Tags { "RenderType"="Transparent"}
ZTest Off
ZWrite Off
Cull Off
Blend SrcAlpha One
CGPROGRAM
#pragma target 5.0
#pragma vertex star_vertex
#pragma fragment frag
#pragma exclude_renderers gles
#include "UnityCG.cginc"
#include "StarStructInc.cginc"
StructuredBuffer<Star> stars;
StructuredBuffer<float3> quadPoints;
sampler2D _MainTex;
float4 _Color;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
// vertex shader with no inputs
// uses the system values SV_VertexID and SV_InstanceID to read from compute buffers
v2f star_vertex(uint id : SV_VertexID, uint inst : SV_InstanceID)
{
v2f o;
float3 worldPosition = stars[inst].position;
float3 Qpoint = quadPoints[id];
o.pos = mul (UNITY_MATRIX_P, mul (UNITY_MATRIX_V, float4(worldPosition, 1.0f)) + float4(Qpoint, 0.0f));
o.uv = quadPoints[id]+ 0.5f; //setting UV texture coord center
return o;
}
float4 frag (v2f i) : COLOR
{
float4 texCol = tex2D (_MainTex, i.uv);
//float4 partCol = i.color;
//return float4 (1.0f - (1.0f - texCol.rgb) * (1.0f - partCol.rgb), texCol.a);
return texCol * _Color;
}
ENDCG
Customer support service by UserEcho
How does your code node work though? Do you think it's possible to access our buffers using your code node? Or is it more limited?
Thanks for the information and help.