I’ve made some changes in the shader, especially in line 23:
from :
float4 newcubemap = texCUBE(cubemap, out_texcoord0);
to :
float3 newcubemap = texCUBE(cubemap, out_texcoord0);
This is the new shader :
//Cg
//
//Cg profile arbvp1 arbfp1
void vshader(
float3 vtx_position : POSITION,
float2 vtx_texcoord0 : TEXCOORD0,
out float4 out_position : POSITION,
out float2 out_texcoord0 : TEXCOORD0,
uniform float4x4 mat_modelproj)
{
out_position=mul(mat_modelproj, float4(vtx_position,1));
out_texcoord0=vtx_texcoord0;
}
void fshader(
float4 out_position : POSITION,
float2 out_texcoord0,
samplerCUBE cubemap,
out float4 out_color : COLOR)
{
float attenuate = saturate(0.1);
float3 newcubemap = texCUBE(cubemap, out_texcoord0);
out_color=newcubemap*attenuate;
}
There is no more error in line 23, but now the error is :
:display:gsg:glgsg(error): shader1.sha (25) : error C1035: assignment of incompatible types
in line 25:
out_color=newcubemap*attenuate;
Correct me if this is wrong :
the newcubemap is float3 and the attenuate is float, so the out_color if float3, but it’s expected to be float4.
How can I fix this, I’ve tried to cast it up to float4, but it didn’t work.
Here is the outline of the reflection and shader settings in the script :
self.reflectionshader = Shader.load("shader1.sha")
self.refleksimobiltexstage=TextureStage('refleksi')
self.refleksimobiltex=self.setreflection(self.parent_of_object1,self.refleksimobiltexstage)
self.applyreflection(self.object1)
self.applyreflection(self.object2)
self.applyreflection(self.object3)
.
.
.(and so on)
def setreflection(self,whichobject,texstage):
.
.
.
(setting the cameras and it's node)
.
.
.
return reflectionbuffer.getTexture()
def applyreflection(self,whichobject):
self.whichobject=whichobject
self.whichobject.setTexGen(self.refleksimobiltexstage, TexGenAttrib.MWorldCubeMap)
self.whichobject.setTexture(self.refleksimobiltexstage,self.refleksimobiltex)
### set the shader ###
self.whichobject.setShader(self.reflectionshader)
I didn’t pass the cubemap texture manually to the shader, because it will be done by Panda, or NOT ?
Thanks,
JO