SHARE
TWEET

Untitled

a guest Oct 19th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use eden_engine;
  2.  
  3. component Camera {
  4.     param mat4 model;
  5.     param mat4 view;
  6.     param mat4 proj;
  7.     param mat4 view_proj = view * proj;
  8. }
  9.  
  10. component Object {
  11.     param mat4 model;
  12. }
  13.  
  14. shader UnlitColor {
  15.     // Instantiated components from another shader
  16.     using cam = Camera;
  17.     using obj = Object;
  18.  
  19.     // External parameters exposed to the UI
  20.     #[display(Texture2D)] param texture2D albedo;
  21.  
  22.     // Shader inputs
  23.     input vec3 pos;
  24.     input vec3 normal;
  25.     input vec3 uv;
  26.  
  27.     // Inter stage inputs
  28.     varying vec3 v_normal;
  29.     varying vec3 v_uv;
  30.  
  31.     // Shader outputs
  32.     output vec3 out_color;
  33.  
  34.     // Standard "shader" program for an unlit mesh with a color and tint
  35.     void vertex() {
  36.         eden_position = mvp * vec4(normal, 1);
  37.         v_normal = (obj.model * cam.view_proj * vec4(normal, 0)).xyz;
  38.         v_uv = uv;
  39.     }
  40.  
  41.     void fragment() {
  42.         out_color = sample(albedo, v_uv);
  43.     }
  44. }
  45.  
  46. shader ComputeTest {
  47.     param content int[1024];
  48.  
  49.     #[num_threads(8, 8, 1)]
  50.     void compute() {
  51.         int index = eden_tid.x + eden_tid.y * 128;
  52.         int value = content[index];
  53.         int result = value * value;
  54.  
  55.         content[index] = result;
  56.     }
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top