basicEntity.frag 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #version 430 core
  2. #extension GL_ARB_bindless_texture: require
  3. layout (location = 0) out vec4 color;
  4. layout (location = 1) out vec4 out_screenSpacePositions;
  5. layout (location = 2) out ivec3 out_normals;
  6. layout (location = 3) out vec3 out_bloom;
  7. layout (location = 4) out float out_materials; //just roughness for now
  8. in vec2 v_uv;
  9. in vec3 v_normals;
  10. in vec3 v_vertexPosition;
  11. in vec3 v_color;
  12. uniform mat4 u_view;
  13. uniform float u_exposure;
  14. ivec3 fromFloatTouShort(vec3 a)
  15. {
  16. //[-1 1] -> [0 2]
  17. a += 1.f;
  18. //[0 2] -> [0 1]
  19. a /= 2.f;
  20. //[0 1] -> [0 65536]
  21. a *= 65536;
  22. return ivec3(a);
  23. }
  24. flat in int test;
  25. readonly restrict layout(std430) buffer u_entityTextureSamplerers
  26. {
  27. uvec2 textureSamplerers[];
  28. };
  29. flat in uvec2 v_textureSampler;
  30. //flat in float v_ambient;
  31. void main()
  32. {
  33. color.rgba = texture2D(sampler2D(v_textureSampler), v_uv).rgba;
  34. //color.rgba = texture2D(sampler2D(textureSamplerers[1]), v_uv).rgba;
  35. //color.rgba = vec4(v_uv,0,1);
  36. if(color.a < 0.5)discard;
  37. color.rgb = pow(color.rgb, vec3(2.2)) * v_color;
  38. //color.rgb *= v_ambient;
  39. out_screenSpacePositions.xyzw = vec4((u_view * vec4(v_vertexPosition,1)).xyz,1);
  40. out_normals = fromFloatTouShort(v_normals);
  41. out_bloom = vec3(0,0,0);
  42. out_materials.r = 0.9;
  43. //color.rgb = vec3(1.f/float(test));
  44. }