Closed 9-zzz closed 3 years ago
I think you have to add independent passes for each streak angle.
To learn shaders:
I'm closing this issue now. Please feel free to reopen it for further problems.
ah okay thanks will take a look.. just wanted to make sure... so what if i just want to take the existing one and just rotate it slightly
is it possible?
would that be something to do in the .shader or .csharp file for kinostreak?
Apply a rotation matrix to calculate displaced samples points in downsampler/upsampler in the shader.
Hi I tried to follow the rotation matrix method from the book link but I'm still having trouble... not sure what my 'st' value in the case of this shader would be..
Did I use the rotation method in the wrong way?: `float2x2 rotate2d(float _angle) { return float2x2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); }
// Downsampler
float4 FragmentDownsample(Varyings input) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
//float2 uv = input.texcoord;
float2 uv = mul(rotate2d( sin(0.1)*PI ),input.texcoord);
const float dx = _InputTexture_TexelSize.x;
float u0 = uv.x - dx * 5;
float u1 = uv.x - dx * 3;
float u2 = uv.x - dx * 1;
float u3 = uv.x + dx * 1;
float u4 = uv.x + dx * 3;
float u5 = uv.x + dx * 5;
//uv += float2(0.5,0.5);
half3 c0 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u0, uv.y)).rgb;
half3 c1 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u1, uv.y)).rgb;
half3 c2 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u2, uv.y)).rgb;
half3 c3 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u3, uv.y)).rgb;
half3 c4 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u4, uv.y)).rgb;
half3 c5 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u5, uv.y)).rgb;
return half4((c0 + c1 * 2 + c2 * 3 + c3 * 3 + c4 * 2 + c5) / 12, 1);
}
// Upsampler
float4 FragmentUpsample(Varyings input) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
//float2 uv = input.texcoord;
float2 uv = mul(rotate2d( sin(0.1)*PI ),input.texcoord);
const float dx = _InputTexture_TexelSize.x * 1.5;
float u0 = uv.x - dx;
float u1 = uv.x;
float u2 = uv.x + dx;
//uv += float2(0.5,0.5);
float3 c0 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u0, uv.y)).rgb;
float3 c1 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u1, uv.y)).rgb;
float3 c2 = SAMPLE_TEXTURE2D(_InputTexture, s_linear_clamp_sampler, float2(u2, uv.y)).rgb;
float3 c3 = SAMPLE_TEXTURE2D(_HighTexture, s_linear_clamp_sampler, uv).rgb;
return float4(lerp(c3, c0 / 4 + c1 / 2 + c2 / 4, _Stretch), 1);
}`
i ended up with this
First of all, you're referring to a wrong repository. This repository is a post-processing effect for the legacy render pipeline, but your code looks like an effect for HDRP.
Did I use the rotation method in the wrong way?
Wong. You have displace the UVs in a 2D way, not in a 1D way done in the original code.
I was wondering if there was a simple way to rotate the the streak I tried flipping the Xs and Ys in the shader code and kind of got it to work. but then the positioning was off. Would it be better to do that in the csharp code? To layer it i created a 2nd streakx post process I wanted to get this effect:
and with figuring out how to rotate maybe add more:
(sorry if this is not a valid issue)
also do you have any links to how to learn to make something like this.. i really tried to understand the shader code and could not..
thanks for all your awesome assets!!