Unity Shader Graph:如何从Time节点加速时间?

时间:2018-06-13 06:55:32

标签: unity3d shader

我正在尝试使用时间节点的正弦时间输出,但我希望它更快。

如果在Unity c#中完成,我会尝试这样的事情

totalTime += Time.deltaTime * speed;

value = Mathf.PingPong(totalTime, 1);

但我不能在Shader Graph中这样做。如何解决这个问题?

EDIT1:我也尝试创建自定义节点功能,但这会导致错误。

static string PingPongFunction(
    [Slot(0, Binding.None)] Vector1 t,
    [Slot(1, Binding.None)] Vector1 length,
    [Slot(2, Binding.None)] out Vector1 Out)
{
    return
        @"
            {
                Out = Mathf.PingPong(t, length);
            }
        ";
}

2 个答案:

答案 0 :(得分:1)

将时间作为x馈给sin(x),并将时间乘以数字以加快速度。

enter image description here

答案 1 :(得分:0)

我会这样做,将时间传递到public void onClickLogInSignUp (View view) { EditText editTextUsername = (EditText) findViewById(R.id.editTextUsername); EditText editTextPassword = (EditText) findViewById(R.id.editTextPassword); username = editTextUsername.getText().toString(); password = editTextPassword.getText().toString(); ParseUser.logInInBackground(username, password, new LogInCallback() { @Override public void done(ParseUser user, ParseException e) { Log.i("Parse","Trying to log in "); if ( e == null ) { Log.i("Parse","Log In Successful"); Log.i("Parse","Redirecting as "+ ParseUser.getCurrentUser().getUsername()); Toast.makeText(MainActivity.this, "Logged In", Toast.LENGTH_SHORT).show(); startActivity(new Intent(getApplicationContext(), UserList.class)); } else { Log.e("Parse","Log In Failed Error - "+e.toString()); isLogInSuccessful = false; ParseUser.getCurrentUser().signUpInBackground(); ParseUser.getCurrentUser().saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { ParseUser user = new ParseUser(); user.setUsername(username); user.setPassword(password); user.signUpInBackground(new SignUpCallback() { @Override public void done(ParseException e) { if (e == null) { startActivity(new Intent(getApplicationContext(), UserList.class)); Log.i("Parse","Sign Up Successful"); Log.i("Parse","Redirecting as "+ ParseUser.getCurrentUser().getUsername()); Toast.makeText(MainActivity.this, "Signed Up", Toast.LENGTH_SHORT).show(); } else { Log.e("Parse","Can't log in as well as signup."); Toast.makeText(MainActivity.this, "Can't log in as well as signup.", Toast.LENGTH_SHORT).show(); } } }); } }); } } }); } 上的A,然后您可以手动将multiply node设置为2以提高两倍或添加新的vector1属性所以你可以从检查员那里改变它。

Shader Graph Example