I’m trying to use a texture in a Cycles material so that it looks like it’s displayed on a video screen, with fairly large pixels. I’m having no luck finding the right shader for this. It should work so that each pixel is uniform, displaying only one colour value.
Does anyone know of such a shader? All I could find was the following GLSL code and I don’t know how to convert it to OSL.
uniform sampler2D tex;
float dx = 15.*(1./512.);
float dy = 10.*(1./512.);
vec2 coord = vec2(dx*floor(gl_TexCoord.x/dx),
gl_FragColor = texture2D(tex, coord);
I’ve made an OSL shader for simulating a raster screen :
Enjoy it !
Great, that’s exactly what I was looking for. Thanks a lot for sharing your work, it’s quite a shader.
I got as far with it as getting a purple screen, any idea why is it purple?
And a suggestion: please consider making the related archives available as .zip or .tar. I’m not able to extract the .rar files. I have the unrar-free utility, but it fails on each file in the archive, only extracts the directory structure.
EDIT: By purple screen, I mean it works, the texture appears pixelated in the little grid squares, it’s just toned purple. I guess I need a screen pattern image - the output is purple because the pattern texture is missing?
Yes, it is surely because the pattern are missing.
Purple is the OSL / Cylces message to show an error in shading.
you can try with those RGB patterns :
I didn’t find how to include a file selector in an OSL shader, so, you have to enter the name manually.
If you have any question, just ask !
I’ll make a Zip version of the archive asap ! Do you have an email where I can send it ?
Thanks for the files, now it works perfectly. No need to send the zip files, but thanks for the offer.
Regarding texture selection in OSL nodes, wouldn’t a Color input work, by connecting a texture to it?
Happy Ostara on this Good Friday…