-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathTextureSampleScreenSpace.osl
More file actions
28 lines (26 loc) · 1.05 KB
/
TextureSampleScreenSpace.osl
File metadata and controls
28 lines (26 loc) · 1.05 KB
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
/*
Screen space texture sampling for Redshift.
Handles colorspace correctly in Redshift.
This file is licensed under Apache 2.0 license
*/
shader ScreenSpaceTex
[[ string help = "Screen Space Texture Projection Mapping",
string label = "Screen Space Texture Map" ]]
(
string file = "" [[string widget = "filename", int connectable = 0]],
string fileColorSpace = "" [[string label = "ColorSpace", string widget = "colorspace"]],
point scale = point(1.0, 1.0, 1.0),
output color outColor = 0
)
{
point screenCordinates = transform("world", "screen", P);
//this is a weird way to do this so I have to rescale the coordinates.
screenCordinates += -1;
screenCordinates *= 0.5;
//texture tiling
screenCordinates *= scale;
color textureSample = texture(file, screenCordinates.x, 1-screenCordinates.y);
//reverse baked in colorspace
color textureSampleRAW = transformc("ACEScg", "scene-linear Rec.709-sRGB", textureSample);
outColor = transformc(fileColorSpace, "ACEScg", textureSampleRAW);
}