Advertisement
Techgeek1

Untitled

Oct 19th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.30 KB | None | 0 0
  1. use eden_engine;
  2.  
  3. component Camera {
  4.     param model                   : mat4;
  5.     param view                    : mat4;
  6.     param proj                    : mat4;
  7.     param view_proj = view * proj : mat4;
  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 albedo: texture2D;
  21.  
  22.     // Shader inputs
  23.     input pos    : vec3;
  24.     input normal : vec3;
  25.     input uv     : vec3;
  26.  
  27.     // Intra stage inputs
  28.     varying v_normal : vec3;
  29.     varying v_uv     : vec3;
  30.  
  31.     // Shader outputs
  32.     output out_color : vec3;
  33.  
  34.     // Standard "shader" program for an unlit mesh with a color and tint
  35.     fn 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.     fn 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.     fn compute() {
  51.         let index = eden_tid.x + eden_tid.y * 128;
  52.         let value = content[index];
  53.         let result = value * value;
  54.  
  55.         content[index] = result;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement