Oogst wrote:Maybe a stupid question, but how can I do modulo in a shader model 2.x shader?
inneractive wrote:I have to admit that your technique looks very strange and unrealistic for now. It's probably been mentioned in the thread that glass has reflective properties. Perhaps you will need to do another pass that blends the interior with exterior environment reflection to get a more realistic look.
Shadow007 wrote:What you need is a hash function to get int f(x,y,z) = hash(x + hash(y + hash(z)));
You would get 32 bits to choose from
Now as a hash, you can use some kind of pseudoRNG (similar to what Kencho suggests).
You can also have a look at the following link :Long Period Hash Functions for Procedural Texturing. http://www.cs.kuleuven.ac.be/~graphics/CGRG.PUBLICATIONS/LagaeDutre2006LongPeriodHashFunctionsForProceduralTexturing
Shadow007 wrote:Wouldn't that be a % b = a - (floor(a/b) * b) ?
There may be easier possibilities though.
Oogst wrote:Some of the images already do that! It is just that the reflection is set to pretty weak to show the effect of Interior Mapping more clearly for demoing purposes. (is that de-moing or demo-ing?) I think I should also make the balance between reflection and interior depend on the angle with the glass, to make a sort of fresnel-effect.
// vertex to fragment communication for noise shaders
varying vec3 Nin;
// 2D noise texture
uniform sampler2D ntex;
modulus for random hash
const float modulus = 61;
void
main()
{
// integer and fractional components of input
float fracArg = fract(modulus*Nin.z);
float intArg = floor(modulus*Nin.z);
// hash z & z+1 to get offsets for noise slices
vec2 hash = mod(intArg,modulus);
hash.y = hash.y+1;
hash = mod(hash*hash,modulus);
hash = hash/modulus;
// look up noise and blend slices
vec2 g0, g1;
g0 = texture2D(ntex, vec2(Nin.x,Nin.y+hash.x)).ra*2-1;
g1 = texture2D(ntex, vec2(Nin.x,Nin.y+hash.y)).ra*2-1;
float noise = mix( g0.x+g0.y*fracArg,
g1.x+g1.y*(fracArg-1),
smoothstep(0,1,fracArg));
// combine with lighting
gl_FragColor = (noise*.5+.5)*gl_Color;
}
Shadow007 wrote:Of course, the easiest solution would be to use a "Noise" 2D Texture.To get a 3D result, you can do : ((h2d(x,y) + z)% 61)^2
float calculateBinaryNoise(float3 position, sampler2D noiseTexture, float threshold)
{
float3 noises = float3(tex2D(noiseTexture, float2(position.x, position.y) / 32).r,
tex2D(noiseTexture, float2(position.z, position.x) / 32).r,
tex2D(noiseTexture, float2(position.y, position.z) / 32).r);
float result = noises.x + noises.y + noises.z;
result /= 3;
result = step(result, threshold);
return result;
}
Oogst wrote:Shadow007 wrote:To get a 3D result, you can do : ((h2d(x,y) + z)% 61)^2
Hmm, that one looks really simple, but I do not get how it can work. What is that "h2d"-thing? Do you mean a texture read there? In that case the formula seems wrong, because the texture will result in a float between 0 and 1, which will be almost fully cancelled out by the much larger value in z.
(floor((h2d(x,y) * 61)+ floor(z))% 61)^2
((floor((h2d(x,y) * 61)+ floor(z))% 61)^2) % 61
JRowe47 wrote:How expensive would render to texture be, to show actors moving around inside and so on? That would be awesome, if feasible... silhouettes on shades, an ogre looking out the window from his or her desk... objects in a room?
JRowe47 wrote:Really neat, can't wait to read your paper
Users browsing this forum: Bing [Bot] and 3 guests