ProjectArcade

Форк
0
/
fakereflections.fsh 
36 строк · 1.3 Кб
1
// Simple fake reflection shader; created to use in PPSSPP.
2
// Without excessive samples and complex nested loops
3
// (to make it compatible with low-end GPUs and to ensure ps_2_0 compatibility).
4

5
#ifdef GL_ES
6
precision mediump float;
7
precision mediump int;
8
#endif
9

10
uniform sampler2D sampler0;
11
varying vec2 v_texcoord0;	
12

13
uniform vec4 u_setting;
14

15
void main()
16
{
17
  //get the pixel color
18
  vec3 color = texture2D(sampler0, v_texcoord0.xy).rgb;
19
  float gray = (color.r + color.g + color.b) / 3.0;
20
  float saturation = (abs(color.r - gray) + abs(color.g - gray) + abs(color.b - gray)) / 3.0;
21

22
  //persistent random offset to hide that the reflection is wrong
23
  float rndx = mod(v_texcoord0.x + gray, 0.03) + mod(v_texcoord0.y + saturation, 0.05);
24
  float rndy = mod(v_texcoord0.y + saturation, 0.03) + mod(v_texcoord0.x + gray, 0.05);
25

26
  //show the effect mainly on the bottom part of the screen
27
  float step = (max(gray, saturation) + 0.1) * v_texcoord0.y;
28

29
  //the fake reflection is just a watered copy of the frame moved slightly lower
30
  vec3 reflection = texture2D(sampler0, v_texcoord0 + vec2(rndx, rndy - min(v_texcoord0.y, 0.25)) * step).rgb;
31

32
  //apply parameters and mix the colors
33
  reflection *= 4.0 * (1.0 - gray) * u_setting.x;
34
  reflection *= reflection * step * u_setting.y;
35
  gl_FragColor = vec4(color + reflection, 1.0);
36
}
37

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.