本文整理汇总了C++中ofShader::setUniform2f方法的典型用法代码示例。如果您正苦于以下问题:C++ ofShader::setUniform2f方法的具体用法?C++ ofShader::setUniform2f怎么用?C++ ofShader::setUniform2f使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofShader
的用法示例。
在下文中一共展示了ofShader::setUniform2f方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: begin
//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::begin(ofShader& shader){
if(playingVO){
return;
}
if(!getPlayer().isLoaded() ){
return;
}
if(!getTextureReference().isAllocated()){
return;
}
getPlayer().bind();
shader.setUniformTexture("rgbdTexture", getTextureReference(), 1);
shader.setUniform2f("textureSize", getPlayer().getWidth(), getPlayer().getHeight());
shader.setUniform4f("colorRect", colorRect.x, colorRect.y, colorRect.width, colorRect.height);
shader.setUniform2f("colorScale", colorScale.x, colorScale.y);
shader.setUniform2f("colorFOV", colorFOV.x, colorFOV.y );
shader.setUniform2f("colorPP", colorPrincipalPoint.x, colorPrincipalPoint.y);
shader.setUniform3f("dK", distortionK.x, distortionK.y, distortionK.z);
shader.setUniform2f("dP", distortionP.x, distortionP.y);
ofMatrix4x4 adjustmentMatrix;
adjustmentMatrix.rotate(adjustRotate.x, 0, 1, 0);
adjustmentMatrix.rotate(adjustRotate.y, 1, 0, 0);
adjustmentMatrix.translate(adjustTranslate.x, adjustTranslate.y, adjustTranslate.z);
shader.setUniformMatrix4f("extrinsics", extrinsics * adjustmentMatrix );
shader.setUniform4f("depthRect", depthRect.x, depthRect.y, depthRect.width, depthRect.height);
shader.setUniform2f("depthPP", depthPrincipalPoint.x, depthPrincipalPoint.y);
shader.setUniform2f("depthFOV", depthFOV.x, depthFOV.y);
shader.setUniform4f("normalRect", normalRect.x, normalRect.y, normalRect.width, normalRect.height);
shader.setUniform4f("faceFeatureRect", faceFeatureRect.x, faceFeatureRect.y, faceFeatureRect.width, faceFeatureRect.height);
shader.setUniform4f("deltaChangeRect", deltaChangeRect.x, deltaChangeRect.y, deltaChangeRect.width, deltaChangeRect.height);
shader.setUniform1f("farClip", farClip);
shader.setUniform1f("nearClip", nearClip);
shader.setUniform1f("edgeClip", edgeClip);
shader.setUniform1f("minDepth", minDepth);
shader.setUniform1f("maxDepth", maxDepth);
shader.setUniform3f("skinSampleColor",skinSampleColor.r,skinSampleColor.g,skinSampleColor.b);
shader.setUniform3f("skinWeights", skinWeights.x,skinWeights.y,skinWeights.z);
shader.setUniform2f("skinThreshold", skinThreshold.min, skinThreshold.max);
shader.setUniform3f("headPosition",headPosition.x,-headPosition.y,headPosition.z);
shader.setUniform1f("flowPosition", flowPosition);
}
示例2: setupProjectionUniforms
void ofxRGBDRenderer::setupProjectionUniforms(ofShader& theShader){
rgbMatrix = (depthToRGBView * rgbProjection);
ofVec2f dims = ofVec2f(currentRGBImage->getTextureReference().getWidth(),
currentRGBImage->getTextureReference().getHeight());
theShader.setUniform2f("fudge", xmult, ymult);
theShader.setUniform2f("dim", dims.x, dims.y);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadMatrixf(rgbMatrix.getPtr());
glMatrixMode(GL_MODELVIEW);
}
示例3: updateMaterial
void ofMaterial::updateMaterial(const ofShader & shader,ofGLProgrammableRenderer & renderer) const{
shader.setUniform4fv("mat_ambient", &data.ambient.r);
shader.setUniform4fv("mat_diffuse", &data.diffuse.r);
shader.setUniform4fv("mat_specular", &data.specular.r);
shader.setUniform4fv("mat_emissive", &data.emissive.r);
shader.setUniform4fv("global_ambient", &ofGetGlobalAmbientColor().r);
shader.setUniform1f("mat_shininess",data.shininess);
for(auto & uniform: uniforms1f){
shader.setUniform1f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms2f) {
shader.setUniform2f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms3f) {
shader.setUniform3f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms4f) {
shader.setUniform4f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms1i) {
shader.setUniform1i(uniform.first, uniform.second);
}
for (auto & uniform : uniforms2i) {
shader.setUniform2i(uniform.first, uniform.second.x, uniform.second.y);
}
for (auto & uniform : uniforms3i) {
shader.setUniform3i(uniform.first, uniform.second.x, uniform.second.y, uniform.second.z);
}
for (auto & uniform : uniforms4i) {
shader.setUniform4i(uniform.first, uniform.second.x, uniform.second.y, uniform.second.z, uniform.second.w);
}
for (auto & uniform : uniforms4m) {
shader.setUniformMatrix4f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms3m) {
shader.setUniformMatrix3f(uniform.first, uniform.second);
}
for (auto & uniform : uniformstex) {
shader.setUniformTexture(uniform.first,
uniform.second.textureTarget,
uniform.second.textureID,
uniform.second.textureLocation);
}
}
示例4: setupProjectionUniforms
//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::setupProjectionUniforms(ofShader& shader){
if(!getPlayer().isLoaded()){
ofLogWarning() << " CloudsRGBDVideoPlayer::setupProjectionUniforms -- player is not ready";
return;
}
shader.setUniformTexture("rgbdTexture", getPlayer().getTextureReference(), 0);
shader.setUniform2f("textureSize", getPlayer().getWidth(), getPlayer().getHeight());
shader.setUniform4f("colorRect", colorRect.x, colorRect.y, colorRect.width, colorRect.height);
shader.setUniform2f("colorScale", colorScale.x, colorScale.y);
shader.setUniform2f("colorFOV", colorFOV.x, colorFOV.y );
shader.setUniform2f("colorPP", colorPrincipalPoint.x, colorPrincipalPoint.y);
shader.setUniform3f("dK", distortionK.x, distortionK.y, distortionK.z);
shader.setUniform2f("dP", distortionP.x, distortionP.y);
ofMatrix4x4 adjustmentMatrix;
adjustmentMatrix.rotate(adjustRotate.x, 0, 1, 0);
adjustmentMatrix.rotate(adjustRotate.y, 1, 0, 0);
adjustmentMatrix.translate(adjustTranslate.x, adjustTranslate.y, adjustTranslate.z);
shader.setUniformMatrix4f("extrinsics", extrinsics * adjustmentMatrix );
shader.setUniform4f("depthRect", depthRect.x, depthRect.y, depthRect.width, depthRect.height);
shader.setUniform2f("depthPP", depthPrincipalPoint.x, depthPrincipalPoint.y);
shader.setUniform2f("depthFOV", depthFOV.x, depthFOV.y);
shader.setUniform4f("normalRect", normalRect.x, normalRect.y, normalRect.width, normalRect.height);
shader.setUniform4f("faceFeatureRect", faceFeatureRect.x, faceFeatureRect.y, faceFeatureRect.width, faceFeatureRect.height);
shader.setUniform4f("deltaChangeRect", deltaChangeRect.x, deltaChangeRect.y, deltaChangeRect.width, deltaChangeRect.height);
shader.setUniform1i("useFaces", useFaces ? 1 : 0);
shader.setUniform1f("flowPosition", flowPosition);
shader.setUniform1f("farClip", farClip);
shader.setUniform1f("nearClip", nearClip);
shader.setUniform1f("edgeClip", edgeClip);
shader.setUniform1f("minDepth", minDepth);
shader.setUniform1f("maxDepth", maxDepth);
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:VisualSystemsLibrary,代码行数:45,代码来源:CloudsRGBDVideoPlayer.cpp
示例5: draw
void draw() {
ofBackground(25);
fbo.begin();
ofClear(0,0,0,0);
ofEnableDepthTest();
camera.begin();
glPushMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
if(dvel) draw_velocity();
if(dden){
draw_density();
}
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glPopMatrix();
if( drawAxis ){ ofDrawAxis(15); }
camera.end();
ofDisableDepthTest();
fbo.end();
shader.begin();
shader.setUniformTexture("tex",fbo.getTextureReference(),0);
shader.setUniform2f("resolution",dw,dh);
shader.setUniform1f("timer",ofGetElapsedTimef());
fbo.draw(0,0);
shader.end();
gui.draw();
}
示例6: drawFace
void BGNode::drawFace(ofShader & mEyeShader) {
/*
int n = neighbours.size();
ofVec2f toVector(1,0);
if(n > 0)
toVector = (neighbours[0]->position - position).normalize();
ofVec2f perpVec(-toVector.y, toVector.x);
*/
ofSetColor(255);
float offset = .05 * nodeRadius;
float perpOffset = .6 * nodeRadius;
float eyeRadius = .6 * nodeRadius;
ofVec2f toVector = mSurfaceNormal;
ofVec2f perpVec(-toVector.y, toVector.x);
ofVec2f goalPos = position;
if(neighbours.size() > 0)
goalPos = neighbours[0]->position;
float texFactor = .6 * nodeRadius;
for(int i=0; i<2; ++i) {
int factor = i == 0 ? 1 : -1;
ofVec2f pos = position + toVector * offset + factor * perpVec * perpOffset;
ofMesh eyeMesh;
eyeMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
for(int j=0; j<4; ++j) {
ofVec2f texPos(j % 2, j / 2);
ofVec2f vPos = pos + (texPos.x - .5) * texFactor * perpVec + (texPos.y - .5) * texFactor * toVector;
eyeMesh.addVertex(ofVec3f(vPos.x, vPos.y, 0));
eyeMesh.addTexCoord(texPos);
}
ofVec2f goalPos = position;
if(neighbours.size() > 0)
goalPos = neighbours[0]->position;
ofVec2f toGoal = goalPos - pos;
float toGoalLength = toGoal.length();
ofVec2f pupilPos = pos;
if(toGoalLength > 0.01)
pupilPos = pos + .25 * eyeRadius / toGoalLength * toGoal;
mEyeShader.begin();
mEyeShader.setUniform2f("uCenter", pos.x, pos.y);
mEyeShader.setUniform2f("uFocusPoint", goalPos.x, goalPos.y);
mEyeShader.setUniform2f("uPupilLoc", pupilPos.x, pupilPos.y);
mEyeShader.setUniform1i("uFlipHorizontally", i > 0);
eyeMesh.draw();
mEyeShader.end();
}
ofMesh mouthMesh;
mouthMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
for(int i=0; i<21; ++i) {
float t = i / 20.0;
float x = .6 * (t - .5) * nodeRadius;
float yVar = 2 * abs(t - .5);
float y = (-yVar * yVar * (1 - yVar) * .6 - .3) * nodeRadius;
for(int it=0; it<2; ++it) {
mouthMesh.addVertex(position + y * toVector + x * perpVec);
mouthMesh.addColor(ofColor(0));
y -= 3;
}
}
mouthMesh.draw();
}