Strange Things happing in DX9/OpenGL Coding.......

  • Posts: 810
3 years 7 months ago #1 by BlueSkyKnight
This works in OpenGL but not in DX9
float gridy = floor(texcoord.y*(BUFFER_HEIGHT));
float gridx = floor(texcoord.x*(BUFFER_WIDTH));

color = (int(gridy+gridx) & 1) < 0.5 ? tex2D(SamplerCL,float2(texcoord.x + Perspective * pix.x,texcoord.y)).rgb : tex2D(SamplerCR,float2(texcoord.x - Perspective * pix.x,texcoord.y)).rgb;

For DX 9 I have to write it like this.
float gridy = floor(texcoord.y*(BUFFER_HEIGHT));
float gridx = floor(texcoord.x*(BUFFER_WIDTH));
                //wait What?Why?DX9 Workaround.......
color = (int((gridy+gridx)+(gridy+gridx)) & 2) < 0.5 ? tex2D(SamplerCL,float2(texcoord.x + Perspective * pix.x,texcoord.y)).rgb : tex2D(SamplerCR,float2(texcoord.x - Perspective * pix.x,texcoord.y)).rgb;

It feels like I'm missing something. Is this because the way API read the information? The two game I tested on are Quake 2 XP GL4+ and Borderlands 2 DX9

Please Log in or Create an account to join the conversation.

  • Posts: 3667
3 years 7 months ago - 3 years 7 months ago #2 by crosire
D3D9 does not have native bitwise operators, so I am emulating those. Turns out there is a type issue in my equation, which falsifies the result. I'll have that fixed in the next update.
The following user(s) said Thank You: BlueSkyKnight

Please Log in or Create an account to join the conversation.