• FEATURED
• FEATURED
• FEATURED
• FEATURED
• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# how to do "bvec4 & bvec4" in GLSL?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1RPTD  Members

Posted 18 July 2013 - 07:36 AM

A simple problem: calculate two limits for 4 points at the same time. Using GLSL this would look like this:

vec4 testPoint, limitA, limitB = ...

bvec4 result = lessThan( testPoint, limitA ) & greaterThan( testPoint, limitB)

Problem is, this is not possible in GLSL it looks like. Compiler says there is no operator for "bvec4 & bvec4". I tried also with && but the same, no operator for "bvec4 && bvec4". I even tried something like multiplication (since using 0 and 1 as false and true it would work with 0*0=0, 0*1=0, 1*0=0 and 1*1=1) but again no operator for "bvec4 * bvec4".

How is one supposed to make a component wise AND operation on two bvec4 in GLSL? Or has GLSL overlooked this very important operation?

Edited by RPTD, 18 July 2013 - 07:36 AM.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

### #2Ashaman73  Members

Posted 19 July 2013 - 01:53 AM

How about using the step function ?

This checks if your testpoint is inside the limit.

vec4 result = step(limitA,testPoint) * step(testPoint,limitB);

This will check, if all 4 axis are inside.

bool is_inside = dot(result,result)==4;

More robust:

bool is_inside = dot(result,result)>3.5;


Edited by Ashaman73, 19 July 2013 - 01:55 AM.

Ashaman

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.