Skip to content

Commit 045c2f2

Browse files
author
thomasdeliot
committed
Removed unnecessary .NET 4 requirement
1 parent d73a071 commit 045c2f2

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

ProceduralStochasticTexturing/Editor/StandardStochasticShaderGUI.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,13 @@ public Color GetColor(int w, int h)
582582
{
583583
return data[h * width + w];
584584
}
585-
public ref Color GetColorRef(int w, int h)
585+
public void SetColor(int w, int h, Color value)
586586
{
587-
return ref data[h * width + w];
587+
data[h * width + w] = value;
588588
}
589-
public void SetColorAt(int w, int h, Color value)
589+
public void SetColor(int w, int h, int channel, float value)
590590
{
591-
data[h * width + w] = value;
591+
data[h * width + w][channel] = value;
592592
}
593593
};
594594

@@ -1060,7 +1060,7 @@ TextureData TextureToTextureData(Texture2D input, ref TextureFormat inputFormat)
10601060
{
10611061
for (int y = 0; y < res.height; y++)
10621062
{
1063-
res.SetColorAt(x, y, linearInput || PlayerSettings.colorSpace == ColorSpace.Gamma ?
1063+
res.SetColor(x, y, linearInput || PlayerSettings.colorSpace == ColorSpace.Gamma ?
10641064
colors[y * res.width + x] : colors[y * res.width + x].linear);
10651065
}
10661066
}
@@ -1191,7 +1191,7 @@ private void RescaleForDXTCompression(ref TextureData Tinput, ref Vector3 DXTSca
11911191
{
11921192
float v = Tinput.GetColor(x, y)[i];
11931193
v = (v - 0.5f) / DXTScalers[i] + 0.5f;
1194-
Tinput.GetColorRef(x, y)[i] = v;
1194+
Tinput.SetColor(x, y, i, v);
11951195
}
11961196
}
11971197
}
@@ -1295,7 +1295,7 @@ private void ComputeTinput(ref TextureData input, ref TextureData T_input, int c
12951295
// Gaussian quantile
12961296
float G = invCDF(U, GAUSSIAN_AVERAGE, GAUSSIAN_STD);
12971297
// Store
1298-
T_input.GetColorRef(x, y)[channel] = G;
1298+
T_input.SetColor(x, y, channel, G);
12991299
}
13001300
}
13011301

@@ -1326,7 +1326,7 @@ private void ComputeinvT(ref TextureData input, ref TextureData Tinv, int channe
13261326
// Get input value
13271327
float I = sortedInputValues[index];
13281328
// Store in LUT
1329-
Tinv.GetColorRef(i, 0)[channel] = I;
1329+
Tinv.SetColor(i, 0, channel, I);
13301330
}
13311331
}
13321332

@@ -1560,7 +1560,7 @@ private void DecorrelateColorSpace(
15601560
// Project on eigenvector
15611561
float new_channel_value = Vector3.Dot(vec, eigenvectors[channel]);
15621562
// Store
1563-
input_decorrelated.GetColorRef(x, y)[channel] = new_channel_value;
1563+
input_decorrelated.SetColor(x, y, channel, new_channel_value);
15641564
}
15651565

15661566
// Compute ranges of the new color space
@@ -1586,7 +1586,7 @@ private void DecorrelateColorSpace(
15861586
// Remap in [0, 1]
15871587
float remapped_value = (value - colorSpaceRanges[channel].x) / (colorSpaceRanges[channel].y - colorSpaceRanges[channel].x);
15881588
// Store
1589-
input_decorrelated.GetColorRef(x, y)[channel] = remapped_value;
1589+
input_decorrelated.SetColor(x, y, channel, remapped_value);
15901590
}
15911591

15921592
// Compute color space origin and vectors scaled for the normalized range
@@ -1685,7 +1685,7 @@ private void PrefilterLUT(ref TextureData image_T_Input, ref TextureData LUT_Tin
16851685
// Filter look-up table around this position with Gaussian kernel
16861686
float filteredValue = FilterLUTValueAtx(ref LUT_Tinv, x_texel, window_std, channel);
16871687
// Store filtered value
1688-
LUT_Tinv.GetColorRef(i, LOD)[channel] = filteredValue;
1688+
LUT_Tinv.SetColor(i, LOD, channel, filteredValue);
16891689
}
16901690
}
16911691
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ To use this prototype, either clone the repository into your Asset folder or dow
99
More detailed description and instructions:
1010
[Procedural Stochastic Texturing in Unity](https://blogs.unity3d.com/)
1111

12+
The code works with Unity 2018.3. Since the plugin plugs into parts of the Standard Shader code which has evolved since the initial release in Unity 5, it’s not working with older versions as it is.
13+
1214
This work is the implementation of two recent research publications at Unity Labs, which are the best resource for understanding the technique in detail.
1315

1416
Paper: [High-Performance By-Example Noise using a Histogram-Preserving Blending Operator](https://eheitzresearch.wordpress.com/722-2/)
1517

1618
Technical chapter: [Procedural Stochastic Textures by Tiling and Blending](https://eheitzresearch.wordpress.com/738-2/)
1719

1820
The comments in the code refer to specific sections of the Technical chapter.
21+

0 commit comments

Comments
 (0)