You must be mistaken, I just checked myself and there are quite a lot more than two lines different. What program are you using to merge them?
I used meld to check things out, and with only problem is that there is different switch, but I think that is related to the newer version of panda?
There should be a block of code you need around line 300. Basically what has been added is a condition that checks if the length of the input is 1 and runs the existing code, otherwise there is a new block of code that will run for an array (input length more than 1).
Unfortunatelly, it will end with:
Vertex shader was successfully compiled to run on hardware.
Ener call array
array vec4
Ener call array
array vec4
:display:gsg:glgsg(error): z_Position: parameter type supported only in Cg
Here is the code:
import tests
import os
import math
import time
import warnings
from pandac.PandaModules import ConfigVariableBool
shandle = ConfigVariableBool('basic-shaders-only', False)
shandle.setValue(True)
import direct.directbase.DirectStart
from pandac.PandaModules import *
from panda3d.core import *
from direct.actor.Actor import Actor
INST_NUM = 0
MODEL = os.path.abspath("../models/mod.egg")
TEXTURE = os.path.abspath("../textures/text.png")
SHA_V = "../shaders/inst-sha-v.sha"
SHA_F = "../shaders/inst-sha-f.sha"
SHA_NVIDIA = "../shaders/instance-shader.cg"
position = PTAVecBase4.emptyArray(INST_NUM+1)
rotation = PTAFloat.emptyArray(INST_NUM+1)
warnings.warn("Test if number of spawned creeps is correct before release!", FutureWarning)
for x in xrange(0, INST_NUM+1):
position[x] = Vec4(x*10.0, x*10.0, 0.0, 0.0)
rotation[x] = float(math.radians(45))
model = Actor(MODEL)
model.setTexture(loader.loadTexture(TEXTURE))
model.setScale(5.0, 5.0, 5.0)
model.loop("idle01")
model.reparentTo(render)
#shader = Shader.load(SHA_NVIDIA)
shader = Shader.load(Shader.SLGLSL, SHA_V, SHA_F)
#model.setShaderInput("offsets", position)
model.setShaderInput("z_Position", position)
model.setShaderInput("z_Rotation", rotation)
model.setShader(shader)
model.setInstanceCount(INST_NUM+1)
run()
Shaders:
//GLSL
uniform vec4 z_Position[128];
uniform float z_Rotation[128];
void main(void)
{
mat4 z_RotationMatrixZ = mat4 (cos( z_Rotation[gl_InstanceID] ), sin( z_Rotation[gl_InstanceID] ), 0.0, 0.0,
-sin( z_Rotation[gl_InstanceID] ), cos( z_Rotation[gl_InstanceID] ), 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
gl_Position = gl_ProjectionMatrix * ( z_Position[gl_InstanceID] + ( gl_ModelViewMatrix * ( z_RotationMatrixZ * gl_Vertex)));
}
//GLSL
uniform sampler2D tex_0;
void main(void)
{
gl_FragColor = texture(tex_0, vec2(gl_TexCoord[0]));
}
Here is my glShaderContext_src.cxx:
http://paste.pocoo.org/show/447125/