| /*============================================================================= | |
| LightmapTextureDensityShader.hlsl: Shader for rendering lightmap texture | |
| density as a color. | |
| Copyright EA Digital Illusions AB | |
| =============================================================================*/ | |
| /*============================================================================= | |
| Vertex Shader | |
| =============================================================================*/ | |
| void MainVertexShader( | |
| FVertexFactoryInput Input, | |
| out FVertexFactoryInterpolants FactoryInterpolants, | |
| out float4 WorldPosition : TEXCOORD6, | |
| out float4 Position : POSITION | |
| ) | |
| { | |
| WorldPosition = VertexFactoryGetWorldPosition(Input); | |
| Position = MulMatrix(ViewProjectionMatrix, WorldPosition); | |
| FactoryInterpolants = VertexFactoryGetInterpolants(Input); | |
| } | |
| /*============================================================================= | |
| Pixel Shader | |
| =============================================================================*/ | |
| float4 LightmapTextureDensityParameters; | |
| static const float3 BadColor = float3(1.0f, 0.0f, 0.0f); | |
| static const float3 IdealColor = float3(1.0f, 0.8745f, 0.2470f); | |
| static const float3 OkColor = float3(0.1960f, 0.1960f, 1.0f); | |
| void MainPixelShader( | |
| FVertexFactoryInterpolants FactoryInterpolants, | |
| float4 WorldPosition : TEXCOORD6, | |
| out float4 OutColor : COLOR0 | |
| ) | |
| { | |
| float2 LightmapTextureCoord = GetLightMapCoordinate(FactoryInterpolants); | |
| // Area of parallelogram, in world space units. | |
| float WorldSpaceArea = length( cross( ddx(WorldPosition.xyz), ddy(WorldPosition.xyz) ) ); | |
| WorldSpaceArea = max( WorldSpaceArea, 0.00000001f ); | |
| // Area of lightmap texture | |
| float2 TextureAreaVec = ddx(LightmapTextureCoord.xy).xy * ddy(LightmapTextureCoord.xy).yx; | |
| float TextureArea = abs(TextureAreaVec.x - TextureAreaVec.y); | |
| //Finally calculate the density texture area per world space area | |
| float Density = (TextureArea/WorldSpaceArea) * 1000000.0; | |
| float MinDensity = LightmapTextureDensityParameters.x; | |
| float IdealDensity = LightmapTextureDensityParameters.y; | |
| float MaxDensity = LightmapTextureDensityParameters.z; | |
| if ( Density > IdealDensity ) | |
| { | |
| float Range = MaxDensity - IdealDensity; | |
| Density -= IdealDensity; | |
| OutColor = RETURN_COLOR( float4(lerp(IdealColor, BadColor, Density/Range), 1.0f) ); | |
| } | |
| else | |
| { | |
| float Range = IdealDensity - MinDensity; | |
| Density -= MinDensity; | |
| OutColor = RETURN_COLOR( float4(lerp(OkColor, IdealColor, Density/Range), 1.0f) ); | |
| } | |
| //OutColor = RETURN_COLOR( float4( Density , 0.0f, 0.0f, 1.0f ) ); | |
| } | |
Xet Storage Details
- Size:
- 2.74 kB
- Xet hash:
- b938665b8bbc0d256f1721a1ed52e2ad120aee251ea23b734eaf7554d7776b8f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.