• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ominous94 · Dec 27, 2020 at 09:43 PM · compute shader

SampleteLevel don't work on ps4

I use SampleLevel to sample texture, it's work on pc, but don't work on ps4. Here is the Script and ComputeShader:

 using System.Collections;
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using UnityEngine;
 
 public class CommandBufferTest : MonoBehaviour
 {
     private static int _Map = Shader.PropertyToID("_Map");
     private static int _TestDataBuffer = Shader.PropertyToID("_TestDataBuffer");
 
     public ComputeShader m_shader;
     public RenderTexture m_rt;
 
     private ComputeBuffer m_testDataBuffer;
 
     private TestData[] testDatas = null;
 
     private int k_id;
 
     void Start()
     {
         k_id = m_shader.FindKernel("CSMain");
         m_shader.SetTexture(k_id, _Map, m_rt);
         testDatas = new TestData[1];
         testDatas[0].x = 1;
         int inputSize = Marshal.SizeOf(typeof(TestData));
         m_testDataBuffer = new ComputeBuffer(1, inputSize, ComputeBufferType.Default);
         m_shader.SetBuffer(k_id, _TestDataBuffer, m_testDataBuffer);
 
         m_testDataBuffer.GetData(testDatas);
         Debug.Log(testDatas[0].x);
     }
 
     // Update is called once per frame
     void Update()
     {
         m_shader.Dispatch(k_id, 8, 1, 1);
         m_testDataBuffer.GetData(testDatas);
         Debug.Log(testDatas[0].x);
     }
 
     private void OnGUI()
     {
         GUILayout.Label("buffer_X:" + testDatas[0].x + "|buffer_Y:" + testDatas[0].y + "|buffer_Z" + testDatas[0].z);
     }
 }

===============================================

 #pragma kernel CSMain
 
 
 cbuffer CB
 {
     Texture2D<float4> _Map;
     SamplerState sampler_Map;
 }
 
 struct TestData//for test
 {
     float x;
     float y;
     float z;
 };
 
 RWStructuredBuffer<TestData> _TestDataBuffer;
 
 
 [numthreads(8,1,1)]
 void CSMain (uint3 id : SV_DispatchThreadID)
 {
     TestData a;
     float3 _Color = _Map.SampleLevel(sampler_Map, float2(-0.1,-0.1),0);
     a.x = _Color.r;
     a.y = _Color.g;
     a.z = _Color.b;
     _TestDataBuffer[id.x] = a;
 }
 

I want to know why it don't work on ps4.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

112 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Shader / Compute Shader in Unity 1 Answer

DepthNormalsTexture access in Compute Shader 0 Answers

How to disable Warnings in Compute Shaders ? 1 Answer

Unity compute shader is blocked or not after Dispatch kernel? 0 Answers

Replacing a geometry shader with a compute shader. How do I output an arbitrary number of triangles? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges