Tag Info

New answers tagged

0

I do recommend this link for examples: http://www.codesampler.com/dx9src/dx9src_8.htm#dx9_hlsl_fx_simple For those wondering why their code won't work, or if you're confused on how to incorporate the shader into your pipeline, this is a good place to go.


4

Absolutely, But not as simple as taking a return value of a normal function. First I assume your question isn't about sharing variables between two shader stages (vertex, fragment..etc) but actually between two shader (programs). Shaders are part of the rendering pipeline, every input/output should pass through the rendering pipeline and its memory is ...


2

What you essentially want is the depth in camera coordinates, but relative to model, not camera. the easiest way to achieve that is to calculate the position of the origin of a model coordinate system in camera coordinates. ... vec4 cs_position = glModelViewMatrix * gl_Vertex; vec4 origin_position = glModelViewMatrix * vec4(0,0,0,1); distToOrigin = ...


1

calculate a bounding volume of the object (sphere, convex hull, box - depends on your speed/accuracy needs), this needs to be done only once - at initalization while rendering, for each object: transform camera (origin, direction) to object space project bounding volume on camera direction axis and subtract camera origin projection to retrieve min/max ...


0

I managed to find out what my problem was. The "smooth" keyword. Vertex shader: ... in float in_fl; flat out int FL; void main(void) { FL = int(in_fl); ... Fragment shader: ... flat in int FL; ... So now I have a red, a blue and a green square, as I wanted. Anyway thanks for any help.


1

It took quite a while but I've found the solution and am posting it here for anyone else who has the same issue. The draw code remains the same. Pixel Shader: // Texture sprite sheet. uniform extern texture ScreenTexture; sampler screen : register(s0) = sampler_state { Texture = <ScreenTexture>; MinFilter = POINT; // Stops pixels bleeding ...



Top 50 recent answers are included