Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plastic relief(low-relief) shader effect.
02-22-2015, 07:17 AM (This post was last modified: 02-22-2015 10:08 AM by Internauta1024A.)
Post: #1
Plastic relief(low-relief) shader effect.
Based on fxaa shader witout knowledge about shaders, I find funny effect (glass plastic relief) - best effect result with 2x or higher rendering resolution and linear texture scaling.
Someone with knowledge about shaders based on this effect can create more better
effect.

fsh:

// Plastic relief - based on FXAA PPSSPP shader.

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

uniform sampler2D sampler0;

uniform vec2 u_texelDelta;
varying vec2 v_texcoord0;

void main() {
vec3 rgbM = texture2D(sampler0, v_texcoord0.xy).xyz;
vec3 luma = vec3(0.299, 0.587, 0.114);
float lumaM = dot( rgbM, luma);
float lumaMax = lumaM;
//Change number values to create other plastic relief effect
vec3 rgbA = 0.41* (
texture2D(sampler0, v_texcoord0.xy + u_texelDelta * 0.9).xyz +
texture2D(sampler0, v_texcoord0.xy + u_texelDelta * 0.9).xyz);
vec3 rgbB = rgbA * 0.008 + 0.525* (
texture2D(sampler0, v_texcoord0.xy + u_texelDelta * 1.2).xyz +
texture2D(sampler0, v_texcoord0.xy + u_texelDelta * 1.2).xyz);
float lumaB = dot(rgbB, luma);

if(lumaB > lumaMax){
gl_FragColor.xyz=mix(rgbM,rgbA,1.0);
} else {
gl_FragColor.xyz=mix(rgbM,rgbB,0.8);
}
gl_FragColor.a = 1.0;
}

vsh:

attribute vec4 a_position;
attribute vec2 a_texcoord0;
varying vec2 v_texcoord0;
void main() {
v_texcoord0 = a_texcoord0;
gl_Position = a_position;
}


Attached File(s) Thumbnail(s)
       
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: