PDA

View Full Version : Black Objects if use GL_ARB_vertex_program without GL_ARB_fragment_program



AndreyOGL/D3D
07-19-2007, 08:33 AM
Hello!
i use simple Cg vertex shader.

struct PS {
float4 position : POSITION; // position in projection space
float2 uv0 : TEXCOORD0; // texture coordinate
};
uniform float4x4 ModelViewProjection : WorldViewProj; //register(c0); // the model*view*projection matrix

PS vsMain(float4 position : POSITION, float2 uv0 : TEXCOORD0)
{
PS vsOut;
vsOut.position = mul(position, ModelViewProjection);
vsOut.uv0 = uv0;
return vsOut;
}

After i get compiled code to arbvp1 profile:

!!ARBvp1.0
# cgc version 1.5.0019, build date Feb 22 2007 06:27:05
# command line args: -q -profile arbvp1 -entry vsMain -DWorldViewProj=state.matrix.mvp.transpose -DWORLDVIEWPROJ=state.matrix.mvp.transpose -Dworldviewproj=state.matrix.mvp.transpose -DProjection=state.matrix.projection -DPROJECTION=state.matrix.projection -Dprojection=state.matrix.projection -DView=state.matrix.modelview.transpose -DVIEW=state.matrix.modelview.transpose -Dview=state.matrix.modelview.transpose -DWorld=state.matrix.modelview.transpose -DWORLD=state.matrix.modelview.transpose -Dworld=state.matrix.modelview.transpose NumTemps=65535 MaxInstructions=256 MaxAddressRegs=1 MaxLocalParams=256

#vendor NVIDIA Corporation
#version 1.5.0.19
#profile arbvp1
#program vsMain
#semantic DiffSampler
#semantic ModelViewProjection : STATE.MATRIX.MVP.TRANSPOSE
#var float4 position : $vin.POSITION : POSITION : 0 : 1
#var float2 uv0 : $vin.TEXCOORD0 : TEXCOORD0 : 1 : 1
#var sampler DiffSampler : : : -1 : 0
#var float4x4 ModelViewProjection : STATE.MATRIX.MVP.TRANSPOSE : c[1], 4 : -1 : 1
#var float4 vsMain.position : $vout.POSITION : HPOS : -1 : 1
#var float2 vsMain.uv0 : $vout.TEXCOORD0 : TEX0 : -1 : 1
PARAM c[5] = { program.local[0],
state.matrix.mvp.transpose };
TEMP R0;
MUL R0, vertex.position.y, c[2];
MAD R0, vertex.position.x, c[1], R0;
MAD R0, vertex.position.z, c[3], R0;
MAD result.position, vertex.position.w, c[4], R0;
MOV result.texcoord[0].xy, vertex.texcoord[0];
END
# 5 instructions, 1 R-regs

if use this, objects in scene is black :(
if use simple pixel Cg shader:

float4 psMain(float2 uv0: TECOORD0) : COLOR
{
float4 diffColor = tex2D(DiffSampler, uv0);
return diffColor;
}

all ok! objects not black.
1) I have found first decision:
if pixel shader does not exist, I cause:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
this works if cards support GL_ARB_fragment_program(Radeon X1300, GeForce 6600 ).
On card Geforce2, Radeon 9200 SE objects on former black :( .
1) I have found second decision:
I return the colour from top in pixel shader:

struct PS {
float4 position : POSITION; // position in projection space
float2 uv0 : TEXCOORD0; // texture coordinate
float4 color : COLOR0;
};
uniform float4x4 ModelViewProjection : WorldViewProj; //register(c0); // the model*view*projection matrix

PS vsMain(float4 position : POSITION, float2 uv0 : TEXCOORD0, float4 color : COLOR0)
{
PS vsOut;
vsOut.position = mul(position, ModelViewProjection);
vsOut.uv0 = uv0;
vsOut.color = color;
return vsOut;
}

Exists decision of the problem without change top vertex shader?

CrazyButcher
07-20-2007, 05:03 AM
Radeon 9200 SE supports no pixel shaders in Cg. hence black.

Only ARB_fragment_program/fragment_shader cards or older "nvidia register combiners/texture shaders" cards are supported.

AndreyOGL/D3D
07-21-2007, 04:17 AM
CrazyButcher
And as now me to be? Use the decision 2?

CrazyButcher
07-22-2007, 03:47 AM
wihtout changing vertexshader (although I would recommend outputting color there), you can do a certain amount of pixel operations with "fixed function" extensions.

you can pass colors for an object using GL_ARB_texture_env_combine with the GL_CONSTANT source

AndreyOGL/D3D
07-23-2007, 02:38 AM
CrazyButcher
>you can pass colors for an object using >GL_ARB_texture_env_combine with the GL_CONSTANT >source
There is Example Code? please. Function glTexEnv* is used In decision ?
Radeon 9200SE, GeForce 2 support GL_ARB_texture_env_combine?