This file is indexed.

/usr/share/gazebo-9/media/skyx/SkyX_Ground.hlsl is in gazebo9-common 9.0.0+dfsg5-3ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
--------------------------------------------------------------------------------
This source file is part of SkyX.
Visit http://www.paradise-studios.net/products/skyx/

Copyright (C) 2009-2012 Xavier Verguín González <xavyiy@gmail.com>

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt.
--------------------------------------------------------------------------------
*/

// --------------------- SkyX ground material ------------------------

float scale(float cos, float uScaleDepth)
{
	float x = 1.0 - cos;
	return uScaleDepth * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));
}

void main_vp(
    // IN
	float4 iPosition	        : POSITION,
	// OUT
	out float4 oPosition		: POSITION,
	out float3 oRayleighColor   : TEXCOORD0,
	out float3 oDirection       : TEXCOORD1,
	// UNIFORM
	uniform float4x4 uWorldViewProj,
    uniform float4x4 uWorld,
	// Global information
	uniform float3 uLightDir,
	// Position information
	uniform float3 uCameraPos,
	uniform float3 uCameraPos_,
	uniform float3 uInvWaveLength,
	uniform float  uInnerRadius,
	// Scattering parameters
	uniform float  uKrESun, // Kr * ESun
	uniform float  uKr4PI,  // Kr * 4 * PI
	uniform float  uKm4PI,  // Km * 4 * PI
	// Atmosphere properties
	uniform float uScale,               // 1 / (outerRadius - innerRadius)
	uniform float uScaleDepth,          // Where the average atmosphere density is found
	uniform float uScaleOverScaleDepth, // Scale / ScaleDepth
	uniform float uSkydomeRadius,
	// Number of samples
	uniform int   uNumberOfSamples,
	uniform float uSamples)
{
    // Clip space position
	oPosition = mul(uWorldViewProj, iPosition);
	
	// Calculate vertex world position
	float3 vertexWorldPos = mul(uWorld, iPosition);
	
	// Z-up
	vertexWorldPos.xyz = vertexWorldPos.xzy;
	
	// Get the ray from the camera to the vertex, and its length (which is the far point of the ray passing through the atmosphere)
	float3 v3Pos;                            // Z-up xz -> xy
	v3Pos.xz = (vertexWorldPos.xz-uCameraPos_.xy) / uSkydomeRadius;
	v3Pos.y = uCameraPos.y + vertexWorldPos.y / uSkydomeRadius;
	
	float3 v3Ray = v3Pos - uCameraPos;
	float fFar = length(v3Ray);
	v3Ray /= fFar;
	
	// Calculate the ray's starting position, then calculate its scattering offset
	float3 v3Start = uCameraPos; // Creo k ai k ajustar la posicion y del pixel
	float fDepth = exp((uInnerRadius - uCameraPos.y) / uScaleDepth);
	float fCameraAngle = dot(v3Ray, uCameraPos) / length(v3Pos);
	float fLightAngle = dot(normalize(uLightDir), v3Pos) / length(v3Pos);
	float fCameraScale = scale(fCameraAngle, uScaleDepth);
	float fLightScale = scale(fLightAngle, uScaleDepth);
	float fCameraOffset = fDepth*fCameraScale;
	float fTemp = (fLightScale + fCameraScale);
	
    // Init loop variables
	float fSampleLength = fFar / uSamples;
	float fScaledLength = fSampleLength * uScale;
	float3 v3SampleRay = v3Ray * fSampleLength;
	float3 v3SamplePoint = v3Start + v3SampleRay * 0.5f;
	
	// Loop the ray
	float3 color = float3(0,0,0);
	for (int i = 0; i < uNumberOfSamples; i++)
	{
    	float fHeight = length(v3SamplePoint);
		float fDepth = exp(uScaleOverScaleDepth * (uInnerRadius-fHeight));
		float fScatter = fDepth*fTemp - fCameraOffset;
		float3 v3Attenuate = exp(-fScatter * (uInvWaveLength * uKr4PI + uKm4PI)); // <<< TODO
		
		color += v3Attenuate * (fDepth * fScaledLength);
		v3SamplePoint += v3SampleRay;
	}

    // Outputs
    oRayleighColor = color * (uInvWaveLength * uKrESun); // TODO <--- parameter
	oDirection     = uCameraPos - v3Pos;
}

void main_fp(
    // IN
	float3 iRayleighColor   : TEXCOORD0,
	float3 iDirection       : TEXCOORD1,
	// OUT 
	out float4 oColor		: COLOR,
	// UNIFORM
	uniform float3 uLightDir
#ifdef LDR
	,uniform float  uExposure
#endif // LDR
	)
{	
	float cos = dot(uLightDir, iDirection) / length(iDirection);
	float cos2 = cos*cos;
	
	float rayleighPhase = 0.75 * (1.0 + 0.5*cos2);
					 
	oColor = float4(rayleighPhase*iRayleighColor,1);
	
#ifdef LDR
	oColor.xyz = 1 - exp(-uExposure * oColor);
#endif // LDR
}