Skip to content
Snippets Groups Projects
Commit 3fe7f8e1 authored by Stefano Nardo's avatar Stefano Nardo Committed by Sandro Weber
Browse files

Merged in NRRPLT-7975-add-missing-gazebo-materials (pull request #40)

[NRRPLT-7975] Add gazebo materials

* [NRRPLT-7975] Add gazebo materials

* [NRRPLT-7975] add gazebo material

* [NRRPLT-7975] Add textures

* [NRRPLT-7975] Fix folders

Approved-by: Sandro Weber
Approved-by: Manos Angelidis
parent 0f45dc18
No related branches found
No related tags found
No related merge requests found
Showing
with 615 additions and 0 deletions
uniform sampler2D RSM;
uniform mat4 view;
uniform mat4 viewProj;
uniform mat4 World;
uniform mat4 InvShadowProjMatrix;
uniform float radius;
//vs_3_0 vec4 getClipCoords(vec3 coords)
vec4 getClipCoords(vec3 coords)
{
return vec4(2.0 * (coords.x - 0.5),
-2.0 * (coords.y - 0.5),
2.0 * (coords.z-0.5), 1.0);
}
//gp4vp vec4 getClipCoords(vec3 coords)
//{
// return vec4(2.0 * (coords.x - 0.5),
// -2.0 * (coords.y - 0.5),
// coords.z, 1.0);
//}
void main()
{
vec3 RSMNormal;
vec3 RSMFlux;
vec4 RSMVal = texture2D(RSM, vec2(gl_MultiTexCoord0.xy));
float attenuation = 1.0 / (1.0 + RSMVal.x * RSMVal.x);
vec4 prPos = InvShadowProjMatrix *
getClipCoords(vec3(gl_MultiTexCoord0.xy, RSMVal.x));
prPos.xyz /= prPos.w;
vec3 RSMPos = prPos.xyz;
// unpack the normal
RSMNormal.x = RSMVal.y;
float posZ = float((RSMVal.z > 1.0));
RSMNormal.y = RSMVal.z - (2.0 * posZ);
RSMNormal.z = 2.0 * (posZ - 0.5) * sqrt(RSMNormal.x * RSMNormal.x +
RSMNormal.y * RSMNormal.y);
RSMFlux.z = fract(RSMVal.w);
//RSMFlux.z = RSMVal.w - floor(RSMVal.w);
RSMVal.w -= RSMFlux.z;
RSMVal.w /= 255.0;
RSMFlux.y = fract(RSMVal.w);
//RSMFlux.y = RSMVal.w - floor(RSMVal.w);
RSMVal.w -= RSMFlux.y;
RSMVal.w /= 255.0;
RSMFlux.x = fract(RSMVal.w);
//RSMFlux.x = RSMVal.w - floor(RSMVal.w);
RSMFlux *= attenuation;
gl_TexCoord[3].xyz = (view * vec4(RSMNormal, 0.0)).xyz;
vec3 worldPos = gl_Vertex.xyz * radius * length(RSMFlux) *
clamp(1000.0 * dot(normalize(gl_Vertex.xyz), normalize(RSMNormal)),0.0, 1.0)
+ RSMPos;
vec4 projPos = viewProj * vec4(worldPos, 1.0);
gl_TexCoord[0] = projPos;
gl_TexCoord[0].xyz /= gl_TexCoord[0].w;
gl_TexCoord[1] = vec4(RSMFlux, 1.0);
gl_Position = projPos;
gl_TexCoord[2] = view * vec4(RSMPos, 1.0);
gl_TexCoord[2].xyz /= gl_TexCoord[2].w;
}
varying vec3 normal;
varying vec3 position;
uniform vec4 ambient;
uniform vec4 diffuse;
uniform vec4 specular;
void main()
{
vec4 color = ambient * gl_LightSource[0].ambient;
// normalize both input vectors
vec3 n = normalize(normal);
vec3 e = normalize(-position);
vec3 lightDir = normalize(vec3(gl_LightSource[0].position));
float NdotL = max(dot(normal, lightDir), 0.0);
// if the vertex is lit compute the specular color
if (NdotL> 0.0) {
color += gl_LightSource[0].diffuse * diffuse * NdotL;
// compute the half vector
// vec3 halfVector = normalize(lightDir + e);
vec3 halfVector = normalize(gl_LightSource[0].halfVector.xyz);
// add specular
float NdotH = max(dot(n, halfVector), 0.0);
float shininess = 1.0;
color += gl_LightSource[0].specular * specular * pow(NdotH, shininess);
}
gl_FragColor = color;
}
varying vec3 normal;
varying vec3 position;
uniform float time;
// deform along vertex normal dir
vec3 deform(vec3 v)
{
float z = 0.05 * sin((time+3.0*v.y)*4.0) * cos((time+3.0*v.x)*4.0);
return v + gl_Normal * z;
}
void main()
{
vec3 v = deform(gl_Vertex.xyz);
// Note: need to deform normal but for simplicity keep the same normal
vec3 n = gl_Normal;
gl_Position = gl_ModelViewProjectionMatrix * vec4(v, 1.0);
vec4 pos = gl_ModelViewMatrix * vec4(v, 1.0);
position = pos.xyz / pos.w;
normal = normalize(gl_NormalMatrix * n);
}
uniform float pNear;
uniform float pFar;
varying float depth;
void main()
{
// This normalizes the depth value
//gl_FragColor = vec4(vec3(depth / (pFar - pNear)), 1.0);
// This returns the world position
gl_FragColor = vec4(vec3(depth), 1.0);
}
uniform vec4 texelOffsets;
varying float depth;
void main()
{
gl_Position = ftransform();
gl_Position.xy += texelOffsets.zw * gl_Position.w;
//depth = -(gl_ModelViewMatrix * gl_Vertex).z; // ???
depth = gl_Position.w; // copied from old gazebo
}
#version 120
uniform sampler2D tex;
uniform float width;
uniform float height;
varying vec4 point;
void main()
{
//vec3 color = 255 * texture2D(tex, vec2(gl_FragCoord.s / width , gl_FragCoord.t / height)).xyz;
vec3 color = vec3(80, 0, 0);
// int rgb = int(color.r) << 16 | int(color.g) << 8 | int(color.b);
int rgb = 1;
gl_FragColor = vec4(point.x, -point.y, -point.z, rgb);
}
varying vec4 point;
void main()
{
gl_Position = ftransform();
// Vertex in world space
point = gl_ModelViewMatrix * gl_Vertex;
}
uniform sampler2D shadow_map_0;
uniform sampler2D shadow_map_1;
uniform sampler2D shadow_map_2;
uniform sampler2D diffuse_map;
uniform vec4 inv_shadow_map_size_0;
uniform vec4 inv_shadow_map_size_1;
uniform vec4 inv_shadow_map_size_2;
uniform vec3 derived_light_diffuse_color;
uniform vec4 derived_light_specular_color;
uniform float surface_shininess;
uniform vec4 shadow_depth_range_0;
uniform vec4 shadow_depth_range_1;
uniform vec4 shadow_depth_range_2;
uniform vec4 light_position_view_space;
uniform vec4 light_position_world_space;
uniform vec4 light_direction_view_space;
uniform vec4 light_attenuation;
uniform float light_casts_shadows;
uniform vec4 pssm_split_points;
varying vec3 vertex_world_view_pos;
varying vec3 vertex_world_norm;
varying vec4 vertex_light_pos_0;
varying vec4 vertex_light_pos_1;
varying vec4 vertex_light_pos_2;
varying float shadow_distance;
//------------------------------------------------------------------------------
// A Simple blur function
vec4 Blur(sampler2D map, vec2 uv, const in vec2 offset, float steps, float adjust)
{
float stepSize = offset.x;
uv.xy -= vec2(stepSize * steps);
vec4 total = vec4(0.0, 0.0, 0.0, 0.0);
for (float x = 0.0; x < steps; x+=1.0)
for (float y = 0.0; y < steps; y+=1.0)
total +=
texture2D(map, vec2(uv.xy + vec2(x * stepSize, y * stepSize))) + adjust;
return total / (steps * steps);
}
//------------------------------------------------------------------------------
// Calculate the shadow factor
float ShadowPCF(in sampler2D shadow_map, in vec4 shadow_map_pos,
const in vec2 offset)
{
// Old depth calc, using linear distance
//float depth = (vertex_light_pos.z - shadow_depth_range.x) *
// shadow_depth_range.w;
// Get the shadow map position
shadow_map_pos = shadow_map_pos / shadow_map_pos.w;
vec2 uv = shadow_map_pos.xy;
float depth_adjust = 0.00001;
vec2 c = Blur(shadow_map, uv, offset, 4.0, depth_adjust).xy;
// standard variance shadow mapping code
float variance = min(max( c.y - (c.x * c.x), 0.0), 1.0);
float m_d = c.x - shadow_map_pos.z;
float p = variance / (variance + m_d * m_d);
return smoothstep(0.4, 1.0, shadow_map_pos.z <= c.x ? 1.0 : p);
}
void main()
{
float spot = 1.0;
float shadow_factor = 1.0;
float specular = 0.0;
// Normalized fragment normal
vec3 norm = normalize(vertex_world_norm);
// Direction from the fragment to the light
vec3 light_dir_view = light_position_view_space.xyz -
vertex_world_view_pos.xyz * light_position_view_space.w;
// light_position_view_space.w == 0 for directional lights
float light_dist = length(light_dir_view);
light_dir_view = normalize(light_dir_view);
float lambertTerm = max( dot(norm, light_dir_view), 0.0 );
//////////////////////////////////////////////////////////////////////////////
// COMPUTE DIFFUSE CONTRIBUTION
vec4 diffuse_tex = texture2D(diffuse_map, gl_TexCoord[0].st);
vec4 diffuse_contrib = vec4(derived_light_diffuse_color *
diffuse_tex.rgb * lambertTerm,1.0);
//////////////////////////////////////////////////////////////////////////////
// COMPUTE SPECULAR COMPONENT
if (lambertTerm > 0.0 && light_dist <= light_attenuation.x)
{
vec3 view = -normalize(vertex_world_view_pos.xyz);
vec3 halfway = normalize( view + light_dir_view );
float nDotH = dot(norm, halfway);
float fAtten = 1.0 / (light_attenuation.y +
light_attenuation.z*light_dist +
light_attenuation.w*light_dist*light_dist);
// Works for all light types
specular = pow(clamp(nDotH, 0.0, 1.0), surface_shininess) * fAtten;
}
//////////////////////////////////////////////////////////////////////////////
// COMPUTE SHADOW CONTRIBUTION
if (light_casts_shadows)
{
if (shadow_distance <= pssm_split_points.y)
{
shadow_factor = ShadowPCF(shadow_map_0, vertex_light_pos_0,
inv_shadow_map_size_0.xy);
}
else if (shadow_distance <= pssm_split_points.z)
{
shadow_factor = ShadowPCF(shadow_map_1, vertex_light_pos_1,
inv_shadow_map_size_1.xy);
}
else
{
shadow_factor = ShadowPCF(shadow_map_2, vertex_light_pos_2,
inv_shadow_map_size_2.xy);
}
}
vec4 specular_contrib = specular * derived_light_specular_color;
gl_FragColor = (diffuse_contrib + specular_contrib) * shadow_factor;
}
uniform mat4 world_view_mat;
uniform mat4 world_view_proj_mat;
uniform mat4 inv_trans_world_view_mat;
uniform mat4 tex_world_view_proj_mat_0;
uniform mat4 tex_world_view_proj_mat_1;
uniform mat4 tex_world_view_proj_mat_2;
varying vec3 vertex_world_norm;
varying vec3 vertex_world_view_pos;
varying vec4 vertex_light_pos_0;
varying vec4 vertex_light_pos_1;
varying vec4 vertex_light_pos_2;
varying float shadow_distance;
void main()
{
gl_Position = world_view_proj_mat * gl_Vertex;
// Vertex in world space
vertex_world_view_pos = (world_view_mat * gl_Vertex).xyz;
// Vertex normal in world space
vertex_world_norm = (inv_trans_world_view_mat * vec4(gl_Normal, 1.0)).xyz;
shadow_distance = gl_Position.z;
// Position of the vertex in light space (shadow map texture coords)
vertex_light_pos_0 = tex_world_view_proj_mat_0 * gl_Vertex;
vertex_light_pos_1 = tex_world_view_proj_mat_1 * gl_Vertex;
vertex_light_pos_2 = tex_world_view_proj_mat_2 * gl_Vertex;
// Pass through the diffuse component
gl_TexCoord[0] = gl_MultiTexCoord0;
}
varying vec3 worldPos;
varying float depth;
void main()
{
// Inverse size of each grid cell
float gsize = 1.0;
// Width of the lines
float gwidth = 0.15;
vec3 f = abs(fract(worldPos * gsize));
vec3 df = fwidth(worldPos * gsize);
float mi = max(0.0, gwidth - 1.0);
float ma = max(1.0, gwidth);
vec3 g = clamp((f-df*mi) / (df*(ma-mi)), max(0.0, 1.0-gwidth), 1.0);
float c = 1.0 - (g.x * g.y);
// The alpha value fades out the grid as it proceeds into the distance
float alpha = depth/50.0;
float bound = clamp(alpha*0.1, 0.005, 0.1);
gl_FragColor = vec4(c, c, c, 1.0 - alpha);
}
varying vec3 worldPos;
varying float depth;
void main()
{
worldPos = gl_Vertex.xyz;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
depth = gl_Position.z;
}
uniform float retro;
uniform float near;
uniform float far;
varying vec4 point;
void main()
{
//vec3 p = vec3(point.x, point.y, point.z - near);
float l = length(point.xyz);
if (l>far)
l = far;
gl_FragColor = vec4(l, retro, 0, 1.0);
}
varying vec4 point;
void main()
{
gl_Position = ftransform();
// Vertex in world space
point = gl_ModelViewMatrix * gl_Vertex;
}
uniform float retro;
uniform float near;
uniform float far;
varying vec4 point;
void main()
{
//vec3 p = vec3(point.x, point.y, point.z - near);
float l = length(point.xyz);
if (l>far)
l = far;
float nl = l / far;
gl_FragColor = vec4(nl, nl, nl, 0.0);
}
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform sampler2D tex3;
uniform vec4 texSize;
varying float tex;
void main()
{
if ((gl_TexCoord[0].s < 0.0) || (gl_TexCoord[0].s > 1.0) ||
(gl_TexCoord[0].t < 0.0) || (gl_TexCoord[0].t > 1.0))
gl_FragColor = vec4(1,1,1,1);
else
{
int int_tex = int(tex * 1000.0);
if (int_tex == 0)
//gl_FragColor=vec4(1,0,0,1);
gl_FragColor = texture2D( tex1, gl_TexCoord[0].st);
else
if (int_tex == 1)
//gl_FragColor=vec4(2,1,0,1);
gl_FragColor = texture2D( tex2, gl_TexCoord[0].st);
else
//gl_FragColor=vec4(3,2,1,1);
gl_FragColor = texture2D( tex3, gl_TexCoord[0].st);
}
}
varying float tex;
void main()
{
gl_Position = ftransform();
tex = gl_Vertex.x;
gl_TexCoord[0] = gl_MultiTexCoord0;
}
uniform float2 LensCentre;
uniform float2 Scale;
uniform float2 ScaleIn;
uniform float4 HmdWarpParam;
// Scales input texture coordinates for distortion.
float2 HmdWarp(float2 in01)
{
float2 theta = (in01 - LensCentre) * ScaleIn; // Scales to [-1, 1]
float rSq = theta.x * theta.x + theta.y * theta.y;
float2 rvector = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);
return LensCentre + Scale * rvector;
}
float4 main_fp(float4 pos : POSITION, float2 iTexCoord : TEXCOORD0, uniform sampler2D RT : register(s0)) : COLOR
{
float2 tc = HmdWarp(iTexCoord);
return float4(tex2D(RT, tc).rgb,1);
}
void oculusBaseLightMap_vp(float4 position : POSITION,
float2 uv1 : TEXCOORD0,
float2 uv2 : TEXCOORD1,
out float4 oPosition : POSITION,
out float2 oUv1 : TEXCOORD0,
out float2 oUv2 : TEXCOORD1,
out float4 colour : COLOR,
uniform float4x4 worldViewProj,
uniform float4 ambient)
{
oPosition = mul(worldViewProj, position);
oUv1 = uv1;
oUv2 = uv2;
colour = ambient;
}
float4 oculusBaseLightMap_fp(float2 uv1 : TEXCOORD0, float2 uv2 : TEXCOORD1, uniform sampler2D texMap : register(s0), uniform sampler2D lightMap : register(s1)) : COLOR
{
float4 colour1 = tex2D(texMap, uv1);
float4 colour2 = tex2D(lightMap, uv2);
colour2.rgb = colour2.rgb * lerp(1.2, 1.9, saturate(length(colour2.rgb)));
if (colour1.a <= 0.4)
discard;
return float4(colour1 * colour2);
}
uniform vec4 derived_light_diffuse_color;
uniform vec4 derived_light_specular_color;
uniform float surface_shininess;
uniform vec4 light_position_view_space;
uniform vec4 light_direction_view_space;
uniform vec4 light_attenuation;
uniform vec4 spotlight_params;
varying vec3 vertex_world_view_pos;
varying vec3 vertex_world_norm;
void main()
{
vec4 color = gl_FrontMaterial.emission;
// Normalized fragment normal
vec3 norm = normalize(vertex_world_norm);
// Direction from the fragment to the light
vec3 light_dir_view = light_position_view_space.xyz -
vertex_world_view_pos.xyz * light_position_view_space.w;
// light_position_view_space.w == 0 for directional lights
float light_dist = length(light_dir_view);
light_dir_view = normalize(light_dir_view);
float lambert_term = max( dot(norm, light_dir_view), 0.0 );
if (lambert_term > 0.0)
{
vec3 view = -normalize(vertex_world_view_pos.xyz);
vec3 halfway = normalize( view + light_dir_view );
float nDotH = dot(norm, halfway);
// Light attenuation
float atten = 1.0 / (light_attenuation.y +
light_attenuation.z*light_dist +
light_attenuation.w*light_dist*light_dist);
// Modify attenuation for spot lights
if (!(spotlight_params.x == 1.0 && spotlight_params.y == 0.0 &&
spotlight_params.z == 0.0 && spotlight_params.w == 1.0))
{
float rho = dot(-light_direction_view_space.xyz, light_dir_view);
float fSpotE = clamp((rho - spotlight_params.y) /
(spotlight_params.x - spotlight_params.y),0.0,1.0);
atten *= pow(fSpotE, spotlight_params.z);
}
// Add diffuse component
color += derived_light_diffuse_color * lambert_term * atten;
// Add specular component
color += derived_light_specular_color *
pow(clamp(nDotH, 0.0, 1.0), surface_shininess) * atten;
}
gl_FragColor = color;
}
uniform mat4 world_view_mat;
uniform mat4 world_view_proj_mat;
varying vec3 vertex_world_view_pos;
varying vec3 vertex_world_norm;
void main()
{
gl_Position = world_view_proj_mat * gl_Vertex;
// Vertex in world space
vertex_world_view_pos = (world_view_mat * gl_Vertex).xyz;
// Vertex normal in world space
vertex_world_norm = normalize( gl_NormalMatrix * gl_Normal );
}
uniform vec4 inColor;
// Pixel Inputs
// in vec2 uv0;
// Outputs
// out vec4 color;
void main()
{
//color = inColor;
gl_FragColor = inColor;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment