EntityColor

Blitz3D Forums/Blitz3D Programming/EntityColor

big10p(Posted 2004) [#1]
OK, been wondering about this one for ages so I'm finally going to ask. :)

Anyone know why the RGB params of EntityColor() are floats and not simply ints?

*grits teeth, bracing for the obvious answer* :P


John Blackledge(Posted 2004) [#2]
Err... No.


big10p(Posted 2004) [#3]
Heh, It seems it's not just me, then. :)


koekjesbaby(Posted 2004) [#4]
this code doesn't help at all:
Graphics3D 640,480,0,2

cam=CreateCamera()
PositionEntity(cam, 0,0,-5)
l=CreateLight()

x# = 128
f=CreateSphere()
i=CreateSphere()

PositionEntity(f, 1,0,0)
PositionEntity (i,-1,0,0)
Repeat
	EntityColor(f,x,x,x)
	EntityColor(i,Int(x),Int(x),Int(x))
	x= (x+0.01) Mod 255
	RenderWorld tween
	Text 0,0, x
	Text 0,10,Int(x)
	Flip 0

Until KeyHit(1)
End

so i'll guess you have to stick to integers because it's probably impossible to see the difference (even if the command uses floats)

blah


DJWoodgate(Posted 2004) [#5]
If nothing else I suppose it saves having to convert them to floats for DirectX which uses normalised floating point color values (red#=red#/255 etc).


Rob Farley(Posted 2004) [#6]
I think I read somewhere it's for future enhancement when you get higher bit depths on colour. So the colours still work from 0-255 however, there can be more than 256 interations between these 0-255.

Of course I might just be making it up, or have dreamed it, or something...


Rob(Posted 2004) [#7]
It's a docs error.


Floyd(Posted 2004) [#8]
Ordinarily you would never be able to see tiny differences in color.
But you can here, with an incredibly bright light to magnify them.
Graphics3D 640, 480, 0, 2

cam = CreateCamera()
PositionEntity cam, 0,0,-5 

e1 = CreateSphere()
e2 = CreateSphere()

PositionEntity e1,  1,0,0
PositionEntity e2, -1,0,0 

light = CreateLight()
LightColor light, 66000, 0, 0

EntityColor e1, 0.66, 0, 0 
EntityColor e2, 0.99, 0, 0  ; 50% more than e1

RenderWorld  :  Flip 

WaitKey  :  End



big10p(Posted 2004) [#9]
I don't think it's a docs error, as such. Unless the same error was made on every single command that works with RGB. :P

However, this:

VertexColor surf,index,1.2345,0,0
.
.
.
Text 10,10,VertexRed(surf,index)


causes 1.0 to be displayed. But VertexRed() must be returning a float in order for it to be displayed with the decimal point.


Rob(Posted 2004) [#10]
Let me put some facts down as I know them:

B3D File format uses range 0..1. This is a float.
Blitz3D entities use range 0..511 this is integer.

The actual colour range you can use is 0..255, however the reason it's 512 is because you can override the ambient light value with EntityColor values above 255.

I still mantain it's a docs error and you're just getting confused with ambient light values. Floating point colour is not on in DX7! DX9 is another story.


simonh(Posted 2004) [#11]
It's not a docs error. Just press F1 once in the official IDE to see that - what's shown in the status bar (in this case EntityColor red#,green#,blue#) is taken directly from Blitz itself.


DJWoodgate(Posted 2004) [#12]
I do not think it is a docs error. Why? Because if you specify 127.5 as a colour value the value stored by blitz is 0.5. That would not happen if the argument was an integer. Further Blitz does not restrict the value passed to 0..511. I have observed they can be anything you like positive or negative.

Of course DX caps the actual values applied to each lit vertex to the range 0..255 *after* it has done all its lighting stuff. Thats my understanding anyways, but heck I am no DX guru so if you know better please set me right.


Floyd(Posted 2004) [#13]
My example showed color values of 0.66 and 0.99 being different, and both non-zero. So we know the floating point values are being used somehow.

And about the docs, the F1 quick help shows the arguments as floats. This is determined by Blitz's internal record of the argument type. So it can't be wrong.


Rob(Posted 2004) [#14]
Well we definately need some form of clarification from the man himself.


Ross C(Posted 2004) [#15]
Ok, this shows that floats are being used by Blitz. Modified example from floyd's code.

The sphere on the left is incrementing the RED colour value by 1.

The sphere on the right is incrementing the RED colour value by 0.01.

You can clearly see the sphere on the left is stepping quite a bit.

Graphics3D 640, 480, 0, 2

cam = CreateCamera()
PositionEntity cam, 0,0,-5 

e1 = CreateSphere()
e2 = CreateSphere()

PositionEntity e1,  1,0,0
PositionEntity e2, -1,0,0

light = CreateLight()
LightColor light, 6000, 0, 0

Global count#=0
Global dir#=0.01

Global count1#=0
Global dir1#=0.01


While Not KeyHit(1)
	
	EntityColor e1, 1+count, 0, 0
	count=count+dir:If count> 100 Or count<0 Then dir=dir*-1

	EntityColor e2, Int(1+count1), 0, 0
	count1=count1+dir1:If count1> 100 Or count1<0 Then dir1=dir1*-1
	
	RenderWorld
	Text 0,0," red left="+(Int(1+count1))+"  red right="+(1+count)
	Flip
	Delay 20
Wend
End



Rob(Posted 2004) [#16]
WOW! This really is intriguing!


Ross C(Posted 2004) [#17]
Sarcasim there? :)