CyberAgentGameEntertainment / NovaShader

Multi-functional shader for the Particle System that supports Universal Render Pipeline (URP) of Unity.
MIT License
1.12k stars 73 forks source link

Can you add a clamp control to texture sampling? This way, we don't have to change the texture mode. It would be more convenient and increase the versatility of the textures. #55

Closed HCchay closed 1 year ago

Haruma-K commented 1 year ago

Are you talking about the Wrap Mode in the import settings of the texture? Using inline sampler states makes it technically possible, but currently, we use them for the Mirror Sampling feature. If you have a more specific idea of how you'd like to use the Wrap Mode, please let us know.

HCchay commented 1 year ago

I personally believe that, in terms of special effects usage, the clamp mode is more commonly used than the mirror mode. It would be best if the texture's U and V coordinates could be clamped individually. Why should this feature be added? Because in regular work, there are times when adjusting the effect only requires the texture to scroll once, without looping. However, textures are typically imported with the repeat mode set, which necessitates duplicating the texture and setting it to clamp mode. By adding the clamp mode in the shader, it would increase convenience and optimize resources.

Haruma-K commented 1 year ago

Because in regular work, there are times when adjusting the effect only requires the texture to scroll once, without looping.

Does this mean that you set it to Clamp for adjustment and finally to Repeat? If so, wouldn't it be unnecessary to duplicate the texture? I think I might not be fully understanding your point, so I'd like to know a more specific example.

Since inline sampler states are specified as combinations of filtering modes and wrapping modes, I'm concerned that the number of shader keywords will increase significantly if we try to accommodate your request. So unless there is a valid reason, the policy is to set the texture wrapping mode in the import settings.

HCchay commented 1 year ago

I've provided a common clamp UV version. So you can see what I'm talking about inline half2 ClampUV(half2 uv, float uClamp, float vClamp) { if (uClamp > 0) uv.x = saturate(uv.x); if (vClamp > 0) uv.y = saturate(uv.y);

return uv;

} In this way, the map uv offset can be achieved even if the map mode is repeat. The effect will not be repeated

HCchay commented 1 year ago

That's right. I don't see the template test function. Can it be increased?

Haruma-K commented 1 year ago

I've provided a common clamp UV version. So you can see what I'm talking about

Thank you for the code. I know this is a repeat of my previous question, but what is the reason for wanting to do this in the shader instead of the import setting?

That's right. I don't see the template test function. Can it be increased?

Sorry, I'm not quite sure I understand. What are you talking about?

HCchay commented 1 year ago

Because usually do special effects map. In general, imported texture Settings are repeated as set. But sometimes you need to use clamp mode. Here's a common example. Sweep out... Some only sweep once. And keep going through the cycle. The texture used for the sweep is the same. So just sweep it once. The tile mode is clamp. But if I keep going. repeated tiles is repeated. So since the same picture is used for both effects... Is there no need to make two copies? One repeated. A piece of clamp. Isn't that an increase in resources? It's not very convenient. And there are a lot of them. I don't know if you can understand what I'm trying to say.

HCchay commented 1 year ago

That's right. I don't see the template test function. Can it be increased?

Sorry, I'm not quite sure I understand. What are you talking about?

Template testing. Maybe we have different names. In the case of shader, it's Stencil. For example, I can set a template value. Then the value equal to the template is displayed

Haruma-K commented 1 year ago

I apologize for my lack of understanding... What do you mean by "Sweep"? Also, I understand that the template refers to a stencil, but how does the stencil relate to this context?