Skip to content

The values passing from custom vertex stream to shader are not correct. #191

Description

@LenbaSun

Describe the bug
Hi, I uses UIParticle.cs to control my custom particle system on UI.
I write a custom shader which uses "custom vertex streams" to control like "uv flow" of texture by artists.
But I found it looks like only TEXCOORD0.xyzw will work well.
If I use TEXCOORD1, TEXCOORD2.... , the values fetched in shader not correct.
I have tried to use the same setting (with same particle system and same shader), make particle system not controlled by "UIParticle.cs", it will be correct.

I am not sure whether it's limitation for UIParticle.cs or maybe just I didn't setup correctly?

Like the image below, I use Custom1.xyzw (TEXCOORD0.zw/xy) as custom value.
It will use
custom1.xy => represent TEXCOORD0.zw in shader.
custom1.zw => represent TEXCOORD1.xy in shader.
This is how I get particle system input value in shader, in this case, TEXCOORD0.zw are correct, but TEXCOORD1.xy are always wrong....

I have no idea what happened....

image

To Reproduce
Steps to reproduce the behavior:

  1. Enable "Custom Vertex Stream" of renderer of particle system.
  2. Add Custom1.xyzw (TEXCOORD0.zw|xy)
  3. Implement custom shader and declare attribute like the "offset" below to fetch custom data input on particle system:
        struct Attributes
        {
            float4 positionOS   : POSITION;
            half4 texcoord     : TEXCOORD0;
            half2 offset : TEXCOORD1;
            half4 color        : COLOR;
        };

  1. Make texture "offset" in shader like :
Varyings Vertex(Attributes input)
{
	Varyings output = (Varyings)0;
	output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
	output.uv = input.texcoord.xy + input.offset;
	return output;
}

half4 Fragment(Varyings input) : SV_TARGET
{
	return SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv);
}

Expected behavior
If you feed "offset" value by "custom data" on particle system, the texture should be "offset".

Environment (please complete the following information):

  • Version 3.3.9
  • Platform: Standalone(Windows)
  • Unity version: 2020.3.14
  • Build options: Not built, editor can reproduce it.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions